feat: stores
This commit is contained in:
12
src/stores/query-control.ts
Normal file
12
src/stores/query-control.ts
Normal 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 };
|
||||
});
|
||||
@@ -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 };
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user