refactor: ♻️ 获取用户信息和登出清除会话优化

Former-commit-id: 4486879b3beb4d26b7a41cffd4e0b4b022e1943d
This commit is contained in:
郝先瑞
2023-11-09 18:32:51 +08:00
parent 642f4cbe8c
commit 8bd514fa29
5 changed files with 23 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ router.beforeEach(async (to, from, next) => {
}
} else {
try {
const { roles } = await userStore.getInfo();
const { roles } = await userStore.getUserInfo();
const accessRoutes = await permissionStore.generateRoutes(roles);
accessRoutes.forEach((route) => {
router.addRoute(route);
@@ -40,7 +40,7 @@ router.beforeEach(async (to, from, next) => {
next({ ...to, replace: true });
} catch (error) {
// 移除 token 并跳转登录页
await userStore.resetStore();
await userStore.resetToken();
next(`/login?redirect=${to.path}`);
NProgress.done();
}