fix(Login): avoid infinite loop when query redirect to next route redirect (#3630). resolve #3620 #3627

This commit is contained in:
xachary
2024-02-27 18:14:06 +08:00
committed by GitHub
parent 1a7ae0e810
commit ab55cbf99b

View File

@@ -113,6 +113,11 @@ 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();
@@ -120,6 +125,7 @@ export function createPermissionGuard(router: Router) {
// 指向redirect
next({ path: redirect, replace: true });
}
next();
} else {
// 正常访问
next();