refactor: 简化设备树的自动定位逻辑

This commit is contained in:
yangsy
2025-12-24 00:19:36 +08:00
parent 7f07725935
commit 4eb2a2ab3d
2 changed files with 5 additions and 15 deletions

View File

@@ -46,7 +46,6 @@ const {
selectedStationCode,
selectedDeviceType,
selectedDevice,
hasFromPage,
selectDevice,
routeDevice,
// 设备管理
@@ -461,16 +460,11 @@ const onLocateDeviceTree = async () => {
animated.value = true;
};
// 渲染全线设备树时,若是首次经过路由跳转而来选择设备,则定位设备树
const unwatchLocate = watch(selectedDevice, async (newDevice, oldDevice) => {
// 渲染全线设备树时,选择设备发生变化,则定位设备树
// 暂时不考虑多次执行的问题,因为当选择的设备在设备树视口内时,不会发生滚动
watch(selectedDevice, async () => {
if (!!station.value) return;
if (!hasFromPage.value) return;
if (!!newDevice && !oldDevice) {
if (!!deviceTreeInst.value) {
await onLocateDeviceTree();
unwatchLocate();
}
}
await onLocateDeviceTree();
});
</script>