红点问题修复

This commit is contained in:
2026-02-26 17:01:00 +08:00
parent a0b476da7a
commit 00489b5c27

View File

@@ -190,6 +190,13 @@ async function sendMessage() {
inputText.value = '' inputText.value = ''
await nextTick() await nextTick()
scrollToBottom() 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) { } catch (e) {
console.error('发送消息失败', e) console.error('发送消息失败', e)
if(e =='Error: id can not be the same as your id'){ if(e =='Error: id can not be the same as your id'){
@@ -289,17 +296,16 @@ function onConversationsUpdated(conversations) {
function onMessageReceived(message) { function onMessageReceived(message) {
if (!isGoEasyEnabled()) return if (!isGoEasyEnabled()) return
// 更新会话列表中的未读数 // 始终累加会话未读数和更新最后一条消息(全局 unreadStore 由 PkAppaside 统一维护)
const conv = chatList.value.find(c => c.userId === message.senderId) const conv = chatList.value.find(c => c.userId === message.senderId)
if (conv) { if (conv) {
conv.unread = (conv.unread || 0) + 1 conv.unread = (conv.unread || 0) + 1
conv.lastMessage = message conv.lastMessage = message
} }
// 如果当前正在查看该会话,加消息到列表 // 如果当前正在查看该会话,加消息到列表
if (selectedChat.value && selectedChat.value.userId === message.senderId) { if (selectedChat.value && selectedChat.value.userId === message.senderId) {
messagesList.value.push(message) messagesList.value.push(message)
nextTick(() => scrollToBottom()) nextTick(() => scrollToBottom())
goEasyMessageRead({ id: message.senderId }).catch(() => {})
} }
} }