From 35ca2189d01289a93c3f01002d1d32011417d66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=94=BF=E6=9D=83?= <1978141412@qq.com> Date: Sat, 12 Oct 2024 19:26:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../user-message/user-message.tsx | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d387b9f71..cf0c7fca2 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 f4c435bdf..f9f9fb031 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(); }, ); -- Gitee