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]));
|
var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4]));
|
||||||
PrintData(udpDataObj);
|
// PrintData(udpDataObj);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue