mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 04:26:30 +08:00
chore: 先验证token,再获取菜单 (#487)
This commit is contained in:
parent
a0c67b05d9
commit
0d70db425d
|
@ -23,6 +23,16 @@ router.beforeEach(async (to, from, next) => {
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
await userStore.getUserInfo();
|
||||||
|
} catch (error) {
|
||||||
|
MessagePlugin.error(error);
|
||||||
|
next({
|
||||||
|
path: '/login',
|
||||||
|
query: { redirect: encodeURIComponent(to.fullPath) },
|
||||||
|
});
|
||||||
|
NProgress.done();
|
||||||
|
}
|
||||||
|
|
||||||
const { asyncRoutes } = permissionStore;
|
const { asyncRoutes } = permissionStore;
|
||||||
|
|
||||||
|
@ -42,22 +52,11 @@ router.beforeEach(async (to, from, next) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await userStore.getUserInfo();
|
|
||||||
|
|
||||||
if (router.hasRoute(to.name)) {
|
if (router.hasRoute(to.name)) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
next(`/`);
|
next(`/`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
MessagePlugin.error(error);
|
|
||||||
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