From fe792c0638eeaaba49289de00c4c59bd6279ecd9 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期二, 27 八月 2024 17:11:37 +0800
Subject: [PATCH] update

---
 src/store/modules/user.ts |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 861f94b..8fd7e8d 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -23,7 +23,7 @@
 
   // 鍖荤敓璇婂閫夋嫨
   isSetRoom: boolean
-  room: RoomVO
+  room: RoomVO | null
 }
 
 export const useUserStore = defineStore('admin-user', {
@@ -85,7 +85,7 @@
       wsCache.set(CACHE_KEY.USER, userInfo)
       wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
     },
-    // 鍖荤敓璇婂閫夋嫨
+    // 鍖荤敓鍏ュ骇
     async setRoomInfoAction(room: RoomVO) {
       // 鏇存柊 store
       this.room = room
@@ -99,6 +99,20 @@
         wsCache.set(CACHE_KEY.USER, userInfo2)
       }
     },
+    // 鍖荤敓绂诲骇
+    async clearRoomInfoAction() {
+      // 娓� store
+      this.room = null
+      this.isSetRoom = false
+
+      // 鏇存柊 cache
+      const userInfo2 = wsCache.get(CACHE_KEY.USER)
+      if (userInfo2) {
+        userInfo2.room = null
+        userInfo2.isSetRoom = false
+        wsCache.set(CACHE_KEY.USER, userInfo2)
+      }
+    },
 
     async setUserAvatarAction(avatar: string) {
       const userInfo = wsCache.get(CACHE_KEY.USER)

--
Gitblit v1.9.3