From 8d0db4fe4f83eae33d42d81bdceb35bddbfed9ac Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期五, 06 九月 2024 13:54:49 +0800
Subject: [PATCH] refactor- rename
---
src/store/modules/user.ts | 49 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 861f94b..a611f6c 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -40,11 +40,13 @@
// 鍖荤敓璇婂閫夋嫨
isSetRoom: false,
room: {
- id: 0,
- roomId: 0,
- roomName: "",
- bedNo: "",
- onstage: true
+ id: null,
+ roomId: null,
+ roomName: null,
+ bedNo: null,
+ status: null,
+ docId: null,
+ docName: null
}
}),
getters: {
@@ -64,7 +66,7 @@
getIsSetRoom(): boolean {
return this.isSetRoom
},
- getRoom(): RoomVO {
+ getRoom(): RoomVO | null {
return this.room
}
},
@@ -85,10 +87,16 @@
wsCache.set(CACHE_KEY.USER, userInfo)
wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
},
- // 鍖荤敓璇婂閫夋嫨
+ // 鍖荤敓鍏ュ骇
async setRoomInfoAction(room: RoomVO) {
// 鏇存柊 store
- this.room = room
+ this.room!.id = room.id
+ this.room!.roomId = room.roomId
+ this.room!.roomName = room.roomName
+ this.room!.bedNo = room.bedNo
+ this.room!.status = room.status
+ this.room!.docId = room.docId
+ this.room!.docName = room.docName
this.isSetRoom = true
// 鏇存柊 cache
@@ -96,6 +104,27 @@
if (userInfo2) {
userInfo2.room = room
userInfo2.isSetRoom = true
+ wsCache.set(CACHE_KEY.USER, userInfo2)
+ }
+ },
+ // 鍖荤敓绂诲骇
+ async clearRoomInfoAction() {
+ // 娓� store
+ this.room.id = null
+ this.room.roomId = null
+ this.room.roomName = null
+ this.room.bedNo = null
+ this.room.status = null
+ this.room.docId = null
+ this.room.docName = 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)
}
},
@@ -137,7 +166,9 @@
roomId: 0,
roomName: "",
bedNo: "",
- onstage: true
+ status: null,
+ docId: null,
+ docName: null
}
}
}
--
Gitblit v1.9.3