| | |
| | | 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)); |