mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 07:28:24 +08:00
perf: 路由守卫获取菜单异常,跳转登录页并弹窗提示 (#502)
This commit is contained in:
parent
4bcf7d22aa
commit
c89f434ce8
|
@ -25,14 +25,6 @@ router.beforeEach(async (to, from, next) => {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await userStore.getUserInfo();
|
await userStore.getUserInfo();
|
||||||
} catch (error) {
|
|
||||||
MessagePlugin.error(error);
|
|
||||||
next({
|
|
||||||
path: '/login',
|
|
||||||
query: { redirect: encodeURIComponent(to.fullPath) },
|
|
||||||
});
|
|
||||||
NProgress.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { asyncRoutes } = permissionStore;
|
const { asyncRoutes } = permissionStore;
|
||||||
|
|
||||||
|
@ -51,12 +43,19 @@ router.beforeEach(async (to, from, next) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (router.hasRoute(to.name)) {
|
if (router.hasRoute(to.name)) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
next(`/`);
|
next(`/`);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
MessagePlugin.error(error.message);
|
||||||
|
next({
|
||||||
|
path: '/login',
|
||||||
|
query: { redirect: encodeURIComponent(to.fullPath) },
|
||||||
|
});
|
||||||
|
NProgress.done();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* white list router */
|
/* white list router */
|
||||||
if (whiteListRouters.indexOf(to.path) !== -1) {
|
if (whiteListRouters.indexOf(to.path) !== -1) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user