jump to dashboard
This commit is contained in:
@@ -75,9 +75,15 @@ router.beforeEach(async (
|
|||||||
const title = to.meta.title as string
|
const title = to.meta.title as string
|
||||||
document.title = `${title} - AI`
|
document.title = `${title} - AI`
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
// 用户已登录,重定向到dashboard
|
||||||
|
if (to.path === '/' && authStore.isLoggedIn) {
|
||||||
|
next({ name: 'Dashboard' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 检查是否需要用户认证
|
// 检查是否需要用户认证
|
||||||
if (to.meta.requiresAuth) {
|
if (to.meta.requiresAuth) {
|
||||||
const authStore = useAuthStore()
|
|
||||||
if (!authStore.isLoggedIn) {
|
if (!authStore.isLoggedIn) {
|
||||||
next('/')
|
next('/')
|
||||||
return
|
return
|
||||||
@@ -92,7 +98,7 @@ router.beforeEach(async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next('/dashboard')
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
Reference in New Issue
Block a user