From 68c042ad47b10cdc859823d592147f5cdb447659 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Thu, 3 Jul 2025 15:02:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=80=E5=90=AF=E5=85=8D=E6=89=93?= =?UTF-8?q?=E6=89=B0=E6=97=B6=E5=B7=B2=E8=AF=BB=E7=8A=B6=E6=80=81=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/components/chat-item/chat-item.vue | 8 +++-- im-uniapp/pages/chat/chat-box.vue | 26 ++++++++-------- im-uniapp/pages/chat/chat.vue | 2 +- im-uniapp/store/chatStore.js | 6 +--- im-web/src/components/chat/ChatBox.vue | 31 +++++++++----------- im-web/src/components/chat/ChatItem.vue | 2 +- im-web/src/store/chatStore.js | 6 +--- im-web/src/view/Home.vue | 8 ++--- 8 files changed, 37 insertions(+), 52 deletions(-) diff --git a/im-uniapp/components/chat-item/chat-item.vue b/im-uniapp/components/chat-item/chat-item.vue index d7c8f7f..f8002ce 100644 --- a/im-uniapp/components/chat-item/chat-item.vue +++ b/im-uniapp/components/chat-item/chat-item.vue @@ -17,8 +17,8 @@ {{ chat.sendNickName + ': ' }} - + @@ -170,9 +170,11 @@ export default { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - } - + + .icon { + font-size: $im-font-size; + } } } } diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index af94be6..d2bd260 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -669,21 +669,19 @@ export default { }); }, readedMessage() { - if (this.unreadCount == 0) { - return; - } - let url = "" - if (this.chat.type == "GROUP") { - url = `/message/group/readed?groupId=${this.chat.targetId}` - } else { - url = `/message/private/readed?friendId=${this.chat.targetId}` + if (this.unreadCount > 0) { + let url = "" + if (this.chat.type == "GROUP") { + url = `/message/group/readed?groupId=${this.chat.targetId}` + } else { + url = `/message/private/readed?friendId=${this.chat.targetId}` + } + this.$http({ + url: url, + method: 'PUT' + }).then(() => {}) } - this.$http({ - url: url, - method: 'PUT' - }).then(() => { - this.chatStore.resetUnreadCount(this.chat) - }) + this.chatStore.resetUnreadCount(this.chat) }, loadGroup(groupId) { this.$http({ diff --git a/im-uniapp/pages/chat/chat.vue b/im-uniapp/pages/chat/chat.vue index c5bc1d3..4bc52ad 100644 --- a/im-uniapp/pages/chat/chat.vue +++ b/im-uniapp/pages/chat/chat.vue @@ -104,7 +104,7 @@ export default { unreadCount() { let count = 0; this.chatStore.chats.forEach(chat => { - if (!chat.delete) { + if (!chat.isDnd && !chat.delete) { count += chat.unreadCount; } }) diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index efbb562..1e40da4 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -195,7 +195,7 @@ export default defineStore('chatStore', { chat.lastSendTime = msgInfo.sendTime; chat.sendNickName = msgInfo.sendNickName; // 未读加1 - if (!chat.isDnd && !msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED && + if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED && msgInfo.status != MESSAGE_STATUS.RECALL && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) { chat.unreadCount++; } @@ -354,7 +354,6 @@ export default defineStore('chatStore', { let chat = this.findChat(chatInfo); if (chat) { chat.isDnd = isDnd; - chat.unreadCount = 0; } }, refreshChats() { @@ -374,9 +373,6 @@ export default defineStore('chatStore', { chat.isDnd = group.isDnd } } - if (chat.isDnd) { - chat.unreadCount = 0; - } }) // 排序 cacheChats.sort((chat1, chat2) => chat2.lastSendTime - chat1.lastSendTime); diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index b79d67b..67a5f8c 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -11,10 +11,9 @@
- +
@@ -505,19 +504,18 @@ export default { }); }, readedMessage() { - if (this.chat.unreadCount == 0) { - return; - } - this.chatStore.resetUnreadCount(this.chat) - if (this.chat.type == "GROUP") { - var url = `/message/group/readed?groupId=${this.chat.targetId}` - } else { - url = `/message/private/readed?friendId=${this.chat.targetId}` + if (this.chat.unreadCount > 0) { + if (this.isGroup) { + var url = `/message/group/readed?groupId=${this.chat.targetId}` + } else { + url = `/message/private/readed?friendId=${this.chat.targetId}` + } + this.$http({ + url: url, + method: 'put' + }).then(() => { }) + this.chatStore.resetUnreadCount(this.chat) } - this.$http({ - url: url, - method: 'put' - }).then(() => { }) }, loadReaded(fId) { this.$http({ @@ -682,7 +680,6 @@ export default { return this.chat.unreadCount; }, showMessages() { - console.log("this.chat.messages.slice(this.showMinIdx):",this.chat.messages.slice(this.showMinIdx)) return this.chat.messages.slice(this.showMinIdx) }, messageSize() { diff --git a/im-web/src/components/chat/ChatItem.vue b/im-web/src/components/chat/ChatItem.vue index 8ad7a5b..07ee6b2 100644 --- a/im-web/src/components/chat/ChatItem.vue +++ b/im-web/src/components/chat/ChatItem.vue @@ -3,7 +3,7 @@
-
{{ chat.unreadCount }}
+
{{ chat.unreadCount }}
diff --git a/im-web/src/store/chatStore.js b/im-web/src/store/chatStore.js index 3922ee4..cda390f 100644 --- a/im-web/src/store/chatStore.js +++ b/im-web/src/store/chatStore.js @@ -196,7 +196,7 @@ export default defineStore('chatStore', { chat.lastSendTime = msgInfo.sendTime; chat.sendNickName = msgInfo.sendNickName; // 未读加1 - if (!chat.isDnd && !msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED && + if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED && msgInfo.status != MESSAGE_STATUS.RECALL && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) { chat.unreadCount++; } @@ -350,7 +350,6 @@ export default defineStore('chatStore', { let chat = this.findChat(chatInfo); if (chat) { chat.isDnd = isDnd; - chat.unreadCount = 0; } }, refreshChats() { @@ -370,9 +369,6 @@ export default defineStore('chatStore', { chat.isDnd = group.isDnd } } - if (chat.isDnd) { - chat.unreadCount = 0; - } }) // 排序 cacheChats.sort((chat1, chat2) => chat2.lastSendTime - chat1.lastSendTime); diff --git a/im-web/src/view/Home.vue b/im-web/src/view/Home.vue index 9c5ac77..67b7d5d 100644 --- a/im-web/src/view/Home.vue +++ b/im-web/src/view/Home.vue @@ -392,10 +392,6 @@ export default { location.href = "/"; }, playAudioTip() { - // 离线消息不播放铃声 - if (this.chatStore.isLoading()) { - return; - } // 防止过于密集播放 if (new Date().getTime() - this.lastPlayAudioTime > 1000) { this.lastPlayAudioTime = new Date().getTime(); @@ -439,8 +435,8 @@ export default { unreadCount() { let unreadCount = 0; let chats = this.chatStore.chats; - chats.forEach((chat) => { - if (!chat.delete) { + chats.forEach(chat => { + if (!chat.delete && !chat.isDnd) { unreadCount += chat.unreadCount } });