From 973b191eafe2e508d4ac0ea139b468b781b06374 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 8 Mar 2021 16:07:12 +0100 Subject: [PATCH] add query params to remember opened texts & define what component to append based on those query --- src/pages/Biblio.vue | 45 +++++++++++++++++++++++++++++++++++++++++--- src/pages/Home.vue | 15 +++++++-------- src/router/routes.js | 6 +++++- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/pages/Biblio.vue b/src/pages/Biblio.vue index 17e2d1b..1ef4201 100644 --- a/src/pages/Biblio.vue +++ b/src/pages/Biblio.vue @@ -1,11 +1,18 @@ diff --git a/src/pages/Home.vue b/src/pages/Home.vue index 50c2d05..66a4084 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -1,6 +1,8 @@ @@ -10,14 +12,11 @@ export default { data () { return { - text: null + query: { + mode: 'card-list', + texts: [[1, 10, 2], [20, 5, 19]] + } } - }, - - created () { - this.$store.dispatch('GET_TEXT', { id: 1 }).then(data => { - this.text = data.textref - }) } } diff --git a/src/router/routes.js b/src/router/routes.js index 72d9850..762f819 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -17,7 +17,11 @@ export default [ }, props: { default: ({ query }) => ({ - mode: query.mode || 'tree-map' + mode: query.mode || 'tree-map', + // In case of a reload or direct link, vue-router doesn't turn the query string into an array. + texts: query.texts && query.texts.length && typeof query.texts[0] === 'string' + ? query.texts.map(text => text.split(',').map(id => parseInt(id))) + : query.texts }), options: ({ query }) => ({ show: !('texts' in query)