mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
feature: modal darowizn
This commit is contained in:
+23
-4
@@ -9,7 +9,7 @@ import { parseSpawns, getScheduledTrains, getStationTrains } from './utils';
|
||||
import { OnlineScenery, ScheduledTrain, StationJSONData, StoreState } from './typings';
|
||||
|
||||
import packageInfo from '../../package.json';
|
||||
import { Websocket, API } from '../typings/api';
|
||||
import { Websocket, API, GithubAPI } from '../typings/api';
|
||||
import { Status } from '../typings/common';
|
||||
|
||||
export const useStore = defineStore('store', {
|
||||
@@ -17,6 +17,7 @@ export const useStore = defineStore('store', {
|
||||
({
|
||||
activeData: {} as unknown,
|
||||
rollingStockData: undefined,
|
||||
donatorsData: [],
|
||||
|
||||
stationList: [],
|
||||
regionOnlineCounters: [],
|
||||
@@ -55,7 +56,14 @@ export const useStore = defineStore('store', {
|
||||
|
||||
blockScroll: false,
|
||||
listenerLaunched: false,
|
||||
modalLastClickedTarget: null
|
||||
modalLastClickedTarget: null,
|
||||
|
||||
tooltip: {
|
||||
content: '',
|
||||
visible: false,
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
}) as StoreState,
|
||||
|
||||
getters: {
|
||||
@@ -280,6 +288,7 @@ export const useStore = defineStore('store', {
|
||||
async connectToAPI() {
|
||||
this.connectToWebsocket();
|
||||
this.fetchStockInfoData();
|
||||
this.fetchDonatorsData();
|
||||
this.fetchStationsGeneralInfo();
|
||||
},
|
||||
|
||||
@@ -299,6 +308,18 @@ export const useStore = defineStore('store', {
|
||||
}
|
||||
},
|
||||
|
||||
async fetchDonatorsData() {
|
||||
try {
|
||||
const response = await axios.get<GithubAPI.Donators.Response>(
|
||||
'https://raw.githubusercontent.com/Spythere/api/main/td2/data/donators.json'
|
||||
);
|
||||
|
||||
if (response.data) this.donatorsData = ['Kryszakos'];
|
||||
} catch (error) {
|
||||
console.error('Ups! Wystąpił błąd podczas pobierania informacji o donatorach:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async setStatuses() {
|
||||
if (!this.activeData.activeSceneries) {
|
||||
this.dataStatuses.sceneries = Status.Data.Error;
|
||||
@@ -311,8 +332,6 @@ export const useStore = defineStore('store', {
|
||||
this.dataStatuses.sceneries = Status.Data.Loaded;
|
||||
this.dataStatuses.trains = !this.activeData.trains ? Status.Data.Warning : Status.Data.Loaded;
|
||||
this.dataStatuses.dispatchers = Status.Data.Loaded;
|
||||
|
||||
// if (this.apiData.dispatchers != null) this.lastDispatcherStatuses = prevDispatcherStatuses;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+10
-2
@@ -1,6 +1,6 @@
|
||||
import { Socket } from 'socket.io-client';
|
||||
import Station from '../scripts/interfaces/Station';
|
||||
import { API, Websocket } from '../typings/api';
|
||||
import { API, GithubAPI, Websocket } from '../typings/api';
|
||||
import { Status } from '../typings/common';
|
||||
|
||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||
@@ -15,6 +15,7 @@ export interface StoreState {
|
||||
stationList: Station[];
|
||||
activeData: Websocket.ActiveData;
|
||||
rollingStockData?: API.RollingStock.Response;
|
||||
donatorsData: GithubAPI.Donators.Response;
|
||||
|
||||
regionOnlineCounters: RegionCounters[];
|
||||
|
||||
@@ -55,6 +56,13 @@ export interface StoreState {
|
||||
listenerLaunched: boolean;
|
||||
blockScroll: boolean;
|
||||
modalLastClickedTarget: EventTarget | null;
|
||||
|
||||
tooltip: {
|
||||
visible: boolean;
|
||||
x: number;
|
||||
y: number;
|
||||
content: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface StationRoutesInfo {
|
||||
@@ -187,7 +195,7 @@ export interface TrainStop {
|
||||
departureDelay: number;
|
||||
pointId: number;
|
||||
|
||||
comments?: any;
|
||||
comments?: string;
|
||||
|
||||
beginsHere: boolean;
|
||||
terminatesHere: boolean;
|
||||
|
||||
Reference in New Issue
Block a user