perf: optimize query and device tree

This commit is contained in:
yangsy
2025-09-09 14:26:30 +08:00
parent 5a28645f80
commit 4e09c4542e

View File

@@ -26,15 +26,11 @@ const onClickBack = () => router.push({ path: `${route.query['from']}` });
const { selectedStationCode, selectedDeviceType, selectedDevice, selectDevice, initFromRoute } = useDeviceSelection(); const { selectedStationCode, selectedDeviceType, selectedDevice, selectDevice, initFromRoute } = useDeviceSelection();
const localLineDevices = ref<LineDevices>({});
// 页面初始化 // 页面初始化
onMounted(() => { onMounted(() => {
initFromRoute(lineDevices.value); initFromRoute(lineDevices.value);
}); });
watch(lineDevices, (devices) => initFromRoute(devices), { deep: true });
// 加载条控制 // 加载条控制
watch( watch(
lineDevicesFetching, lineDevicesFetching,
@@ -44,8 +40,7 @@ watch(
} else { } else {
window.$loadingBar.finish(); window.$loadingBar.finish();
// 当设备数据更新时,需要重新配置设备树 // 当设备数据更新时,需要重新配置设备树
localLineDevices.value = lineDevices.value; initFromRoute(lineDevices.value);
// initFromRoute(lineDevices.value);
} }
}, },
{ {
@@ -59,7 +54,7 @@ watch(
<NLayoutSider bordered :width="600" :collapsed-width="0" show-trigger="bar"> <NLayoutSider bordered :width="600" :collapsed-width="0" show-trigger="bar">
<DeviceTree <DeviceTree
:station-list="stationList" :station-list="stationList"
:line-devices="localLineDevices" :line-devices="lineDevices"
:selected-station-code="selectedStationCode" :selected-station-code="selectedStationCode"
:selected-device-type="selectedDeviceType" :selected-device-type="selectedDeviceType"
:selected-device="selectedDevice" :selected-device="selectedDevice"