eight
2024-08-28 75bdffbfab151c40a79d70f1e7e6844c4c39c605
src/store/modules/user.ts
@@ -23,7 +23,7 @@
  // 医生诊室选择
  isSetRoom: boolean
  room: RoomVO
  room: RoomVO | null
}
export const useUserStore = defineStore('admin-user', {
@@ -85,13 +85,8 @@
      wsCache.set(CACHE_KEY.USER, userInfo)
      wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
    },
    // 医生诊室选择
    // 医生入座
    async setRoomInfoAction(room: RoomVO) {
      if (!getAccessToken()) {
        this.resetState()
        return null
      }
      // 更新 store
      this.room = room
      this.isSetRoom = true
@@ -104,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)