|
|
@@ -831,13 +831,12 @@ export default {
|
|
|
content = '[视频]';
|
|
|
}
|
|
|
|
|
|
- // 对于自己发送的消息,isPeerRead 需要特殊处理
|
|
|
- // 不能直接使用 timMsg.isPeerRead,因为 setMessageRead() 会影响这个值
|
|
|
- // 只有真正收到 MESSAGE_READ_BY_PEER 事件时才应该标记为已读
|
|
|
+ // 对于自己发送的消息,使用 TIM SDK 的 isPeerRead 值
|
|
|
+ // TIM SDK 会根据 peerReadTime 自动更新这个字段
|
|
|
let isPeerRead = false;
|
|
|
if (timMsg.from === this.userId) {
|
|
|
- // 自己发送的消息,默认未读,只有收到已读回执事件时才更新
|
|
|
- isPeerRead = false;
|
|
|
+ // 自己发送的消息,使用 TIM SDK 的 isPeerRead 值
|
|
|
+ isPeerRead = timMsg.isPeerRead || false;
|
|
|
} else {
|
|
|
// 对方发送的消息,不需要 isPeerRead 字段
|
|
|
isPeerRead = false;
|
|
|
@@ -2255,6 +2254,12 @@ export default {
|
|
|
timManager.tim.off(TIM.EVENT.MESSAGE_READ_BY_PEER, this.handleMessageReadByPeer);
|
|
|
console.log('✅ 已清理已读回执监听');
|
|
|
}
|
|
|
+
|
|
|
+ // 清理新消息监听
|
|
|
+ if (this.handleNewMessage) {
|
|
|
+ timManager.offMessage(this.handleNewMessage);
|
|
|
+ console.log('✅ 已清理新消息监听');
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|