fix: polling still running when modal open
This commit is contained in:
@@ -2,6 +2,7 @@ import type { Station } from '@/apis/domains';
|
||||
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
||||
import { postNdmDeviceAlarmLogPage } from '@/apis/requests';
|
||||
import { DeviceType } from '@/enums/device-type';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -32,12 +33,16 @@ export interface LineAlarms {
|
||||
export function useLineAlarmsQuery() {
|
||||
const stationStore = useStationStore();
|
||||
const { updatedTime, stationList, onlineStationList } = storeToRefs(stationStore);
|
||||
const queryControlStore = useQueryControlStore();
|
||||
const { pollingEnabled } = storeToRefs(queryControlStore);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['line-alarms', updatedTime],
|
||||
enabled: computed(() => onlineStationList.value.length > 0),
|
||||
enabled: computed(() => onlineStationList.value.length > 0 && pollingEnabled.value),
|
||||
placeholderData: (prev) => prev,
|
||||
queryFn: async (): Promise<LineAlarms> => {
|
||||
// console.time('useLineAlarmsQuery');
|
||||
|
||||
const lineAlarms: LineAlarms = {};
|
||||
|
||||
if (!stationList?.value) {
|
||||
@@ -96,6 +101,8 @@ export function useLineAlarmsQuery() {
|
||||
}
|
||||
}
|
||||
|
||||
// console.timeEnd('useLineAlarmsQuery');
|
||||
|
||||
return lineAlarms;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
} from '@/apis/models';
|
||||
import { postNdmCameraPage, postNdmDecoderPage, postNdmKeyboardPage, postNdmMediaServerPage, postNdmNvrPage, postNdmSecurityBoxPage, postNdmSwitchPage, postNdmVideoServerPage } from '@/apis/requests';
|
||||
import { DeviceType } from '@/enums/device-type';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -36,12 +37,16 @@ export interface LineDevices {
|
||||
export function useLineDevicesQuery() {
|
||||
const stationStore = useStationStore();
|
||||
const { updatedTime, stationList, onlineStationList } = storeToRefs(stationStore);
|
||||
const queryControlStore = useQueryControlStore();
|
||||
const { pollingEnabled } = storeToRefs(queryControlStore);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['line-devices', updatedTime],
|
||||
enabled: computed(() => onlineStationList.value.length > 0),
|
||||
enabled: computed(() => onlineStationList.value.length > 0 && pollingEnabled.value),
|
||||
placeholderData: (prev) => prev,
|
||||
queryFn: async (): Promise<LineDevices> => {
|
||||
// console.time('useLineDevicesQuery');
|
||||
|
||||
const pageQuery: PageParams<{}> = { model: {}, extra: {}, size: 5000, current: 1, sort: 'id', order: 'ascending' };
|
||||
|
||||
const lineDevices: LineDevices = {};
|
||||
@@ -108,6 +113,8 @@ export function useLineDevicesQuery() {
|
||||
}
|
||||
}
|
||||
|
||||
// console.timeEnd('useLineDevicesQuery');
|
||||
|
||||
return lineDevices;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user