From 96d13ee431fef2fb5eaba05654cd7e0216ce36ab Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期五, 28 六月 2024 16:53:26 +0800 Subject: [PATCH] 新建聊天室 --- src/stores/chatRoom.ts | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts index 1036447..13421b5 100644 --- a/src/stores/chatRoom.ts +++ b/src/stores/chatRoom.ts @@ -1,13 +1,18 @@ -import { computed } from 'vue'; +import { computed, ref, watch } from 'vue'; import type { ChatRoomItem } from '../layout/component/sidebar/waterLeftAside/types'; import { Local } from '../utils/storage'; -export const chatRoomList = computed<ChatRoomItem[]>({ - get: () => { - return Local.get('chatRoomList') ?? []; +export const chatRoomList = ref<ChatRoomItem[]>(Local.get('chatRoomList')); + +watch( + () => chatRoomList.value, + (val) => { + Local.set('chatRoomList', val); }, - set: (value) => { - console.log("馃殌 ~ value:", value) - Local.set('chatRoomList', value); - }, -}); + { + deep: true, + } +); + +export const activeRoomId = ref(null); +export const activeChatRoom = computed(() => chatRoomList.value?.find((item) => item.id === activeRoomId.value)); -- Gitblit v1.9.3