chore: added api mocking

This commit is contained in:
2025-01-27 02:31:08 +01:00
parent 48e8129902
commit f19a256153
9 changed files with 164 additions and 55 deletions
+2 -37
View File
@@ -1,42 +1,7 @@
import { defineStore } from 'pinia';
import httpClient from '../utils/http';
import type { ActiveDataResponse, SceneriesDataResponse } from '../types/api.types';
import type { ActiveData, SceneryData } from '../types/common.types';
export const useGlobalStore = defineStore('global', {
state: () => ({
activeData: null as ActiveData | null,
sceneryData: null as SceneryData[] | null,
}),
state: () => ({}),
getters: {},
actions: {
async _fetchActiveData() {
try {
const response = (await httpClient.get<ActiveDataResponse>('/api/getActiveData')).data;
this.activeData = response;
} catch (error) {
console.error(error);
}
},
async _fetchSceneriesData() {
try {
const response = (await httpClient.get<SceneriesDataResponse>('/api/getSceneries')).data;
this.sceneryData = response;
} catch (error) {
console.error(error);
}
},
setupData() {
this._fetchActiveData();
this._fetchSceneriesData();
setInterval(() => {
this._fetchActiveData();
}, 20000);
},
},
actions: {},
});