fix: fix the original page after login expired

This commit is contained in:
vben
2020-11-10 21:30:06 +08:00
parent 7675a9f6e1
commit 6676c9506b
3 changed files with 14 additions and 11 deletions

View File

@@ -40,8 +40,17 @@ export function createPermissionGuard(router: Router) {
return;
}
// redirect login page
const redirectPath = to.path ? `${LOGIN_PATH}?redirect=${to.path}` : LOGIN_PATH;
next(redirectPath);
const redirectData: { path: string; replace: boolean; query?: { [key: string]: string } } = {
path: LOGIN_PATH,
replace: true,
};
if (to.path) {
redirectData.query = {
...redirectData.query,
redirect: to.path,
};
}
next(redirectData);
return;
}
if (permissionStore.getIsDynamicAddedRouteState) {