From 4eb2a2ab3d0a02470f9571eb7a5274cd36574222 Mon Sep 17 00:00:00 2001 From: yangsy Date: Wed, 24 Dec 2025 00:19:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=AE=80=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=A0=91=E7=9A=84=E8=87=AA=E5=8A=A8=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/device/device-tree/device-tree.vue | 14 ++++---------- src/composables/device/use-device-selection.ts | 6 +----- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/device/device-tree/device-tree.vue b/src/components/device/device-tree/device-tree.vue index 6248738..aa0b655 100644 --- a/src/components/device/device-tree/device-tree.vue +++ b/src/components/device/device-tree/device-tree.vue @@ -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(); }); diff --git a/src/composables/device/use-device-selection.ts b/src/composables/device/use-device-selection.ts index d8e88bb..dd1319b 100644 --- a/src/composables/device/use-device-selection.ts +++ b/src/composables/device/use-device-selection.ts @@ -3,7 +3,7 @@ import { tryGetDeviceType, type DeviceType } from '@/enums'; import { useDeviceStore } from '@/stores'; import { watchDebounced } from '@vueuse/core'; import { storeToRefs } from 'pinia'; -import { computed, onMounted, ref, watch } from 'vue'; +import { onMounted, ref, watch } from 'vue'; import { useRoute, useRouter } from 'vue-router'; export const useDeviceSelection = () => { @@ -17,8 +17,6 @@ export const useDeviceSelection = () => { const selectedDeviceType = ref(); const selectedDevice = ref(); - const hasFromPage = computed(() => !!route.query['fromPage']); - const initFromRoute = (lineDevices: LineDevices) => { const { stationCode, deviceType, deviceDbId } = route.query; if (stationCode) { @@ -107,8 +105,6 @@ export const useDeviceSelection = () => { selectedDeviceType, selectedDevice, - hasFromPage, - initFromRoute, selectDevice, routeDevice,