diff --git a/uni_modules/uni-im-msg-reader/changelog.md b/uni_modules/uni-im-msg-reader/changelog.md index 39f653582fbdf649d211e6767001e8d8d7737b86..9d15e814d64caa7a914e3d40cbeb065c38915331 100644 --- a/uni_modules/uni-im-msg-reader/changelog.md +++ b/uni_modules/uni-im-msg-reader/changelog.md @@ -1,2 +1,6 @@ ## 1.0.0(2024-05-06) 第一版 +## 1.0.1(2024-06-21) +更新:在移动端点击未读详情时,以独立页面展示 +## 1.0.2(2024-11-06) +更新:兼容 uni-im 3.4.x \ No newline at end of file diff --git a/uni_modules/uni-im-msg-reader/components/uni-im-msg-reader/uni-im-msg-reader.vue b/uni_modules/uni-im-msg-reader/components/uni-im-msg-reader/uni-im-msg-reader.vue index a3437ec683bdbae31dd408fc9870c744c8f43d11..d3397ffa5d64fccb1693d7de961bfd00919d0ce5 100644 --- a/uni_modules/uni-im-msg-reader/components/uni-im-msg-reader/uni-im-msg-reader.vue +++ b/uni_modules/uni-im-msg-reader/components/uni-im-msg-reader/uni-im-msg-reader.vue @@ -1,84 +1,90 @@ - \ No newline at end of file diff --git a/uni_modules/uni-im-msg-reader/extension.js b/uni_modules/uni-im-msg-reader/extension.js index 05bc76dae0664ef7f64d867ddd0e4bf69a38abcc..d201681ce8563057913b5ecdbb51844df8eee40f 100644 --- a/uni_modules/uni-im-msg-reader/extension.js +++ b/uni_modules/uni-im-msg-reader/extension.js @@ -1,6 +1,27 @@ import uniIm from '@/uni_modules/uni-im/sdk/index.js' - +import UniImMsgReader from '@/uni_modules/uni-im-msg-reader/components/uni-im-msg-reader/uni-im-msg-reader.vue' function install() { + + // 配置在什么情况下启用已读功能 + uniIm.extensions.installExt('msg-extra', (msg, currentUser) => { + // 仅限“我”发送的消息 + if (msg.from_uid !== uniIm.currentUser._id) return + // 仅限内部用户 + if (!uniIm.currentUser.role.includes('staff')) return + // 排除特殊消息 + if (msg.type == 'system' || msg.is_revoke) return + // 仅限私聊会话 + let conversation = uniIm.conversation.find(msg.conversation_id) + if (!conversation?.friend_uid) return + return { + component: UniImMsgReader, + props: { + msg + } + } + }) + + // 注册 read_msg 消息类型 uniIm.extensions.installExt('msg-type-register', () => { return { @@ -18,38 +39,39 @@ function install() { from_uid, create_time, } = msgData - const msg = conversation.msgList.find(msg => msg._id === msgId) + // debugger + const msg = conversation.msg.find(msgId) if (msg) { let reader = { user_id: from_uid, create_time } msg.reader_list ? msg.reader_list.push(reader) : msg.reader_list = [reader] - conversation.msgManager.localMsg.update(msg.unique_id, msg) } }, } }) // 监听每条消息的显示状态,报送 read_msg 消息 - uniIm.extensions.installExt('msg-appear', (msg, currentUser) => { + uniIm.extensions.installExt('msg-appear', msg => { + const currentUid = uniIm.currentUser._id // 特殊消息不用处理 if (msg.type === 'system' || msg.is_revoke) return // 如果是我发送的消息则不处理 - if (msg.from_uid == currentUser.user_id) return + if (msg.from_uid == currentUid) return // 如果我已经在已读列表里则不再处理 - if (msg.reader_list?.some(u => u.user_id == currentUser.user_id)) return + if (msg.reader_list?.some(u => u.user_id == currentUid)) return // 如果是群聊消息且没有 @我,则不用处理 - let conversation = uniIm.conversation.getCached(msg.conversation_id) - if (conversation.group_id && !msg.call_uid?.includes(currentUser.user_id)) return + let conversation = uniIm.conversation.find(msg.conversation_id) + if (conversation.group_id && !msg.call_uid?.includes(currentUid)) return // 把自己记入已读列表 msg.reader_list = msg.reader_list || [] msg.reader_list.push({ - user_id: currentUser.user_id, + user_id: currentUid, create_time: Date.now() }) @@ -64,7 +86,7 @@ function install() { } }).catch(e => { // 提交失败,把自己从已读列表里去掉 - msg.reader_list = msg.reader_list.filter(u => u.user_id !== currentUser.user_id) + msg.reader_list = msg.reader_list.filter(u => u.user_id !== currentUid) }) }) } diff --git a/uni_modules/uni-im-msg-reader/package.json b/uni_modules/uni-im-msg-reader/package.json index 10219f968d83c8a327df56d3f818472dd6acb611..3b9ad037b3f4aa9fc2664b88700945dd5bf4126d 100644 --- a/uni_modules/uni-im-msg-reader/package.json +++ b/uni_modules/uni-im-msg-reader/package.json @@ -1,14 +1,14 @@ { "id": "uni-im-msg-reader", "displayName": "uni-im-msg-reader", - "version": "1.0.0", + "version": "1.0.2", "description": "uni-im的消息已读未读状态展示插件", "keywords": [ "uni-im-msg-reader" ], "repository": "", "engines": { - "HBuilderX": "^4.14" + "HBuilderX": "^4.29" }, "dcloudext": { "type": "component-vue", @@ -25,7 +25,7 @@ }, "declaration": { "ads": "无", - "data": "插件不采集任何数据", + "data": "无", "permissions": "无" }, "npmurl": "" @@ -46,17 +46,17 @@ }, "App": { "app-vue": "y", - "app-nvue": "y", + "app-nvue": "n", "app-uvue": "n" }, "H5-mobile": { - "Safari": "n", - "Android Browser": "n", - "微信浏览器(Android)": "n", - "QQ浏览器(Android)": "n" + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" }, "H5-pc": { - "Chrome": "n", + "Chrome": "y", "IE": "n", "Edge": "n", "Firefox": "n", diff --git a/uni_modules/uni-im-msg-reader/pages/reader-list/reader-list.vue b/uni_modules/uni-im-msg-reader/pages/reader-list/reader-list.vue new file mode 100644 index 0000000000000000000000000000000000000000..866c1890d84986ddf4be484dd2867a912a5b07e6 --- /dev/null +++ b/uni_modules/uni-im-msg-reader/pages/reader-list/reader-list.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/uni_modules/uni-im-msg-reader/uniCloud/cloudfunctions/common/uni-im-ext-msg-reader/package.json b/uni_modules/uni-im-msg-reader/uniCloud/cloudfunctions/common/uni-im-ext-msg-reader/package.json index 8fb18f516c221fab635e98fa397b6aac29ac5d24..74a9ba163b3f217a7315a998a8921c41de389b5b 100644 --- a/uni_modules/uni-im-msg-reader/uniCloud/cloudfunctions/common/uni-im-ext-msg-reader/package.json +++ b/uni_modules/uni-im-msg-reader/uniCloud/cloudfunctions/common/uni-im-ext-msg-reader/package.json @@ -1,6 +1,6 @@ { "name": "uni-im-ext-msg-reader", - "version": "1.0.0", + "version": "1.0.2", "description": "", "main": "index.js", "keywords": [],