From 8307ea24026502a638accc90a9bb9c72ef7fe4f2 Mon Sep 17 00:00:00 2001 From: wangxulei <727869402@qq.com> Date: Sun, 12 Jan 2025 18:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96im?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/layout/components/Navbar.vue | 4 ++-- web/src/views/common/Im.vue | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/web/src/layout/components/Navbar.vue b/web/src/layout/components/Navbar.vue index b4e05cd..408baa6 100644 --- a/web/src/layout/components/Navbar.vue +++ b/web/src/layout/components/Navbar.vue @@ -95,10 +95,10 @@ export default { IMUI.appendMessage(data.body); IMUI.messageViewToBottom() const contactId = this.$refs.im.contact.id - if(isNotEmpty(contactId)&&contactId==data.body.toContactId){ + if(isNotEmpty(contactId)&&contactId==data.body.toContactId&&this.$refs.im.dialogVisible){ console.log('当前在该用户聊天框 设置为已读') + this.$refs.im.readAuthorMessage(contactId) } - this.$refs.im.readAuthorMessage(contactId) }catch (e) { } //请求总数 diff --git a/web/src/views/common/Im.vue b/web/src/views/common/Im.vue index 23e20d8..bf9d69c 100644 --- a/web/src/views/common/Im.vue +++ b/web/src/views/common/Im.vue @@ -56,8 +56,16 @@ open() { this.dialogVisible = true this.getAuthorList() - const {IMUI} = this.$refs; - IMUI.messageViewToBottom() + if(isNotEmpty(this.contact.id)){ + this.$refs.IMUI.updateContact({ + id: this.contact.id, + unread: 0, + }); + this.readAuthorMessage(this.contact.id) + const {IMUI} = this.$refs; + IMUI.messageViewToBottom() + this.getUnReadCount() + } }, getUnReadCount(){ webSocketManager.sendMessage(JSON.stringify({handlerType:'8',authorId:'8'}))