From e4c6fd5f9fd23d193f98d8e58a3250e2129e98f8 Mon Sep 17 00:00:00 2001 From: Seven <1530011482@qq.com> Date: Wed, 30 Sep 2026 15:50:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E6=98=BE=E7=A4=BAbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/ChatPage.vue | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/pages/index/ChatPage.vue b/src/pages/index/ChatPage.vue index aa80253..ccd7a99 100644 --- a/src/pages/index/ChatPage.vue +++ b/src/pages/index/ChatPage.vue @@ -306,9 +306,6 @@ export default { changeMenu(menu) { this.activeMenu = menu; this.currentContact = null; - if (menu === "contacts") { - this.getContactList(); - } }, // 退出登录 @@ -326,6 +323,7 @@ export default { .then((response) => { this.currentUser = response.data; this.getRecentMessageList(); + this.getContactList(); }) .catch((error) => { console.error(error); @@ -492,9 +490,11 @@ export default { contactName: contactName, content: newMessage.content, createdAt: newMessage.createdAt, - unreadCount: 1, + unreadCount: 1 }); } + + this.$nextTick(); }, // 监听websocket连接成功事件 @@ -535,22 +535,21 @@ export default { from: "other", time: message.createdAt, }); + this.$nextTick(() => { + this.scrollToBottom(); + }); } else { // 不是当前联系人,不加入 contactMessages // 如果是当前联系人列表中的成员,更新最近聊天列表、未读数量 const contactIndex = this.contactList.findIndex( (item) => item.contactName === senderName ); + console.log("contactIndex="+contactIndex) if (contactIndex === -1) return; this.updateRecentChat("receive", senderName, message); } - - this.$nextTick(() => { - this.scrollToBottom(); - }); - - // 发送新消息成功之后,需要把新消息显示到聊天框中(由于要拿数据库里的写入时间,所以要等websocket返回成功再刷新) + // 发送新消息成功之后,需要把新消息显示到聊天框中(由于要拿数据库里的写入时间,所以要等websocket返回成功再刷新) } else if (data.type == "sendSuccess") { const message = data.message; this.contactMessages.push({