mirror of
https://gitcode.com/gh_mirrors/vue/vue-vben-admin
synced 2025-12-30 13:12:26 +00:00
fix(Login): avoid infinite loop when query redirect to next route redirect (#3630). resolve #3620 #3627
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user