完成代码,提交了再删除其他页面

This commit is contained in:
2026-04-22 14:27:44 +08:00
parent 1312131b1e
commit 188b396fea
12 changed files with 173 additions and 177 deletions

View File

@@ -22,14 +22,18 @@ export function createRouterGuards(router: Router) {
return;
}
const token = storage.get(ACCESS_TOKEN);
// Whitelist can be directly entered
if (whitePathList.includes(to.path as PageEnum)) {
if (to.path === LOGIN_PATH && token) {
next({ path: PageEnum.BASE_HOME, replace: true });
return;
}
next();
return;
}
const token = storage.get(ACCESS_TOKEN);
if (!token) {
// You can access without permissions. You need to set the routing meta.ignoreAuth to true
if (to.meta.ignoreAuth) {
@@ -71,9 +75,7 @@ export function createRouterGuards(router: Router) {
router.addRoute(ErrorPageRoute as unknown as RouteRecordRaw);
}
const redirectPath = (from.query.redirect || to.path) as string;
const redirect = decodeURIComponent(redirectPath);
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect };
const nextData = { ...to, replace: true };
asyncRouteStore.setDynamicRouteAdded(true);
next(nextData);
Loading && Loading.finish();