refactor: 移除polling-store,重构setting-store

This commit is contained in:
yangsy
2026-01-19 15:15:38 +08:00
parent b7b6b216fb
commit 6771abec31
29 changed files with 197 additions and 185 deletions
@@ -1,6 +1,6 @@
import { batchVerifyApi, type Station } from '@/apis';
import { LINE_STATIONS_MUTATION_KEY, LINE_STATIONS_QUERY_KEY } from '@/constants';
import { usePollingStore, useStationStore } from '@/stores';
import { useSettingStore, useStationStore } from '@/stores';
import { getAppEnvConfig, parseErrorFeedback } from '@/utils';
import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query';
import axios, { isCancel } from 'axios';
@@ -44,8 +44,8 @@ export const useLineStationsMutation = () => {
};
export const useLineStationsQuery = () => {
const pollingStore = usePollingStore();
const { pollingEnabled } = storeToRefs(pollingStore);
const settingStore = useSettingStore();
const { pollingStations } = storeToRefs(settingStore);
const { requestInterval } = getAppEnvConfig();
const { mutateAsync: getLineStations } = useLineStationsMutation();
const { refetch: refetchLineDevicesQuery } = useLineDevicesQuery();
@@ -53,7 +53,7 @@ export const useLineStationsQuery = () => {
return useQuery({
queryKey: computed(() => [LINE_STATIONS_QUERY_KEY]),
enabled: computed(() => pollingEnabled.value),
enabled: computed(() => pollingStations.value),
refetchInterval: requestInterval * 1000,
staleTime: (requestInterval * 1000) / 2,
queryFn: async ({ signal }) => {
@@ -62,10 +62,10 @@ export const useLineStationsQuery = () => {
const endTime = performance.now();
console.log(`${LINE_STATIONS_QUERY_KEY}: ${endTime - startTime} ms`);
if (!pollingEnabled.value) return null;
if (!pollingStations.value) return null;
await refetchLineDevicesQuery();
if (!pollingEnabled.value) return null;
if (!pollingStations.value) return null;
await refetchLineAlarmsQuery();
return null;