From f4f79e5495204d2de5ef331d939847282c6a2227 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Fri, 9 May 2025 13:59:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(dict):=20:bug:=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=BB=84=E4=BB=B6=E7=9A=84=20WebSocket=20?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E5=99=A8=EF=BC=8C=E4=BB=A5=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=9C=A8=E6=B3=A8=E9=94=80=E7=99=BB=E5=BD=95=E6=9C=9F=E9=97=B4?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=97=A0=E6=95=88=E4=BB=A4=E7=89=8C=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Dict/DictLabel.vue | 10 +++------- src/components/Dict/index.vue | 9 --------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/components/Dict/DictLabel.vue b/src/components/Dict/DictLabel.vue index 1ef82bea..c6603470 100644 --- a/src/components/Dict/DictLabel.vue +++ b/src/components/Dict/DictLabel.vue @@ -53,18 +53,14 @@ const updateLabelAndTag = async () => { tagType.value = newTagType as typeof tagType.value; }; -watch([() => props.code, () => props.modelValue], updateLabelAndTag); - -onMounted(updateLabelAndTag); - -// 监听WebSocket字典更新事件,强制刷新标签 +// 初始化或code变化时更新标签和标签样式 watch( - () => dictStore.getDictItems(props.code || ""), + [() => props.code, () => props.modelValue], async () => { if (props.code) { await updateLabelAndTag(); } }, - { deep: true } + { immediate: true } ); diff --git a/src/components/Dict/index.vue b/src/components/Dict/index.vue index ee5f1136..79d98e4d 100644 --- a/src/components/Dict/index.vue +++ b/src/components/Dict/index.vue @@ -120,13 +120,4 @@ onMounted(async () => { await dictStore.loadDictItems(props.code); options.value = dictStore.getDictItems(props.code); }); - -// 监听字典数据变化,确保WebSocket更新时刷新选项 -watch( - () => dictStore.getDictItems(props.code), - (newItems) => { - options.value = newItems; - }, - { deep: true } -);