From e5b492247ca23ad3a5ad60bdbff22616172f0955 Mon Sep 17 00:00:00 2001 From: SikongJueluo <1822250894@qq.com> Date: Thu, 21 Aug 2025 19:40:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DSwitch=E4=BC=9A?= =?UTF-8?q?=E5=9C=A8=E6=AF=8F=E6=AC=A1=E5=88=B7=E6=96=B0=E5=90=8E=E5=8F=91?= =?UTF-8?q?=E9=80=81=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/UdpServer.cs | 2 +- src/components/equipments/Switch.vue | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/src/UdpServer.cs b/server/src/UdpServer.cs index f8502c9..e396120 100644 --- a/server/src/UdpServer.cs +++ b/server/src/UdpServer.cs @@ -436,7 +436,7 @@ public class UDPServer } var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4])); - PrintData(udpDataObj); + // PrintData(udpDataObj); } catch (Exception e) { diff --git a/src/components/equipments/Switch.vue b/src/components/equipments/Switch.vue index 8f0a021..edd892c 100644 --- a/src/components/equipments/Switch.vue +++ b/src/components/equipments/Switch.vue @@ -191,20 +191,30 @@ function setBtnStatus(idx: number, isOn: boolean) { } // 监听 props 变化只同步一次 +const isFirstEnableDigitalTwin = ref(true); watch( () => props.enableDigitalTwin, (newVal) => { - const client = getClient(); - client.setEnable(newVal); + if (isFirstEnableDigitalTwin.value) { + isFirstEnableDigitalTwin.value = false; + } else { + const client = getClient(); + client.setEnable(newVal); + } }, { immediate: true }, ); +const isFirstUpdateStatus = ref(true); watch( () => [switchCount.value, props.initialValues], () => { btnStatus.value = parseInitialValues(); - updateStatus(btnStatus.value); + if (isFirstUpdateStatus.value) { + isFirstUpdateStatus.value = false; + } else { + updateStatus(btnStatus.value); + } }, );