From 40ac808f5653e94f5f670d10055a136014cd2f4b Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Wed, 6 Aug 2025 19:41:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E8=BF=9E=E5=90=8E=E5=B7=B2?= =?UTF-8?q?=E8=AF=BB=E7=8A=B6=E6=80=81=E5=BC=82=E5=B8=B8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/pages/chat/chat-box.vue | 39 ++++++++++++++++++-------- im-web/src/components/chat/ChatBox.vue | 11 ++++++++ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index 0845cdc..52fa4a2 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -257,12 +257,12 @@ export default { this.atUserIds = atUserIds; }, onLongPressHead(msgInfo) { - if (!msgInfo.selfSend && this.chat.type == "GROUP" && this.atUserIds.indexOf(msgInfo.sendId) < 0) { + if (!msgInfo.selfSend && this.isGroup && this.atUserIds.indexOf(msgInfo.sendId) < 0) { this.atUserIds.push(msgInfo.sendId); } }, headImage(msgInfo) { - if (this.chat.type == 'GROUP') { + if (this.isGroup) { let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); return member ? member.headImage : ""; } else { @@ -270,7 +270,7 @@ export default { } }, showName(msgInfo) { - if (this.chat.type == 'GROUP') { + if (this.isGroup) { let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); return member ? member.showNickName : ""; } else { @@ -357,7 +357,7 @@ export default { return atText; }, fillTargetId(msgInfo, targetId) { - if (this.chat.type == "GROUP") { + if (this.isGroup) { msgInfo.groupId = targetId; } else { msgInfo.recvId = targetId; @@ -675,7 +675,7 @@ export default { }, 50) }, onShowMore() { - if (this.chat.type == "GROUP") { + if (this.isGroup) { uni.navigateTo({ url: "/pages/group/group-info?id=" + this.group.id }) @@ -728,7 +728,7 @@ export default { readedMessage() { if (this.unreadCount > 0) { let url = "" - if (this.chat.type == "GROUP") { + if (this.isGroup) { url = `/message/group/readed?groupId=${this.chat.targetId}` } else { url = `/message/private/readed?friendId=${this.chat.targetId}` @@ -919,7 +919,7 @@ export default { sendTime: new Date().getTime(), type: this.$enums.MESSAGE_TYPE.TIP_TEXT } - if (this.chat.type == "PRIVATE") { + if (this.isPrivate) { msgInfo.recvId = this.mine.id msgInfo.content = "该用户已被管理员封禁,原因:" + this.userInfo.reason } else { @@ -969,7 +969,7 @@ export default { return ""; } let title = this.chat.showName; - if (this.chat.type == "GROUP") { + if (this.isGroup) { let size = this.groupMembers.filter(m => !m.quit).length; title += `(${size})`; } @@ -991,8 +991,8 @@ export default { return this.chat.unreadCount; }, isBanned() { - return (this.chat.type == "PRIVATE" && this.userInfo.isBanned) || - (this.chat.type == "GROUP" && this.group.isBanned) + return (this.isPrivate && this.userInfo.isBanned) || + (this.isGroup && this.group.isBanned) }, atUserItems() { let atUsers = []; @@ -1013,6 +1013,15 @@ export default { }, memberSize() { return this.groupMembers.filter(m => !m.quit).length; + }, + isGroup() { + return this.chat.type == 'GROUP'; + }, + isPrivate() { + return this.chat.type == 'PRIVATE'; + }, + loading() { + return this.chatStore.loading; } }, watch: { @@ -1038,6 +1047,14 @@ export default { this.readedMessage() } } + }, + loading: { + handler(newLoading, oldLoading) { + // 断线重连后,需要更新一下已读状态 + if (!newLoading && this.isPrivate) { + this.loadReaded(this.chat.targetId) + } + } } }, onLoad(options) { @@ -1049,7 +1066,7 @@ export default { // 消息已读 this.readedMessage() // 加载好友或群聊信息 - if (this.chat.type == "GROUP") { + if (this.isGroup) { this.loadGroup(this.chat.targetId); } else { this.loadFriend(this.chat.targetId); diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index 62e5490..5b1d090 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -784,6 +784,9 @@ export default { }, isPrivate() { return this.chat.type == 'PRIVATE'; + }, + loading() { + return this.chatStore.loading; } }, watch: { @@ -833,6 +836,14 @@ export default { } } } + }, + loading: { + handler(newLoading, oldLoading) { + // 断线重连后,需要更新一下已读状态 + if (!newLoading && this.isPrivate) { + this.loadReaded(this.chat.targetId) + } + } } }, mounted() {