refactor: extract constants

This commit is contained in:
yangsy
2025-08-26 11:39:21 +08:00
parent 40bc4b76ef
commit 9fc5c170bc
7 changed files with 69 additions and 31 deletions

View File

@@ -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,
});
}