fix(Login): avoid infinite loop when query redirect to next route redirect (#3630). resolve #3620 #3627
This commit is contained in:
parent
1a7ae0e810
commit
ab55cbf99b
|
|
@ -113,6 +113,11 @@ export function createPermissionGuard(router: Router) {
|
||||||
} else if (from.query.redirect) {
|
} else if (from.query.redirect) {
|
||||||
// 存在redirect
|
// 存在redirect
|
||||||
const redirect = decodeURIComponent((from.query.redirect as string) || '');
|
const redirect = decodeURIComponent((from.query.redirect as string) || '');
|
||||||
|
|
||||||
|
// 只处理一次 from.query.redirect
|
||||||
|
// 也避免某场景(指向路由定义了 redirect)下的死循环
|
||||||
|
from.query.redirect = '';
|
||||||
|
|
||||||
if (redirect === to.fullPath) {
|
if (redirect === to.fullPath) {
|
||||||
// 已经被redirect
|
// 已经被redirect
|
||||||
next();
|
next();
|
||||||
|
|
@ -120,6 +125,7 @@ export function createPermissionGuard(router: Router) {
|
||||||
// 指向redirect
|
// 指向redirect
|
||||||
next({ path: redirect, replace: true });
|
next({ path: redirect, replace: true });
|
||||||
}
|
}
|
||||||
|
next();
|
||||||
} else {
|
} else {
|
||||||
// 正常访问
|
// 正常访问
|
||||||
next();
|
next();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue