perf: ignore CancelledError in all queries, and show error message in route pages
This commit is contained in:
@@ -2,7 +2,7 @@ import { LINE_ALARM_COUNTS_QUERY_KEY } from '@/constants';
|
||||
import { useLineAlarmCountsStore } from '@/stores/line-alarm-counts';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { useMutation, useQuery } from '@tanstack/vue-query';
|
||||
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -101,8 +101,11 @@ function useStationAlarmCountsMutation() {
|
||||
});
|
||||
},
|
||||
onError: (error, { station }) => {
|
||||
console.error(`获取车站 ${station.name} 设备告警数据失败:`, error);
|
||||
lineAlarmCounts.value[station.code] = createEmptyStationAlarmCounts();
|
||||
if (!isCancelledError(error)) {
|
||||
console.error(`获取车站 ${station.name} 设备告警数据失败:`, error);
|
||||
lineAlarmCounts.value[station.code] = createEmptyStationAlarmCounts();
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DeviceType } from '@/enums/device-type';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { useMutation, useQuery } from '@tanstack/vue-query';
|
||||
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import type { StationDevices } from './domains';
|
||||
@@ -84,8 +84,11 @@ function useStationDevicesMutation() {
|
||||
});
|
||||
},
|
||||
onError: (error, { station }) => {
|
||||
console.error(`获取车站 ${station.name} 设备数据失败:`, error);
|
||||
lineDevices.value[station.code] = createEmptyStationDevices();
|
||||
if (!isCancelledError(error)) {
|
||||
console.error(`获取车站 ${station.name} 设备数据失败:`, error);
|
||||
lineDevices.value[station.code] = createEmptyStationDevices();
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { STATION_LIST_QUERY_KEY } from '@/constants';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { getAppEnvConfig } from '@/utils/env';
|
||||
import { useMutation, useQuery } from '@tanstack/vue-query';
|
||||
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
||||
import axios from 'axios';
|
||||
import dayjs from 'dayjs';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -60,5 +60,10 @@ function useStationListMutation() {
|
||||
stationList.value.splice(0, stationList.value.length, ...stations);
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
if (!isCancelledError(error)) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user