refactor: extract constants
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Station } from '@/apis/domains';
|
||||
import { ndmVerify } from '@/apis/requests';
|
||||
import { STATION_LIST_QUERY_KEY } from '@/constants';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { getAppEnvConfig } from '@/utils/env';
|
||||
@@ -14,10 +15,12 @@ export function useStationListQuery() {
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
const queryControlStore = useQueryControlStore();
|
||||
const { pollingEnabled } = storeToRefs(queryControlStore);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['station-list'],
|
||||
queryKey: [STATION_LIST_QUERY_KEY],
|
||||
enabled: computed(() => pollingEnabled.value),
|
||||
refetchInterval: getAppEnvConfig().requestInterval * 1000,
|
||||
queryFn: async () => {
|
||||
const { data: ndmStationList } = await axios.get<{ code: string; name: string }[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`);
|
||||
|
||||
@@ -45,7 +48,6 @@ export function useStationListQuery() {
|
||||
stationList.value.splice(0, stationList.value.length, ...stations);
|
||||
}
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
// queryClient.invalidateQueries({ queryKey: ['station-devices'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['station-alarms'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['line-devices'] });
|
||||
@@ -53,6 +55,5 @@ export function useStationListQuery() {
|
||||
|
||||
return stations;
|
||||
},
|
||||
refetchInterval: getAppEnvConfig().requestInterval * 1000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user