fix: 修复Switch会在每次刷新后发送请求
This commit is contained in:
parent
e3b7cc4f63
commit
e5b492247c
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -191,20 +191,30 @@ function setBtnStatus(idx: number, isOn: boolean) {
|
|||
}
|
||||
|
||||
// 监听 props 变化只同步一次
|
||||
const isFirstEnableDigitalTwin = ref(true);
|
||||
watch(
|
||||
() => props.enableDigitalTwin,
|
||||
(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();
|
||||
if (isFirstUpdateStatus.value) {
|
||||
isFirstUpdateStatus.value = false;
|
||||
} else {
|
||||
updateStatus(btnStatus.value);
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue