From f67b9f5f6ec691bfd80557db67d8477e9a79a2cc Mon Sep 17 00:00:00 2001 From: Larch-C Date: Sat, 17 May 2025 18:09:49 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E4=BA=86=E5=A6=82=E6=9E=9C=E6=AD=A4=E5=89=8D=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BD=86=E6=9C=AA=E8=87=AA=E8=A1=8C=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/router/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dashboard/src/router/index.ts b/dashboard/src/router/index.ts index a56154f18..c44e0249d 100644 --- a/dashboard/src/router/index.ts +++ b/dashboard/src/router/index.ts @@ -24,6 +24,11 @@ router.beforeEach(async (to, from, next) => { const authRequired = !publicPages.includes(to.path); const auth: AuthStore = useAuthStore(); + // 如果用户已登录且试图访问登录页面,则重定向到首页或之前尝试访问的页面 + if (to.path === '/auth/login' && auth.has_token()) { + return next(auth.returnUrl || '/'); + } + if (to.matched.some((record) => record.meta.requiresAuth)) { if (authRequired && !auth.has_token()) { auth.returnUrl = to.fullPath;