perf: ignore CancelledError in all queries, and show error message in route pages

This commit is contained in:
yangsy
2025-09-12 13:29:01 +08:00
parent 2ddab88a92
commit 2a95b40b9e
6 changed files with 44 additions and 12 deletions

View File

@@ -20,8 +20,8 @@ const { lineDevices } = storeToRefs(lineDevicesStore);
const lineAlarmCountsStore = useLineAlarmCountsStore();
const { lineAlarmCounts } = storeToRefs(lineAlarmCountsStore);
const { isFetching: lineDevicesFetching } = useLineDevicesQuery();
const { isFetching: lineAlarmCountsFetching } = useLineAlarmCountsQuery();
const { isFetching: lineDevicesFetching, error: lineDevicesQueryError } = useLineDevicesQuery();
const { isFetching: lineAlarmCountsFetching, error: lineAlarmCountsQueryError } = useLineAlarmCountsQuery();
const layoutStore = useLayoutStore();
const { stationLayoutGridCols } = storeToRefs(layoutStore);
@@ -40,6 +40,15 @@ watch(
},
);
watch([lineDevicesQueryError, lineAlarmCountsQueryError], ([newLineDevicesQueryError, newLineAlarmCountsQueryError]) => {
if (newLineDevicesQueryError) {
window.$message.error(newLineDevicesQueryError.message);
}
if (newLineAlarmCountsQueryError) {
window.$message.error(newLineAlarmCountsQueryError.message);
}
});
const selectedStation = ref<Station>();
const offlineDeviceTreeModalShow = ref(false);
const deviceAlarmTreeModalShow = ref(false);

View File

@@ -13,7 +13,7 @@ import DeviceTree from '@/components/device-page/device-tree.vue';
import DeviceRenderer from '@/components/device-page/device-renderer.vue';
// 数据获取
const { isFetching: lineDevicesFetching } = useLineDevicesQuery();
const { isFetching: lineDevicesFetching, error: lineDevicesQueryError } = useLineDevicesQuery();
const stationStore = useStationStore();
const { stationList } = storeToRefs(stationStore);
const lineDevicesStore = useLineDevicesStore();
@@ -47,6 +47,12 @@ watch(
immediate: true,
},
);
watch(lineDevicesQueryError, (newLineDevicesQueryError) => {
if (newLineDevicesQueryError) {
window.$message.error(newLineDevicesQueryError.message);
}
});
</script>
<template>