From 0497b5fbb99f548b51c95597255f008276f1cca0 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Fri, 27 Mar 2026 19:09:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20=E8=BF=81=E7=A7=BB=20router.b?= =?UTF-8?q?eforeEach=20=E5=88=B0=20Vue=20Router=204=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/router/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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(() => {