增加后台管理模块

This commit is contained in:
2025-10-27 23:57:31 +08:00
parent 3c1ba8e801
commit 0016453f20
420 changed files with 5650 additions and 1449 deletions
+84
View File
@@ -0,0 +1,84 @@
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layouts/Layout.vue'
const routes: RouteRecordRaw[] = [
{
path: '/login',
name: 'Login',
component: () => import('@/views/Login.vue'),
meta: { title: '登录', hidden: true }
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/Dashboard.vue'),
meta: { title: '仪表盘', icon: 'DataLine' }
}
]
},
{
path: '/admin',
component: Layout,
redirect: '/admin/list',
meta: { title: '管理员管理', icon: 'User' },
children: [
{
path: 'list',
name: 'AdminList',
component: () => import('@/views/admin/AdminList.vue'),
meta: { title: '管理员列表', icon: 'User' }
}
]
},
{
path: '/user',
component: Layout,
redirect: '/user/list',
meta: { title: '用户管理', icon: 'UserFilled' },
children: [
{
path: 'list',
name: 'UserList',
component: () => import('@/views/user/UserList.vue'),
meta: { title: '用户列表', icon: 'UserFilled' }
}
]
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/views/NotFound.vue'),
meta: { title: '404', hidden: true }
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
// 路由守卫
router.beforeEach((to, from, next) => {
const token = localStorage.getItem('adminToken')
if (to.path === '/login') {
if (token) {
next('/')
} else {
next()
}
} else {
if (token) {
next()
} else {
next('/login')
}
}
})
export default router