refactor: add store to save data from queries progressively
This commit is contained in:
@@ -3,7 +3,7 @@ import { ndmVerify } from '@/apis/requests';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { getAppEnvConfig } from '@/utils/env';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import { useQuery, useQueryClient } from '@tanstack/vue-query';
|
||||
import axios from 'axios';
|
||||
import dayjs from 'dayjs';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -11,7 +11,7 @@ import { computed } from 'vue';
|
||||
|
||||
export function useStationListQuery() {
|
||||
const stationStore = useStationStore();
|
||||
const { updatedTime, stationList } = storeToRefs(stationStore);
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
const queryControlStore = useQueryControlStore();
|
||||
const { pollingEnabled } = storeToRefs(queryControlStore);
|
||||
|
||||
@@ -45,7 +45,11 @@ export function useStationListQuery() {
|
||||
stationList.value.splice(0, stationList.value.length, ...stations);
|
||||
}
|
||||
|
||||
updatedTime.value = dayjs().toJSON();
|
||||
const queryClient = useQueryClient();
|
||||
queryClient.invalidateQueries({ queryKey: ['station-devices'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['station-alarms'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['line-devices'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['line-alarms'] });
|
||||
|
||||
return stations;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user