fix: 修复Switch会在每次刷新后发送请求

This commit is contained in:
SikongJueluo 2025-08-21 19:40:19 +08:00
parent e3b7cc4f63
commit e5b492247c
2 changed files with 14 additions and 4 deletions

View File

@ -436,7 +436,7 @@ public class UDPServer
} }
var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4])); var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4]));
PrintData(udpDataObj); // PrintData(udpDataObj);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -191,20 +191,30 @@ function setBtnStatus(idx: number, isOn: boolean) {
} }
// props // props
const isFirstEnableDigitalTwin = ref(true);
watch( watch(
() => props.enableDigitalTwin, () => props.enableDigitalTwin,
(newVal) => { (newVal) => {
const client = getClient(); if (isFirstEnableDigitalTwin.value) {
client.setEnable(newVal); isFirstEnableDigitalTwin.value = false;
} else {
const client = getClient();
client.setEnable(newVal);
}
}, },
{ immediate: true }, { immediate: true },
); );
const isFirstUpdateStatus = ref(true);
watch( watch(
() => [switchCount.value, props.initialValues], () => [switchCount.value, props.initialValues],
() => { () => {
btnStatus.value = parseInitialValues(); btnStatus.value = parseInitialValues();
updateStatus(btnStatus.value); if (isFirstUpdateStatus.value) {
isFirstUpdateStatus.value = false;
} else {
updateStatus(btnStatus.value);
}
}, },
); );
</script> </script>