From fb10e2eb90825eb27efdb79c8c2a56c88660c921 Mon Sep 17 00:00:00 2001 From: DCloud_JSON Date: Thu, 20 Jun 2024 11:57:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=BE=E7=BD=AE=E8=87=AA=E5=B7=B1=E7=9A=84?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E4=B8=BA=E5=B7=B2=E8=AF=BB/=E6=9C=AA?= =?UTF-8?q?=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-im-conversation-list.vue | 11 +++++++---- .../conversation/Conversation.class.js | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/components/uni-im-conversation-list/uni-im-conversation-list.vue b/components/uni-im-conversation-list/uni-im-conversation-list.vue index 8249bb3..6088b94 100644 --- a/components/uni-im-conversation-list/uni-im-conversation-list.vue +++ b/components/uni-im-conversation-list/uni-im-conversation-list.vue @@ -170,7 +170,7 @@ export default { "left": clientX } let menuList = [{ - "title": "置顶", + "title": conversation.pinned ? "取消置顶" : "置顶", "action": () => { conversation.pinned = !conversation.pinned db.collection('uni-im-conversation') @@ -190,6 +190,12 @@ export default { }) } }, + { + "title": "标为" + (conversation.unread_count ? "已读" : "未读"), + "action": () => { + conversation.setUnreadCount(conversation.unread_count ? 0 : 1) + } + }, { "title": conversation.mute ? "允许消息通知" : "消息免打扰", "action": () => { @@ -211,9 +217,6 @@ export default { "action": () => conversation.hide() } ] - if (conversation.pinned) { - menuList[0].title = "取消置顶" - } myContextmenu.show(position, menuList) myContextmenu.onClose(() => { conversation.focus = false diff --git a/sdk/methods/conversation/Conversation.class.js b/sdk/methods/conversation/Conversation.class.js index 7496027..189266d 100644 --- a/sdk/methods/conversation/Conversation.class.js +++ b/sdk/methods/conversation/Conversation.class.js @@ -389,6 +389,25 @@ class Conversation { console.log('updated hidden', res) return res } + // 设置未读消息数 + async setUnreadCount(count) { + // console.log('setUnreadCount', count); + const oldCount = this.unread_count + this.unread_count = count + let res = await db.collection('uni-im-conversation') + .doc(this._id) + .update({ + "unread_count": count + }) + .catch(err => { + console.error('setUnreadCount err', err); + this.unread_count = oldCount + }) + .then(e => { + // console.log('setUnreadCount updated', e.result.updated); + }) + return res + } } export default Conversation -- GitLab