perf: 路由守卫获取菜单异常,跳转登录页并弹窗提示 (#502)

This commit is contained in:
liweijie0812 2023-05-11 22:10:32 +08:00 committed by GitHub
parent 4bcf7d22aa
commit c89f434ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,14 +25,6 @@ router.beforeEach(async (to, from, next) => {
}
try {
await userStore.getUserInfo();
} catch (error) {
MessagePlugin.error(error);
next({
path: '/login',
query: { redirect: encodeURIComponent(to.fullPath) },
});
NProgress.done();
}
const { asyncRoutes } = permissionStore;
@ -51,12 +43,19 @@ router.beforeEach(async (to, from, next) => {
return;
}
}
if (router.hasRoute(to.name)) {
next();
} else {
next(`/`);
}
} catch (error) {
MessagePlugin.error(error.message);
next({
path: '/login',
query: { redirect: encodeURIComponent(to.fullPath) },
});
NProgress.done();
}
} else {
/* white list router */
if (whiteListRouters.indexOf(to.path) !== -1) {