From 00489b5c27c4bcf8ee61fce7cdf5ce1c9c9df641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=A1=E5=A4=8D=E4=B9=A0?= <2353956224@qq.com> Date: Thu, 26 Feb 2026 17:01:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E7=82=B9=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/pk-mini/Message.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/views/pk-mini/Message.vue b/src/views/pk-mini/Message.vue index 669a8e4..8adcf58 100644 --- a/src/views/pk-mini/Message.vue +++ b/src/views/pk-mini/Message.vue @@ -190,6 +190,13 @@ async function sendMessage() { inputText.value = '' await nextTick() scrollToBottom() + // 发送消息后标记已读,清除该会话红点 + const conv = chatList.value.find(c => c.userId === selectedChat.value.userId) + if (conv && conv.unread > 0) { + goEasyMessageRead({ id: String(selectedChat.value.userId) }).catch(() => {}) + unreadStore.decrease(conv.unread) + conv.unread = 0 + } } catch (e) { console.error('发送消息失败', e) if(e =='Error: id can not be the same as your id'){ @@ -289,17 +296,16 @@ function onConversationsUpdated(conversations) { function onMessageReceived(message) { if (!isGoEasyEnabled()) return - // 更新会话列表中的未读数 + // 始终累加会话未读数和更新最后一条消息(全局 unreadStore 由 PkAppaside 统一维护) const conv = chatList.value.find(c => c.userId === message.senderId) if (conv) { conv.unread = (conv.unread || 0) + 1 conv.lastMessage = message } - // 如果当前正在查看该会话,添加消息到列表 + // 如果当前正在查看该会话,追加消息到列表 if (selectedChat.value && selectedChat.value.userId === message.senderId) { messagesList.value.push(message) nextTick(() => scrollToBottom()) - goEasyMessageRead({ id: message.senderId }).catch(() => {}) } }