You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
5.9 KiB

<template>
<div class="dashboard-navbar">
<div class="navbar-left">
<div class="hamburger-btn" @click="toggleSideBar">
<i class="fa fa-bars"></i>
</div>
<div class="system-title">
<span class="title-main">执法监督码</span>
<span class="title-dot">·</span>
<span class="title-sub">执法监督</span>
</div>
2 months ago
</div>
<div class="navbar-right">
<div class="system-tabs">
<div
v-for="item in permissionStore.visibleSystemCodeOptions"
:key="item.value"
class="system-tab"
:class="{ 'is-active': item.value === currentSystemCode }"
@click="handleSystemCodeChange(item.value)"
>
<div class="nav-icon">
2 months ago
<el-icon><component :is="item.icon" /></el-icon>
</div>
<div class="nav-label">{{ item.label }}</div>
2 months ago
</div>
</div>
<div class="user-info">
<div class="user-avatar">
<img :src="userStore.avatar" alt="avatar" />
</div>
<div class="user-detail">
<div class="username">{{ userStore.nickname || 'admin' }}</div>
<div class="user-org">深圳市司法局</div>
</div>
<el-dropdown trigger="click" @command="handleCommand">
<i class="fa fa-caret-down user-caret"></i>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { useAppStore } from '@/store/modules/app';
import { useUserStore } from '@/store/modules/user';
import { usePermissionStore } from '@/store/modules/permission';
import { ElMessageBox } from 'element-plus';
import type { ElMessageBoxOptions } from 'element-plus/es/components/message-box/src/message-box.type';
import router from '@/router';
const appStore = useAppStore();
const userStore = useUserStore();
const permissionStore = usePermissionStore();
const currentSystemCode = ref(permissionStore.currentSystemCode);
watch(
() => permissionStore.currentSystemCode,
(val) => {
currentSystemCode.value = val;
}
);
const toggleSideBar = () => {
appStore.toggleSideBar(false);
};
2 months ago
const handleSystemCodeChange = async (systemCode: string) => {
2 months ago
currentSystemCode.value = systemCode;
await permissionStore.switchSystemCode(systemCode);
};
const handleCommand = async (command: string) => {
if (command === 'logout') {
await ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
} as ElMessageBoxOptions);
await userStore.logout();
router.replace({ path: '/login' });
}
};
</script>
<style lang="scss" scoped>
.dashboard-navbar {
height: 50px;
background: linear-gradient(180deg, #0c3d8f 0%, #0a2e72 100%);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
position: relative;
z-index: 1000;
}
.navbar-left {
display: flex;
align-items: center;
gap: 20px;
}
.hamburger-btn {
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
cursor: pointer;
transition: background 0.2s;
i {
color: rgba(255, 255, 255, 0.9);
font-size: 18px;
}
&:hover {
background: rgba(255, 255, 255, 0.1);
}
}
.system-title {
display: flex;
align-items: baseline;
gap: 2px;
}
.title-main {
font-size: 20px;
font-weight: 600;
color: #fff;
letter-spacing: 2px;
text-shadow: 0 0 10px rgba(64, 180, 255, 0.5);
}
.title-dot {
font-size: 18px;
color: rgba(255, 255, 255, 0.7);
margin: 0 2px;
}
.title-sub {
font-size: 18px;
font-weight: 500;
color: rgba(255, 255, 255, 0.9);
letter-spacing: 2px;
}
.navbar-right {
display: flex;
align-items: center;
gap: 8px;
}
2 months ago
.system-tabs {
display: flex;
align-items: center;
gap: 4px;
margin-right: 12px;
}
.system-tab {
display: flex;
flex-direction: column;
2 months ago
align-items: center;
justify-content: center;
width: 64px;
height: 44px;
border-radius: 6px;
2 months ago
cursor: pointer;
transition: all 0.25s ease;
position: relative;
2 months ago
&:hover {
background: rgba(255, 255, 255, 0.12);
.nav-icon .el-icon {
color: rgba(255, 255, 255, 0.9);
}
.nav-label {
color: rgba(255, 255, 255, 0.9);
}
2 months ago
}
&.is-active {
background: rgba(64, 160, 255, 0.25);
box-shadow: inset 0 -2px 0 #40a0ff;
2 months ago
.nav-icon .el-icon {
color: #fff;
2 months ago
}
.nav-label {
color: #fff;
}
2 months ago
}
}
.nav-icon {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1px;
.el-icon {
font-size: 16px;
color: rgba(255, 255, 255, 0.75);
transition: color 0.25s;
}
}
.nav-label {
font-size: 12px;
color: rgba(255, 255, 255, 0.7);
white-space: nowrap;
transition: color 0.25s;
}
.user-info {
2 months ago
display: flex;
align-items: center;
gap: 10px;
margin-left: 16px;
padding: 4px 12px 4px 4px;
border-radius: 24px;
background: rgba(255, 255, 255, 0.08);
cursor: pointer;
transition: background 0.2s;
&:hover {
background: rgba(255, 255, 255, 0.15);
}
}
.user-avatar {
width: 34px;
height: 34px;
border-radius: 50%;
overflow: hidden;
border: 2px solid rgba(64, 160, 255, 0.6);
box-shadow: 0 0 8px rgba(64, 160, 255, 0.3);
img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
}
.user-detail {
display: flex;
flex-direction: column;
line-height: 1.2;
}
.username {
font-size: 14px;
font-weight: 500;
color: #fff;
}
.user-org {
font-size: 11px;
color: rgba(255, 255, 255, 0.65);
margin-top: 2px;
}
.user-caret {
color: rgba(255, 255, 255, 0.6);
font-size: 12px;
margin-left: 4px;
}
</style>