diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index f5aceab..efb7df7 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -75,9 +75,15 @@ router.beforeEach(async ( const title = to.meta.title as string document.title = `${title} - AI` + const authStore = useAuthStore() + // 用户已登录,重定向到dashboard + if (to.path === '/' && authStore.isLoggedIn) { + next({ name: 'Dashboard' }) + return + } + // 检查是否需要用户认证 if (to.meta.requiresAuth) { - const authStore = useAuthStore() if (!authStore.isLoggedIn) { next('/') return @@ -92,7 +98,7 @@ router.beforeEach(async ( } } - next('/dashboard') + next() }) export default router \ No newline at end of file