feat: stores

This commit is contained in:
yangsy
2025-08-17 01:21:32 +08:00
parent 37a8664748
commit 0577042338
3 changed files with 18 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
export const useQueryControlStore = defineStore('ndm-query-control-store', () => {
const pollingEnabled = ref(true);
const enablePolling = () => (pollingEnabled.value = true);
const disablePolling = () => (pollingEnabled.value = false);
return { pollingEnabled, enablePolling, disablePolling };
});

View File

@@ -3,9 +3,11 @@ import { defineStore } from 'pinia';
import { computed, ref } from 'vue';
export const useStationStore = defineStore('ndm-station-store', () => {
const updatedTime = ref('');
const stationList = ref<Station[]>([]);
const onlineStationList = computed(() => stationList.value.filter((station) => station.online));
return { stationList, onlineStationList };
return { updatedTime, stationList, onlineStationList };
});

View File

@@ -8,7 +8,7 @@ import { defineStore } from 'pinia';
import { ref } from 'vue';
import dayjs from 'dayjs';
import { useStationStore } from './station';
import { onlineManager } from '@tanstack/vue-query';
import { useQueryControlStore } from './query-control';
const getHeaders = () => {
const { lampAuthorization, lampClientId, lampClientSecret } = getAppEnvConfig();
@@ -131,7 +131,8 @@ export const useUserStore = defineStore(
window.location.reload();
},
});
onlineManager.setOnline(false);
const queryControlStore = useQueryControlStore();
queryControlStore.disablePolling();
throw new AxiosError(respData.msg, `${respData.code}`);
} else {
if (lampLoginResultRecord.value === null) {