diff --git a/dashboard/src/router/index.ts b/dashboard/src/router/index.ts index 8523bfb58..e484d86de 100644 --- a/dashboard/src/router/index.ts +++ b/dashboard/src/router/index.ts @@ -22,7 +22,7 @@ interface AuthStore { has_token(): boolean; } -router.beforeEach(async (to, from, next) => { +router.beforeEach(async (to, from) => { if (from.name && from.path !== to.path) { const loadingStore = useRouterLoadingStore(); loadingStore.start(); @@ -34,17 +34,17 @@ router.beforeEach(async (to, from, next) => { // 如果用户已登录且试图访问登录页面,则重定向到首页 if (to.path === '/auth/login' && auth.has_token()) { - return next(auth.returnUrl || '/'); + return auth.returnUrl || '/'; } if (to.matched.some((record) => record.meta.requiresAuth)) { if (authRequired && !auth.has_token()) { auth.returnUrl = to.fullPath; - return next('/auth/login'); - } else next(); - } else { - next(); + return '/auth/login'; + } } + + return true; }); router.afterEach(() => {