perf: lift UX priority when query running
This commit is contained in:
@@ -22,14 +22,14 @@ export function useStationListQuery() {
|
||||
queryKey: [STATION_LIST_QUERY_KEY],
|
||||
enabled: computed(() => pollingEnabled.value),
|
||||
refetchInterval: getAppEnvConfig().requestInterval * 1000,
|
||||
queryFn: async () => {
|
||||
queryFn: async ({ signal }) => {
|
||||
// 主动登录校验
|
||||
const [err] = await userClient.post<void>(`/api/ndm/ndmKeepAlive/verify`, {}, { timeout: 5000 });
|
||||
const [err] = await userClient.post<void>(`/api/ndm/ndmKeepAlive/verify`, {}, { timeout: 5000, signal });
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const { data: ndmStationList } = await axios.get<{ code: string; name: string }[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`);
|
||||
const { data: ndmStationList } = await axios.get<{ code: string; name: string }[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`, { signal });
|
||||
|
||||
let stations = ndmStationList.map<Station>((station) => ({
|
||||
code: station.code ?? '',
|
||||
@@ -37,7 +37,7 @@ export function useStationListQuery() {
|
||||
online: false,
|
||||
}));
|
||||
|
||||
const pingResultList = await Promise.allSettled(stations.map((station) => ndmVerify(station.code)));
|
||||
const pingResultList = await Promise.allSettled(stations.map((station) => ndmVerify(station.code, signal)));
|
||||
|
||||
stations = stations.map((station, index) => ({
|
||||
...station,
|
||||
@@ -58,7 +58,7 @@ export function useStationListQuery() {
|
||||
// queryClient.invalidateQueries({ queryKey: ['station-devices'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['station-alarms'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['line-devices'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['line-alarms'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['line-alarms'] });
|
||||
|
||||
return stations;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user