Skip to content

Commit

Permalink
fix(Login): avoid infinite loop when query redirect to next route red…
Browse files Browse the repository at this point in the history
…irect (vbenjs#3630). resolve vbenjs#3620 vbenjs#3627
  • Loading branch information
xachary authored Feb 27, 2024
1 parent 1a7ae0e commit ab55cbf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/router/guard/permissionGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ export function createPermissionGuard(router: Router) {
} else if (from.query.redirect) {
// 存在redirect
const redirect = decodeURIComponent((from.query.redirect as string) || '');

// 只处理一次 from.query.redirect
// 也避免某场景(指向路由定义了 redirect)下的死循环
from.query.redirect = '';

if (redirect === to.fullPath) {
// 已经被redirect
next();
} else {
// 指向redirect
next({ path: redirect, replace: true });
}
next();
} else {
// 正常访问
next();
Expand Down

0 comments on commit ab55cbf

Please sign in to comment.