Browse Source

[Wip 0000] 自动登录问题修改-进行中

houzekong 8 months ago
parent
commit
f2fa809a4f
3 changed files with 7 additions and 3 deletions
  1. 1 1
      src/router/guard/index.ts
  2. 5 0
      src/store/modules/user.ts
  3. 1 2
      src/utils/http/axios/checkStatus.ts

+ 1 - 1
src/router/guard/index.ts

@@ -71,7 +71,7 @@ function createPageLoadingGuard(router: Router) {
       return true;
     }
     if (!ventStore.allTableHeaderColumns) {
-      ventStore.setAllTableHeaderColumns();
+      await ventStore.setAllTableHeaderColumns();
     }
     if (unref(getOpenPageLoading)) {
       appStore.setPageLoadingAction(true);

+ 5 - 0
src/store/modules/user.ts

@@ -89,6 +89,11 @@ export const useUserStore = defineStore({
     getPassword() {
       return getAuthCache<string>(PWD_KEY);
     },
+    // 目前用户角色列表为空数组,所以使用既定的用户名判断
+    getIsAutoLogin() {
+      console.log(this.getUserInfo.username === AUTO_LOGIN_USERNAME);
+      return this.getUserInfo.username === AUTO_LOGIN_USERNAME;
+    },
   },
   actions: {
     /** 设置用户密码并加密,理论上加密、解密的工作应仅在此模块进行 */

+ 1 - 2
src/utils/http/axios/checkStatus.ts

@@ -31,8 +31,7 @@ export function checkStatus(status: number, msg: string, errorMessageMode: Error
         userStore.setSessionTimeout(true);
       } else {
         // 经由自动登录的账号需要在登录信息过期之后重新登录
-        // 目前用户角色列表为空数组,所以使用既定的用户名判断
-        const continuallyLogin = userStore.getUserInfo.username === AUTO_LOGIN_USERNAME;
+        const continuallyLogin = userStore.getIsAutoLogin;
         if (continuallyLogin) {
           userStore.continuallyLogin();
         } else {