Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Login): avoid infinite loop when query redirect to next route red… #3630

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading