|
@@ -8,15 +8,17 @@ const { websiteMeta, fetchMeta } = useMetaStore()
|
|
|
const loginUserStore = useLoginUserStore()
|
|
const loginUserStore = useLoginUserStore()
|
|
|
const login = computed(()=>loginUserStore.loginUser.isLogin)
|
|
const login = computed(()=>loginUserStore.loginUser.isLogin)
|
|
|
const loginHandler = () => {
|
|
const loginHandler = () => {
|
|
|
-
|
|
|
|
|
|
|
+ router.push('/login')
|
|
|
}
|
|
}
|
|
|
const logoutHandler = () => {
|
|
const logoutHandler = () => {
|
|
|
-
|
|
|
|
|
|
|
+ loginUserStore.logoutUser()
|
|
|
|
|
+ router.push('/')
|
|
|
}
|
|
}
|
|
|
const menus:ComputedRef<RouteRecordRaw[] | undefined> = computed(()=>{
|
|
const menus:ComputedRef<RouteRecordRaw[] | undefined> = computed(()=>{
|
|
|
return adminRoutes[0].children;
|
|
return adminRoutes[0].children;
|
|
|
})
|
|
})
|
|
|
const isCollapse = ref(false)
|
|
const isCollapse = ref(false)
|
|
|
|
|
+const mobileMenuVisible = ref(false)
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
fetchMeta()
|
|
fetchMeta()
|
|
@@ -47,11 +49,14 @@ const handleClose = (key: string, keyPath: string[]) => {
|
|
|
<template>
|
|
<template>
|
|
|
<el-container>
|
|
<el-container>
|
|
|
<el-header class="header">
|
|
<el-header class="header">
|
|
|
- <div class="header-left" @click="router.push('/')">
|
|
|
|
|
- <img :src="websiteMeta.logo" alt="logo" class="logo">
|
|
|
|
|
- <h2 class="title">{{ websiteMeta.title }}</h2>
|
|
|
|
|
|
|
+ <div class="header-left">
|
|
|
|
|
+ <el-button class="menu-toggle" @click="mobileMenuVisible = true">☰</el-button>
|
|
|
|
|
+ <div class="brand" @click="router.push('/')">
|
|
|
|
|
+ <img :src="websiteMeta.logo" alt="logo" class="logo">
|
|
|
|
|
+ <h2 class="title">{{ websiteMeta.title }}</h2>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- <h1>后台管理</h1>
|
|
|
|
|
|
|
+ <h1 class="page-title">后台管理</h1>
|
|
|
<div class="header-right">
|
|
<div class="header-right">
|
|
|
<template v-if="login">
|
|
<template v-if="login">
|
|
|
<el-dropdown placement="bottom">
|
|
<el-dropdown placement="bottom">
|
|
@@ -84,12 +89,49 @@ const handleClose = (key: string, keyPath: string[]) => {
|
|
|
@open="handleOpen"
|
|
@open="handleOpen"
|
|
|
@close="handleClose"
|
|
@close="handleClose"
|
|
|
>
|
|
>
|
|
|
- <el-menu-item :index="menu.path" v-for="menu in menus" :key="menu.path">
|
|
|
|
|
- <el-icon><Component :is="menu.meta?.icon"/></el-icon>
|
|
|
|
|
- <template #title>{{menu.meta?.title}}</template>
|
|
|
|
|
- </el-menu-item>
|
|
|
|
|
|
|
+ <template v-for="menu in menus" :key="menu.path">
|
|
|
|
|
+ <el-sub-menu v-if="menu.children?.length" :index="menu.path">
|
|
|
|
|
+ <template #title>
|
|
|
|
|
+ <el-icon><Component :is="menu.meta?.icon"/></el-icon>
|
|
|
|
|
+ <span>{{menu.meta?.title}}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <el-menu-item v-for="child in menu.children" :key="child.path" :index="child.path">
|
|
|
|
|
+ <template #title>{{child.meta?.title}}</template>
|
|
|
|
|
+ </el-menu-item>
|
|
|
|
|
+ </el-sub-menu>
|
|
|
|
|
+ <el-menu-item v-else :index="menu.path">
|
|
|
|
|
+ <el-icon><Component :is="menu.meta?.icon"/></el-icon>
|
|
|
|
|
+ <template #title>{{menu.meta?.title}}</template>
|
|
|
|
|
+ </el-menu-item>
|
|
|
|
|
+ </template>
|
|
|
</el-menu>
|
|
</el-menu>
|
|
|
</el-aside>
|
|
</el-aside>
|
|
|
|
|
+
|
|
|
|
|
+ <el-drawer
|
|
|
|
|
+ v-model="mobileMenuVisible"
|
|
|
|
|
+ direction="ltr"
|
|
|
|
|
+ size="auto"
|
|
|
|
|
+ :with-header="false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-menu router @select="mobileMenuVisible = false">
|
|
|
|
|
+ <template v-for="menu in menus" :key="menu.path">
|
|
|
|
|
+ <el-sub-menu v-if="menu.children?.length" :index="menu.path">
|
|
|
|
|
+ <template #title>
|
|
|
|
|
+ <el-icon><Component :is="menu.meta?.icon"/></el-icon>
|
|
|
|
|
+ <span>{{menu.meta?.title}}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <el-menu-item v-for="child in menu.children" :key="child.path" :index="child.path">
|
|
|
|
|
+ <template #title>{{child.meta?.title}}</template>
|
|
|
|
|
+ </el-menu-item>
|
|
|
|
|
+ </el-sub-menu>
|
|
|
|
|
+ <el-menu-item v-else :index="menu.path">
|
|
|
|
|
+ <el-icon><Component :is="menu.meta?.icon"/></el-icon>
|
|
|
|
|
+ <template #title>{{menu.meta?.title}}</template>
|
|
|
|
|
+ </el-menu-item>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-menu>
|
|
|
|
|
+ </el-drawer>
|
|
|
|
|
+
|
|
|
<el-main>
|
|
<el-main>
|
|
|
<router-view/>
|
|
<router-view/>
|
|
|
</el-main>
|
|
</el-main>
|
|
@@ -114,6 +156,12 @@ const handleClose = (key: string, keyPath: string[]) => {
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
gap: 10px;
|
|
gap: 10px;
|
|
|
}
|
|
}
|
|
|
|
|
+.brand {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 10px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+}
|
|
|
.logo {
|
|
.logo {
|
|
|
width: 40px;
|
|
width: 40px;
|
|
|
height: 40px;
|
|
height: 40px;
|
|
@@ -139,4 +187,34 @@ const handleClose = (key: string, keyPath: string[]) => {
|
|
|
width: 200px;
|
|
width: 200px;
|
|
|
min-height: 400px;
|
|
min-height: 400px;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+.menu-toggle {
|
|
|
|
|
+ display: none;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.page-title {
|
|
|
|
|
+ font-size: 20px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+@media (max-width: 768px) {
|
|
|
|
|
+ .menu {
|
|
|
|
|
+ display: none;
|
|
|
|
|
+ }
|
|
|
|
|
+ .menu-toggle {
|
|
|
|
|
+ display: inline-flex;
|
|
|
|
|
+ }
|
|
|
|
|
+ .header {
|
|
|
|
|
+ padding: 0 10px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .header-left .title {
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .logo {
|
|
|
|
|
+ width: 32px;
|
|
|
|
|
+ height: 32px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .page-title {
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|