支持配置后台页面入口
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user