From 45d90d1e7ba86286e998d1ac4d2cba8e98cd059b Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期一, 12 一月 2026 20:52:30 +0800
Subject: [PATCH] feat: 优化内存

---
 app/store/modules/user.js |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/app/store/modules/user.js b/app/store/modules/user.js
index ec289bf..1b929ea 100644
--- a/app/store/modules/user.js
+++ b/app/store/modules/user.js
@@ -19,7 +19,9 @@
     deptId: storage.get(constant.deptId),
     branchCompanyId: storage.get(constant.branchCompanyId),
     branchCompanyName: storage.get(constant.branchCompanyName),
-    oaUserId: storage.get(constant.oaUserId)
+    oaUserId: storage.get(constant.oaUserId),
+    canCreateTask: storage.get(constant.canCreateTask),
+    canViewAllConsult: storage.get(constant.canViewAllConsult)
   },
 
   mutations: {
@@ -65,6 +67,14 @@
     SET_OA_USER_ID: (state, oaUserId) => {
       state.oaUserId = oaUserId
       storage.set(constant.oaUserId, oaUserId)
+    },
+    SET_CAN_CREATE_TASK: (state, canCreateTask) => {
+      state.canCreateTask = canCreateTask
+      storage.set(constant.canCreateTask, canCreateTask)
+    },
+    SET_CAN_VIEW_ALL_CONSULT: (state, canViewAllConsult) => {
+      state.canViewAllConsult = canViewAllConsult
+      storage.set(constant.canViewAllConsult, canViewAllConsult)
     }
   },
 
@@ -124,6 +134,8 @@
           commit('SET_BRANCH_COMPANY_ID', res.branchCompanyId)
           commit('SET_BRANCH_COMPANY_NAME', res.branchCompanyName)
           commit('SET_OA_USER_ID', res.oaUserId)
+          commit('SET_CAN_CREATE_TASK', res.canCreateTask)
+          commit('SET_CAN_VIEW_ALL_CONSULT', res.canViewAllConsult)
           resolve(res)
         }).catch(error => {
           reject(error)
@@ -140,8 +152,22 @@
           commit('SET_PERMISSIONS', [])
           removeToken()
           storage.clean()
+          
+          // 瑙﹀彂鍏ㄥ眬浜嬩欢锛岄�氱煡 App.vue 鍋滄杞
+          uni.$emit('user-logout')
+          
           resolve()
         }).catch(error => {
+          // 鍗充娇閫�鍑烘帴鍙eけ璐ワ紝涔熻娓呯┖鏈湴鐘舵��
+          commit('SET_TOKEN', '')
+          commit('SET_ROLES', [])
+          commit('SET_PERMISSIONS', [])
+          removeToken()
+          storage.clean()
+          
+          // 瑙﹀彂鍏ㄥ眬浜嬩欢
+          uni.$emit('user-logout')
+          
           reject(error)
         })
       })

--
Gitblit v1.9.1