|
|
@@ -37,6 +37,7 @@ router.beforeEach(async (to, from, next) => {
|
|
|
to.meta.title && useSettingsStore().setTitle(to.meta.title as string);
|
|
|
/* has token*/
|
|
|
if (to.path === '/login') {
|
|
|
+ // 已有 token 时先进首页;若会话已失效,下面 getInfo 失败会清 token 并回登录页
|
|
|
next({ path: '/' });
|
|
|
NProgress.done();
|
|
|
} else if (isWhiteList(to.path)) {
|
|
|
@@ -47,9 +48,9 @@ router.beforeEach(async (to, from, next) => {
|
|
|
// 判断当前用户是否已拉取完user_info信息
|
|
|
const [err] = await tos(useUserStore().getInfo());
|
|
|
if (err) {
|
|
|
+ isRelogin.show = false;
|
|
|
await useUserStore().logout();
|
|
|
- // ElMessage.error(err.message || '获取用户信息失败');
|
|
|
- next({ path: '/' });
|
|
|
+ next(`/login?redirect=${encodeURIComponent(to.fullPath || '/')}`);
|
|
|
} else {
|
|
|
isRelogin.show = false;
|
|
|
const accessRoutes = await usePermissionStore().generateRoutes();
|