diff --git a/src/router/guard.ts b/src/router/guard.ts index a655401..d92771e 100644 --- a/src/router/guard.ts +++ b/src/router/guard.ts @@ -49,8 +49,8 @@ function setupCommonGuard(router: Router) { return { path: '/auth/login', query: { redirect: to.fullPath }, replace: true } } - // 没有访问权限,跳转登录页面 - if (to.fullPath !== '/auth/login') { + // 没有访问权限,跳转登录页面(使用 to.path 而非 to.fullPath,避免 query 参数导致无限重定向) + if (to.path !== '/auth/login') { return { path: '/auth/login', query: { redirect: to.fullPath }, @@ -58,7 +58,8 @@ function setupCommonGuard(router: Router) { replace: true } } - return to + // 登录页面且已带 redirect 参数(由上面逻辑设置),允许进入 + return true } return true