支持配置后台页面入口

This commit is contained in:
yml2213
2026-06-11 08:00:13 +08:00
parent 7130135e23
commit 6d61a336d6
27 changed files with 157 additions and 85 deletions
+4 -3
View File
@@ -3,6 +3,7 @@ import { createRouter, createWebHistory } from 'vue-router'
import { useAdminSessionStore } from '@/stores/adminSession'
import { useSessionStore } from '@/stores/session'
import { getAccessToken, getLoginPath } from '@/shared/utils/authStorage'
import { ADMIN_DASHBOARD_PATH, ADMIN_LOGIN_PATH } from '@/shared/utils/adminPath'
import { accountRoutes } from './accountRoutes'
import { adminRoutes } from './adminRoutes'
import { isMobileHost, isMobileDevice, getMobilePath, getPcPath } from './mobileHost'
@@ -77,11 +78,11 @@ router.beforeEach(async to => {
const adminSession = useAdminSessionStore()
adminSession.syncFromStorage()
if (to.path === '/admin/login') {
if (to.path === ADMIN_LOGIN_PATH) {
if (!adminSession.hasSessionHint) return true
try {
await adminSession.loadMe()
return '/admin/dashboard'
return ADMIN_DASHBOARD_PATH
} catch {
adminSession.logout()
return true
@@ -98,7 +99,7 @@ router.beforeEach(async to => {
}
} catch {
adminSession.logout()
return { path: '/admin/login', query: { redirect: to.fullPath } }
return { path: ADMIN_LOGIN_PATH, query: { redirect: to.fullPath } }
}
}
return true