mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
feat: router links embeded into timetable stop names
This commit is contained in:
@@ -214,6 +214,12 @@ export default defineComponent({
|
|||||||
this.loadSelectedOption();
|
this.loadSelectedOption();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
station() {
|
||||||
|
this.loadSelectedOption();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const currentURL = computed(() => `${location.origin}${route.fullPath}`);
|
const currentURL = computed(() => `${location.origin}${route.fullPath}`);
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
class="stop-label"
|
class="stop-label"
|
||||||
:data-minor="stop.isSBL || (stop.nameRaw.endsWith(', po.') && !stop.duration)"
|
:data-minor="stop.isSBL || (stop.nameRaw.endsWith(', po.') && !stop.duration)"
|
||||||
>
|
>
|
||||||
<span class="name" v-html="stop.nameHtml"></span>
|
<router-link :to="`/scenery?station=${stop.sceneryName}`" @click="closeModal">
|
||||||
|
<span class="name" v-html="stop.nameHtml"></span>
|
||||||
|
</router-link>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="stop.position != 'begin'"
|
v-if="stop.position != 'begin'"
|
||||||
@@ -67,9 +69,10 @@
|
|||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import dateMixin from '../../mixins/dateMixin';
|
import dateMixin from '../../mixins/dateMixin';
|
||||||
import { TrainScheduleStop } from './TrainSchedule.vue';
|
import { TrainScheduleStop } from './TrainSchedule.vue';
|
||||||
|
import modalTrainMixin from '../../mixins/modalTrainMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [dateMixin],
|
mixins: [dateMixin, modalTrainMixin],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
stop: {
|
stop: {
|
||||||
|
|||||||
@@ -165,20 +165,18 @@ export default defineComponent({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
scheduleStops(): TrainScheduleStop[] {
|
scheduleStops(): TrainScheduleStop[] {
|
||||||
let currentSceneryIndex = 0;
|
if (!this.train.timetableData) return [];
|
||||||
|
|
||||||
|
const { timetablePath } = this.train.timetableData;
|
||||||
|
let currentPathIndex = 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.train.timetableData?.followingStops.map((stop, i, arr) => {
|
this.train.timetableData?.followingStops.map((stop, i, arr) => {
|
||||||
const isExternal =
|
const isExternal =
|
||||||
i > 0 &&
|
i < arr.length - 1 &&
|
||||||
stop.arrivalLine != null &&
|
stop.departureLine === timetablePath[currentPathIndex].departureRouteExt;
|
||||||
(stop.arrivalLine != arr[i - 1].departureLine ||
|
|
||||||
(stop.arrivalLine == arr[i - 1].departureLine &&
|
|
||||||
!/-|_|(^it\d+)|(^sbl)/gi.test(stop.arrivalLine)));
|
|
||||||
|
|
||||||
if (isExternal) currentSceneryIndex++;
|
const sceneryName = timetablePath[currentPathIndex].stationName;
|
||||||
|
|
||||||
const sceneryName = this.train.timetableData!.sceneryNames[currentSceneryIndex];
|
|
||||||
const sceneryInfo = this.apiStore.sceneryData.find((st) => st.name == sceneryName);
|
const sceneryInfo = this.apiStore.sceneryData.find((st) => st.name == sceneryName);
|
||||||
|
|
||||||
const arrivalLineInfo = sceneryInfo?.routesInfo.find(
|
const arrivalLineInfo = sceneryInfo?.routesInfo.find(
|
||||||
@@ -189,6 +187,8 @@ export default defineComponent({
|
|||||||
(r) => r.routeName == stop.departureLine
|
(r) => r.routeName == stop.departureLine
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isExternal) currentPathIndex++;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
nameHtml: stop.stopName,
|
nameHtml: stop.stopName,
|
||||||
nameRaw: stop.stopNameRAW,
|
nameRaw: stop.stopNameRAW,
|
||||||
|
|||||||
+56
-13
@@ -50,14 +50,14 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
|
|
||||||
const timetable = train.timetable;
|
const timetable = train.timetable;
|
||||||
|
|
||||||
const sceneryNames =
|
// const sceneryNames =
|
||||||
train.timetable?.sceneries?.map(
|
// train.timetable?.sceneries?.map(
|
||||||
(sceneryHash) =>
|
// (sceneryHash) =>
|
||||||
apiStore.activeData?.activeSceneries?.find((st) => st.stationHash === sceneryHash)
|
// apiStore.activeData?.activeSceneries?.find((st) => st.stationHash === sceneryHash)
|
||||||
?.stationName ??
|
// ?.stationName ??
|
||||||
apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
|
// apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
|
||||||
sceneryHash
|
// sceneryHash
|
||||||
) ?? [];
|
// ) ?? [];
|
||||||
|
|
||||||
const trainObj = {
|
const trainObj = {
|
||||||
id: train.id,
|
id: train.id,
|
||||||
@@ -96,7 +96,7 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
followingStops: timetable.stopList,
|
followingStops: timetable.stopList,
|
||||||
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
|
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
|
||||||
sceneries: timetable.sceneries,
|
sceneries: timetable.sceneries,
|
||||||
sceneryNames: sceneryNames.reverse(),
|
// sceneryNames: sceneryNames.reverse(),
|
||||||
timetablePath: timetable.path.split(';').map((pathElementString) => {
|
timetablePath: timetable.path.split(';').map((pathElementString) => {
|
||||||
const [arrival, station, departure] = pathElementString.split(',');
|
const [arrival, station, departure] = pathElementString.split(',');
|
||||||
|
|
||||||
@@ -169,12 +169,15 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
||||||
if (!train.timetableData) return acc;
|
if (!train.timetableData) return acc;
|
||||||
|
|
||||||
train.timetableData.sceneryNames.forEach((name) => {
|
train.timetableData.timetablePath.forEach((p) => {
|
||||||
if (
|
if (
|
||||||
acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
|
acc.findIndex(
|
||||||
|
(v) =>
|
||||||
|
(v.name == p.stationName || v.hash == p.stationHash) && v.region == train.region
|
||||||
|
) != -1 ||
|
||||||
apiStore.activeData?.activeSceneries?.findIndex(
|
apiStore.activeData?.activeSceneries?.findIndex(
|
||||||
(sc) =>
|
(sc) =>
|
||||||
sc.stationName === name &&
|
(sc.stationName == p.stationName || sc.stationHash == p.stationHash) &&
|
||||||
sc.region == train.region &&
|
sc.region == train.region &&
|
||||||
Date.now() - sc.lastSeen < 1000 * 60 * 2
|
Date.now() - sc.lastSeen < 1000 * 60 * 2
|
||||||
) != -1
|
) != -1
|
||||||
@@ -182,7 +185,7 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
return acc;
|
return acc;
|
||||||
|
|
||||||
acc.push({
|
acc.push({
|
||||||
name: name,
|
name: p.stationName,
|
||||||
hash: '',
|
hash: '',
|
||||||
region: train.region,
|
region: train.region,
|
||||||
maxUsers: 0,
|
maxUsers: 0,
|
||||||
@@ -209,6 +212,46 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// train.timetableData.sceneryNames.forEach((name) => {
|
||||||
|
// if (
|
||||||
|
// acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
|
||||||
|
// apiStore.activeData?.activeSceneries?.findIndex(
|
||||||
|
// (sc) =>
|
||||||
|
// sc.stationName === name &&
|
||||||
|
// sc.region == train.region &&
|
||||||
|
// Date.now() - sc.lastSeen < 1000 * 60 * 2
|
||||||
|
// ) != -1
|
||||||
|
// )
|
||||||
|
// return acc;
|
||||||
|
|
||||||
|
// acc.push({
|
||||||
|
// name: name,
|
||||||
|
// hash: '',
|
||||||
|
// region: train.region,
|
||||||
|
// maxUsers: 0,
|
||||||
|
// currentUsers: 0,
|
||||||
|
// spawns: [],
|
||||||
|
// dispatcherName: '',
|
||||||
|
// dispatcherRate: 0,
|
||||||
|
// dispatcherId: -1,
|
||||||
|
// dispatcherExp: -1,
|
||||||
|
// dispatcherIsSupporter: false,
|
||||||
|
// dispatcherStatus: Status.ActiveDispatcher.FREE,
|
||||||
|
// dispatcherTimestamp: -1,
|
||||||
|
|
||||||
|
// isOnline: false,
|
||||||
|
|
||||||
|
// stationTrains: [],
|
||||||
|
// scheduledTrains: [],
|
||||||
|
|
||||||
|
// scheduledTrainCount: {
|
||||||
|
// all: 0,
|
||||||
|
// confirmed: 0,
|
||||||
|
// unconfirmed: 0
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, [] as ActiveScenery[]);
|
}, [] as ActiveScenery[]);
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ export interface Train {
|
|||||||
SKR: boolean;
|
SKR: boolean;
|
||||||
routeDistance: number;
|
routeDistance: number;
|
||||||
sceneries: string[];
|
sceneries: string[];
|
||||||
sceneryNames: string[];
|
|
||||||
timetablePath: TimetablePathElement[];
|
timetablePath: TimetablePathElement[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
:station="stationInfo"
|
:station="stationInfo"
|
||||||
:onlineScenery="onlineSceneryInfo"
|
:onlineScenery="onlineSceneryInfo"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SceneryInfo :station="stationInfo" :onlineScenery="onlineSceneryInfo" />
|
<SceneryInfo :station="stationInfo" :onlineScenery="onlineSceneryInfo" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user