From 0577042338092cfe93611ff74b417bd4062e96df Mon Sep 17 00:00:00 2001 From: yangsy Date: Sun, 17 Aug 2025 01:21:32 +0800 Subject: [PATCH] feat: stores --- src/stores/query-control.ts | 12 ++++++++++++ src/stores/station.ts | 4 +++- src/stores/user.ts | 5 +++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/stores/query-control.ts diff --git a/src/stores/query-control.ts b/src/stores/query-control.ts new file mode 100644 index 0000000..8e10a55 --- /dev/null +++ b/src/stores/query-control.ts @@ -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 }; +}); diff --git a/src/stores/station.ts b/src/stores/station.ts index 124749d..a371b2e 100644 --- a/src/stores/station.ts +++ b/src/stores/station.ts @@ -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([]); const onlineStationList = computed(() => stationList.value.filter((station) => station.online)); - return { stationList, onlineStationList }; + return { updatedTime, stationList, onlineStationList }; }); diff --git a/src/stores/user.ts b/src/stores/user.ts index 5a8d45e..031ed03 100644 --- a/src/stores/user.ts +++ b/src/stores/user.ts @@ -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) {