diff --git a/CHANGELOG.md b/CHANGELOG.md index d387b9f71e9922cde02062af562225d996952175..cf0c7fca2ef7186068532bfa6b6e50e28175bffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - 多数据部件最后分割线不显示 - 新增用户消息面板组件 - 富文本样式调整 +- 用户消息实时同步 ## [0.0.25] - 2024-10-10 diff --git a/src/panel-component/user-message/user-message.tsx b/src/panel-component/user-message/user-message.tsx index f4c435bdf9587e586d81a986106ae1aef015399f..f9f9fb031f77bb3a9fa704498bd8931598e2b017 100644 --- a/src/panel-component/user-message/user-message.tsx +++ b/src/panel-component/user-message/user-message.tsx @@ -43,22 +43,28 @@ export const MobUserMessage = defineComponent({ // 是否显示消息列表 const isActive = ref(true); const hasNotice = ref(false); + + const refresh = () => { + if (isActive.value && hasNotice.value) { + c.load(); + c.refreshUnreadCount(); + hasNotice.value = false; + } + }; + ibiz.mc.command.internalMessage.on(async (msg: IPortalMessage) => { ibiz.log.debug('mqtt internalMessage: ', msg); if (msg.subtype === 'INTERNALMESSAGE') { hasNotice.value = true; + refresh(); } }); // 激活且存在变更时重新加载 watch( () => isActive.value, - newVal => { - if (newVal && hasNotice.value) { - c.load(); - c.refreshUnreadCount(); - hasNotice.value = false; - } + () => { + refresh(); }, );