110 行
2.5 KiB
Vue
110 行
2.5 KiB
Vue
|
|
<template>
|
||
|
|
<el-container class="layout-container">
|
||
|
|
<el-aside width="220px" class="sidebar">
|
||
|
|
<div class="logo">
|
||
|
|
<span>XuqmGroup</span>
|
||
|
|
</div>
|
||
|
|
<el-menu
|
||
|
|
:default-active="$route.path"
|
||
|
|
router
|
||
|
|
background-color="#1d2129"
|
||
|
|
text-color="#c9d1d9"
|
||
|
|
active-text-color="#409eff"
|
||
|
|
>
|
||
|
|
<el-menu-item index="/dashboard">
|
||
|
|
<el-icon><Odometer /></el-icon>
|
||
|
|
<span>控制台</span>
|
||
|
|
</el-menu-item>
|
||
|
|
<el-menu-item index="/apps">
|
||
|
|
<el-icon><Grid /></el-icon>
|
||
|
|
<span>我的应用</span>
|
||
|
|
</el-menu-item>
|
||
|
|
<el-menu-item index="/accounts" v-if="auth.user?.type === 'MAIN'">
|
||
|
|
<el-icon><User /></el-icon>
|
||
|
|
<span>子账号管理</span>
|
||
|
|
</el-menu-item>
|
||
|
|
</el-menu>
|
||
|
|
</el-aside>
|
||
|
|
|
||
|
|
<el-container>
|
||
|
|
<el-header class="header">
|
||
|
|
<div class="header-right">
|
||
|
|
<el-dropdown @command="handleCommand">
|
||
|
|
<span class="user-info">
|
||
|
|
<el-avatar :size="32" style="background:#409eff">
|
||
|
|
{{ auth.user?.nickname?.charAt(0) ?? 'U' }}
|
||
|
|
</el-avatar>
|
||
|
|
<span class="nickname">{{ auth.user?.nickname }}</span>
|
||
|
|
</span>
|
||
|
|
<template #dropdown>
|
||
|
|
<el-dropdown-menu>
|
||
|
|
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
|
||
|
|
</el-dropdown-menu>
|
||
|
|
</template>
|
||
|
|
</el-dropdown>
|
||
|
|
</div>
|
||
|
|
</el-header>
|
||
|
|
|
||
|
|
<el-main>
|
||
|
|
<router-view />
|
||
|
|
</el-main>
|
||
|
|
</el-container>
|
||
|
|
</el-container>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import { useAuthStore } from '@/stores/auth'
|
||
|
|
import { useRouter } from 'vue-router'
|
||
|
|
|
||
|
|
const auth = useAuthStore()
|
||
|
|
const router = useRouter()
|
||
|
|
|
||
|
|
function handleCommand(cmd: string) {
|
||
|
|
if (cmd === 'logout') {
|
||
|
|
auth.logout()
|
||
|
|
router.push('/login')
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
.layout-container {
|
||
|
|
height: 100vh;
|
||
|
|
}
|
||
|
|
.sidebar {
|
||
|
|
background: #1d2129;
|
||
|
|
}
|
||
|
|
.logo {
|
||
|
|
height: 60px;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
color: #fff;
|
||
|
|
font-size: 18px;
|
||
|
|
font-weight: bold;
|
||
|
|
border-bottom: 1px solid #2d3142;
|
||
|
|
}
|
||
|
|
.header {
|
||
|
|
background: #fff;
|
||
|
|
border-bottom: 1px solid #e8e8e8;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: flex-end;
|
||
|
|
}
|
||
|
|
.header-right {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 12px;
|
||
|
|
}
|
||
|
|
.user-info {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
cursor: pointer;
|
||
|
|
}
|
||
|
|
.nickname {
|
||
|
|
font-size: 14px;
|
||
|
|
color: #333;
|
||
|
|
}
|
||
|
|
</style>
|