From cac16fa86f78fcb8813c0832b24d5cc0fec4126c Mon Sep 17 00:00:00 2001 From: qiutianhong Date: Thu, 31 Oct 2024 21:46:23 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E5=AE=8C=E6=88=90=E7=BE=A4?= =?UTF-8?q?=E7=BB=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components.d.ts | 2 + frontend/src/components/chat/Chat.vue | 38 ++-- frontend/src/components/chat/ChatMsgList.vue | 2 +- .../src/components/chat/ChatUserSetting.vue | 66 +++---- frontend/src/stores/chat.ts | 183 +++++++++++++----- frontend/src/stores/db.ts | 10 +- 6 files changed, 191 insertions(+), 110 deletions(-) diff --git a/frontend/components.d.ts b/frontend/components.d.ts index 522afce..3d33306 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -57,6 +57,8 @@ declare module 'vue' { ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCol: typeof import('element-plus/es')['ElCol'] + ElCollapse: typeof import('element-plus/es')['ElCollapse'] + ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElColorPicker: typeof import('element-plus/es')['ElColorPicker'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDialog: typeof import('element-plus/es')['ElDialog'] diff --git a/frontend/src/components/chat/Chat.vue b/frontend/src/components/chat/Chat.vue index 2a6ead3..1492dd7 100644 --- a/frontend/src/components/chat/Chat.vue +++ b/frontend/src/components/chat/Chat.vue @@ -7,37 +7,24 @@ onMounted(() => { store.initChat(); }); - - const userList = ref([ - { - id: 2, - nickname: "朋友2", - avatar: "/logo.png", - previewTimeFormat: "昨天", - previewType: 1, - previewMessage: "测试消息", - }, - { - id: 3, - nickname: "朋友3", - avatar: "/logo.png", - previewTimeFormat: "昨天", - previewType: 1, - previewMessage: "测试消息", - }, - ]); // 将用户列表转换为 el-transfer 组件所需的数据格式 const generateData = () => { - return userList.value.map((user) => ({ + return store.allUserList.map((user) => ({ key: user.id, label: user.nickname, avatar: user.avatar, // 添加头像数据 })); }; - + const data = ref(generateData()); const users = ref([]); + + watchEffect(() => { + if (store.allUserList.length > 0) { + data.value = generateData(); + } + });