From 08d3a2a03a941ab6f7a815e96b4a892bcf76e5f4 Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 13 Nov 2023 15:32:02 +0100 Subject: [PATCH] feature: nawigacja URL w widoku scenerii --- .../SceneryView/SceneryTimetablesHistory.vue | 6 ++--- src/router/index.ts | 3 ++- src/views/SceneryView.vue | 24 +++++++++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/components/SceneryView/SceneryTimetablesHistory.vue b/src/components/SceneryView/SceneryTimetablesHistory.vue index ae91946..5cb0842 100644 --- a/src/components/SceneryView/SceneryTimetablesHistory.vue +++ b/src/components/SceneryView/SceneryTimetablesHistory.vue @@ -18,9 +18,9 @@ - #{{ historyItem.id }} + + #{{ historyItem.id }} + {{ historyItem.trainCategoryCode }}
diff --git a/src/router/index.ts b/src/router/index.ts index 85573f5..b55a9ce 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -61,7 +61,8 @@ const routes: Array = [ const router = createRouter({ scrollBehavior(to, from, savedPosition) { - if (to.name == 'SceneryView' && from.name) return { el: `.app_main` }; + if (to.name == 'SceneryView' && from.name && from.query['view'] === undefined) + return { el: `.app_main` }; if (savedPosition) return savedPosition; diff --git a/src/views/SceneryView.vue b/src/views/SceneryView.vue index 4318001..494c1b0 100644 --- a/src/views/SceneryView.vue +++ b/src/views/SceneryView.vue @@ -27,7 +27,7 @@ :key="i" class="btn btn--option" @click="setViewMode(viewMode.component)" - :data-checked="currentViewCompontent == viewMode.component" + :data-checked="currentMode == viewMode.component" > {{ $t(viewMode.id) }} @@ -35,10 +35,10 @@ @@ -113,9 +113,9 @@ export default defineComponent({ onlineFrom: -1 }), - activated() { - this.loadSelectedCheckpoint(); - }, + // activated() { + // this.loadSelectedCheckpoint(); + // }, setup() { const route = useRoute(); @@ -128,6 +128,10 @@ export default defineComponent({ }, computed: { + currentMode() { + return this.$route.query.view ?? 'SceneryTimetable'; + }, + stationInfo() { return this.store.stationList.find( (station) => station.name === this.station?.toString().replace(/_/g, ' ') @@ -145,7 +149,13 @@ export default defineComponent({ methods: { setViewMode(componentName: string) { - this.currentViewCompontent = componentName; + this.$router.push({ + path: this.$route.path, + query: { + ...this.$route.query, + view: componentName + } + }); }, loadSelectedCheckpoint() {