From e456f20e2d54f542800580c489f36c0b5eaf734f Mon Sep 17 00:00:00 2001 From: eight <641137800@qq.com> Date: 星期四, 29 八月 2024 17:33:29 +0800 Subject: [PATCH] update --- src/store/modules/user.ts | 63 +++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index b386180..53f2d69 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -3,6 +3,7 @@ import { getAccessToken, removeToken } from '@/utils/auth' import { CACHE_KEY, useCache, deleteUserCache } from '@/hooks/web/useCache' import { getInfo, loginOut } from '@/api/login' +import {RoomVO} from "@/api/ecg/room"; const { wsCache } = useCache() @@ -19,6 +20,10 @@ roles: string[] isSetUser: boolean user: UserVO + + // 鍖荤敓璇婂閫夋嫨 + isSetRoom: boolean + room: RoomVO | null } export const useUserStore = defineStore('admin-user', { @@ -31,6 +36,17 @@ avatar: '', nickname: '', deptId: 0 + }, + // 鍖荤敓璇婂閫夋嫨 + isSetRoom: false, + room: { + id: 0, + roomId: 0, + roomName: "", + bedNo: "", + status: null, + docId: null, + docName: null } }), getters: { @@ -45,6 +61,13 @@ }, getUser(): UserVO { return this.user + }, + // 鍖荤敓璇婂閫夋嫨 + getIsSetRoom(): boolean { + return this.isSetRoom + }, + getRoom(): RoomVO | null { + return this.room } }, actions: { @@ -64,6 +87,35 @@ wsCache.set(CACHE_KEY.USER, userInfo) wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) }, + // 鍖荤敓鍏ュ骇 + async setRoomInfoAction(room: RoomVO) { + // 鏇存柊 store + this.room = room + this.isSetRoom = true + + // 鏇存柊 cache + const userInfo2 = wsCache.get(CACHE_KEY.USER) + if (userInfo2) { + userInfo2.room = room + userInfo2.isSetRoom = true + 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) // NOTE: 鏄惁闇�瑕佸儚`setUserInfoAction`涓�鏍峰垽鏂璥userInfo != null` @@ -94,6 +146,17 @@ nickname: '', deptId: 0 } + // 鍖荤敓璇婂閫夋嫨 + this.isSetRoom = false + this.room = { + id: 0, + roomId: 0, + roomName: "", + bedNo: "", + status: null, + docId: null, + docName: null + } } } }) -- Gitblit v1.9.3