项目初始化

This commit is contained in:
Stev_Wang
2026-01-04 17:19:04 +08:00
commit 93aae460af
41 changed files with 6922 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
{
path: '/',
redirect: '/player'
},
{
path: '/player/login',
name: 'PlayerLogin',
component: () => import('@/views/player/Login.vue'),
meta: { title: '玩家登录' }
},
{
path: '/player',
component: () => import('@/layouts/PlayerLayout.vue'),
children: [
{
path: 'dashboard',
name: 'PlayerDashboard',
component: () => import('@/views/player/Dashboard.vue'),
meta: { title: '玩家控制台', requiresAuth: true }
}
]
},
{
path: '/admin/login',
name: 'AdminLogin',
component: () => import('@/views/admin/Login.vue'),
meta: { title: '管理员登录' }
},
{
path: '/admin',
component: () => import('@/layouts/AdminLayout.vue'),
children: [
{
path: 'dashboard',
name: 'AdminDashboard',
component: () => import('@/views/admin/Dashboard.vue'),
meta: { title: '管理控制台', requiresAdminAuth: true }
}
]
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
router.beforeEach((to, from, next) => {
document.title = (to.meta.title as string) || '梦幻西游一站式运营管理平台'
if (to.path.startsWith('/player')) {
if (to.path === '/player/login') {
next()
} else {
const playerToken = sessionStorage.getItem('player_token')
if (playerToken) {
next()
} else {
next('/player/login')
}
}
} else if (to.path.startsWith('/admin')) {
if (to.path === '/admin/login') {
next()
} else {
const adminToken = localStorage.getItem('admin_token')
if (adminToken) {
next()
} else {
next('/admin/login')
}
}
} else {
next()
}
})
export default router