From b17e7b589a5c9acfad9fa92f27313f3299b48c23 Mon Sep 17 00:00:00 2001 From: yangsy Date: Tue, 26 Aug 2025 04:20:44 +0800 Subject: [PATCH] fix --- src/components/station-card.vue | 10 +++++----- .../query/station/use-station-list-query.ts | 8 ++++---- src/pages/dashboard-page.vue | 4 ++++ src/router/index.ts | 4 ---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/station-card.vue b/src/components/station-card.vue index f03ffa5..036a324 100644 --- a/src/components/station-card.vue +++ b/src/components/station-card.vue @@ -13,8 +13,8 @@ import { toRefs, computed, ref } from 'vue'; interface Props { station: Station; - stationDevices: StationDevices; - stationAlarms: StationAlarms; + stationDevices?: StationDevices; + stationAlarms?: StationAlarms; } const props = defineProps(); @@ -26,7 +26,7 @@ const { code, name, online } = toRefs(station.value); const offlineDeviceCount = computed(() => { let count = 0; Object.values(DeviceType).forEach((deviceType) => { - const offlineDeviceList = stationDevices.value[deviceType].filter((device) => device.deviceStatus === '20'); + const offlineDeviceList = stationDevices.value?.[deviceType].filter((device) => device.deviceStatus === '20') ?? []; count += offlineDeviceList.length; }); return count; @@ -34,14 +34,14 @@ const offlineDeviceCount = computed(() => { const deviceCount = computed(() => { let count = 0; Object.values(DeviceType).forEach((deviceType) => { - count += stationDevices.value[deviceType].length; + count += stationDevices.value?.[deviceType].length ?? 0; }); return count; }); const devicAlarmCount = computed(() => { let count = 0; Object.values(DeviceType).forEach((deviceType) => { - count += stationAlarms.value[deviceType].length; + count += stationAlarms.value?.[deviceType].length ?? 0; }); return count; }); diff --git a/src/composables/query/station/use-station-list-query.ts b/src/composables/query/station/use-station-list-query.ts index fbe30d4..e4c541b 100644 --- a/src/composables/query/station/use-station-list-query.ts +++ b/src/composables/query/station/use-station-list-query.ts @@ -46,10 +46,10 @@ export function useStationListQuery() { } const queryClient = useQueryClient(); - queryClient.invalidateQueries({ queryKey: ['station-devices'] }); - queryClient.invalidateQueries({ queryKey: ['station-alarms'] }); - // queryClient.invalidateQueries({ queryKey: ['line-devices'] }); - // queryClient.invalidateQueries({ queryKey: ['line-alarms'] }); + // queryClient.invalidateQueries({ queryKey: ['station-devices'] }); + // queryClient.invalidateQueries({ queryKey: ['station-alarms'] }); + queryClient.invalidateQueries({ queryKey: ['line-devices'] }); + queryClient.invalidateQueries({ queryKey: ['line-alarms'] }); return stations; }, diff --git a/src/pages/dashboard-page.vue b/src/pages/dashboard-page.vue index eb98c79..2d4ac97 100644 --- a/src/pages/dashboard-page.vue +++ b/src/pages/dashboard-page.vue @@ -5,6 +5,7 @@ import { useStationStore } from '@/stores/station'; import { storeToRefs } from 'pinia'; import { useLineDevicesStore } from '@/stores/line-devices'; import { useLineAlarmsStore } from '@/stores/line-alarms'; +import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables/query'; const stationStore = useStationStore(); const { stationList } = storeToRefs(stationStore); @@ -12,6 +13,9 @@ const lineDevicesStore = useLineDevicesStore(); const { lineDevices } = storeToRefs(lineDevicesStore); const lineAlarmsStore = useLineAlarmsStore(); const { lineAlarms } = storeToRefs(lineAlarmsStore); + +useLineDevicesQuery(); +useLineAlarmsQuery();