mirror of
https://github.com/Spythere/srjp-td2.git
synced 2026-05-03 13:38:12 +00:00
feat: offline mode; PWA
This commit is contained in:
+25
-19
@@ -15,6 +15,8 @@ import type {
|
||||
} from '../types/common.types';
|
||||
import { useGlobalStore } from './global.store';
|
||||
|
||||
let activeDataInterval = -1;
|
||||
|
||||
export const useApiStore = defineStore('api', {
|
||||
state() {
|
||||
return {
|
||||
@@ -28,37 +30,41 @@ export const useApiStore = defineStore('api', {
|
||||
isActiveDataOutdated: false,
|
||||
|
||||
activeDataStatus: DataStatus.LOADING,
|
||||
journalDataStatus: DataStatus.SUCCESS
|
||||
journalDataStatus: DataStatus.SUCCESS,
|
||||
|
||||
connectionMode: 'online' as 'online' | 'offline'
|
||||
};
|
||||
},
|
||||
|
||||
actions: {
|
||||
async setupAPIData() {
|
||||
if (this.client != null) return;
|
||||
if (this.client == null) {
|
||||
let baseURL = 'https://stacjownik.spythere.eu';
|
||||
|
||||
let baseURL = 'https://stacjownik.spythere.eu';
|
||||
switch (import.meta.env.VITE_API_MODE) {
|
||||
case 'development':
|
||||
baseURL = 'http://localhost:3001';
|
||||
break;
|
||||
case 'mocking':
|
||||
baseURL = 'http://localhost:3123';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (import.meta.env.VITE_API_MODE) {
|
||||
case 'development':
|
||||
baseURL = 'http://localhost:3001';
|
||||
break;
|
||||
case 'mocking':
|
||||
baseURL = 'http://localhost:3123';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
this.client = axios.create({
|
||||
baseURL
|
||||
});
|
||||
}
|
||||
|
||||
this.client = axios.create({
|
||||
baseURL
|
||||
});
|
||||
clearInterval(activeDataInterval);
|
||||
|
||||
activeDataInterval = setInterval(() => {
|
||||
this.fetchActiveData();
|
||||
}, 25000);
|
||||
|
||||
this.fetchSceneriesData();
|
||||
await this.fetchActiveData();
|
||||
|
||||
setInterval(() => {
|
||||
this.fetchActiveData();
|
||||
}, 25000);
|
||||
},
|
||||
|
||||
async fetchActiveData() {
|
||||
|
||||
Reference in New Issue
Block a user