mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 471e6f5216 | |||
| a617eef00e | |||
| 38e700ecd6 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stacjownik",
|
||||
"version": "1.14.2",
|
||||
"version": "1.14.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -55,6 +55,16 @@ export interface APIData {
|
||||
connectedSocketCount: number;
|
||||
}
|
||||
|
||||
export interface StationRoutesInfo {
|
||||
routeName: string;
|
||||
isElectric: boolean;
|
||||
isInternal: boolean;
|
||||
isRouteSBL: boolean;
|
||||
routeLength: number;
|
||||
routeSpeed: number;
|
||||
routeTracks: number;
|
||||
}
|
||||
|
||||
export interface StationJSONData {
|
||||
name: string;
|
||||
abbr: string;
|
||||
@@ -70,7 +80,8 @@ export interface StationJSONData {
|
||||
|
||||
SUP: boolean;
|
||||
|
||||
routes: string;
|
||||
// routes: string;
|
||||
routesInfo: StationRoutesInfo[];
|
||||
|
||||
checkpoints: string | null;
|
||||
authors?: string;
|
||||
|
||||
+30
-48
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia';
|
||||
import { io } from 'socket.io-client';
|
||||
import { DataStatus } from '../scripts/enums/DataStatus';
|
||||
import StationAPIData from '../scripts/interfaces/api/StationAPIData';
|
||||
import {ScheduledTrain} from '../scripts/interfaces/ScheduledTrain';
|
||||
import { ScheduledTrain } from '../scripts/interfaces/ScheduledTrain';
|
||||
import Station from '../scripts/interfaces/Station';
|
||||
import StationRoutes from '../scripts/interfaces/StationRoutes';
|
||||
import Train from '../scripts/interfaces/Train';
|
||||
@@ -303,57 +303,39 @@ export const useStore = defineStore('store', {
|
||||
...scenery,
|
||||
authors: scenery.authors?.split(',').map((a) => a.trim()),
|
||||
routes:
|
||||
scenery.routes
|
||||
?.split(';')
|
||||
.filter((routeString) => routeString)
|
||||
.reduce(
|
||||
(acc, routeString) => {
|
||||
const specs1 = routeString.split('_')[0];
|
||||
const isInternal = specs1.startsWith('!');
|
||||
const name = isInternal ? specs1.replace('!', '') : specs1;
|
||||
scenery.routesInfo.reduce(
|
||||
(acc, route) => {
|
||||
const propName: keyof StationRoutes = `${route.routeTracks == 2 ? 'twoWay' : 'oneWay'}${
|
||||
route.isElectric ? '' : 'No'
|
||||
}CatenaryRouteNames`;
|
||||
|
||||
const specs2 = routeString.split('_')[1].split('');
|
||||
const twoWay = specs2[0] == '2';
|
||||
const catenary = specs2[1] == 'E';
|
||||
const SBL = specs2[2] == 'S';
|
||||
const TWB = specs2[3] ? true : false;
|
||||
const speed = Number(routeString.split(':')[1]) || 0;
|
||||
const length = Number(routeString.split(':')[2]) || 0;
|
||||
acc[route.routeTracks == 2 ? 'twoWay' : 'oneWay'].push({
|
||||
name: route.routeName,
|
||||
SBL: route.isRouteSBL,
|
||||
TWB: false,
|
||||
catenary: route.isElectric,
|
||||
isInternal: route.isInternal,
|
||||
tracks: route.routeTracks,
|
||||
length: route.routeLength,
|
||||
speed: route.routeSpeed,
|
||||
});
|
||||
|
||||
const propName = twoWay
|
||||
? catenary
|
||||
? 'twoWayCatenaryRouteNames'
|
||||
: 'twoWayNoCatenaryRouteNames'
|
||||
: catenary
|
||||
? 'oneWayCatenaryRouteNames'
|
||||
: 'oneWayNoCatenaryRouteNames';
|
||||
if (!route.isInternal) acc[propName].push(route.routeName);
|
||||
|
||||
acc[twoWay ? 'twoWay' : 'oneWay'].push({
|
||||
name,
|
||||
SBL,
|
||||
TWB,
|
||||
catenary,
|
||||
isInternal,
|
||||
tracks: twoWay ? 2 : 1,
|
||||
length,
|
||||
speed,
|
||||
});
|
||||
if (!isInternal) acc[propName].push(name);
|
||||
if (route.isRouteSBL) acc['sblRouteNames'].push(route.routeName);
|
||||
|
||||
if (SBL) acc['sblRouteNames'].push(name);
|
||||
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
oneWay: [],
|
||||
twoWay: [],
|
||||
sblRouteNames: [],
|
||||
oneWayCatenaryRouteNames: [],
|
||||
oneWayNoCatenaryRouteNames: [],
|
||||
twoWayCatenaryRouteNames: [],
|
||||
twoWayNoCatenaryRouteNames: [],
|
||||
} as StationRoutes
|
||||
) || {},
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
oneWay: [],
|
||||
twoWay: [],
|
||||
sblRouteNames: [],
|
||||
oneWayCatenaryRouteNames: [],
|
||||
oneWayNoCatenaryRouteNames: [],
|
||||
twoWayCatenaryRouteNames: [],
|
||||
twoWayNoCatenaryRouteNames: [],
|
||||
} as StationRoutes
|
||||
) || {},
|
||||
checkpoints: scenery.checkpoints
|
||||
? scenery.checkpoints.split(';').map((sub) => ({ checkpointName: sub, scheduledTrains: [] }))
|
||||
: [],
|
||||
|
||||
Reference in New Issue
Block a user