Ver Fonte

fix: 登录时清除公司缓存

gatsby há 1 mês atrás
pai
commit
29e6b0466b

+ 5 - 4
frontend/src/plugins/permission.ts

@@ -65,10 +65,11 @@ async function handleAuthenticatedUser(
       // 如果用户信息为空,获取用户信息
       if (!userStore.basicInfo?.roles?.length) {
         await userStore.getUserInfo();
-        // 如果是租户用户,获取企业列表
-        if (!userStore.is_platform_user) {
-          await enterpriseStore.loadEnterpriseList();
-        }
+      }
+
+      // 如果是租户用户,获取企业列表
+      if (!userStore.is_platform_user) {
+        await enterpriseStore.loadEnterpriseList();
       }
 
       const dynamicRoutes = await permissionStore.generateRoutes();

+ 4 - 0
frontend/src/store/modules/user.store.ts

@@ -9,6 +9,8 @@ import { ResultEnum } from "@/enums";
 
 export { type TenantInfo } from "@/api/module_system/tenant";
 
+import { useEnterpriseStore } from "@/store";
+
 export const useUserStore = defineStore("user", {
   state: () => ({
     basicInfo: {} as UserInfo,
@@ -132,6 +134,8 @@ export const useUserStore = defineStore("user", {
         });
       }
       this.resetAllState();
+      // 重置企业列表
+      useEnterpriseStore().clearEnterprise();
     },
 
     // 重置所有状态