From 4305077a35e63959555b056240e9da1415882141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Wed, 4 May 2022 22:39:29 +0200 Subject: [PATCH] Fix router configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raimund Schlüßler --- src/App.vue | 2 +- src/router.js | 72 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/App.vue b/src/App.vue index ff8d10c2a..3f9b598eb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -27,7 +27,7 @@ License along with this library. If not, see . - + diff --git a/src/router.js b/src/router.js index 6ea7c2995..af8336439 100644 --- a/src/router.js +++ b/src/router.js @@ -25,40 +25,58 @@ import AppSidebar from './views/AppSidebar.vue' import Calendar from './views/AppContent/Calendar.vue' import Collections from './views/AppContent/Collections.vue' -import { createWebHashHistory, createRouter } from 'vue-router' +import { h } from 'vue' +import { createWebHashHistory, createRouter, RouterView } from 'vue-router' const routes = [ - // using - // { path: '/collections/all', component: CollectionGeneral, alias: '/' }, - // instead of { path: '/', redirect: getInitialRoute() }, - // would also be an option, but it currently does not work - // reliably with router-link due to - // https://github.com/vuejs/vue-router/issues/419 - { name: 'collections', path: '/collections/:collectionId', component: Collections, props: true }, { - name: 'collectionsTask', - path: '/collections/:collectionId/tasks/:taskId', - components: { default: Collections, sidebar: AppSidebar }, - props: { default: true, sidebar: true }, + path: '/collections/:collectionId', + components: { + default: { render: () => h(RouterView, { name: 'default' }) }, + AppSidebar: { render: () => h(RouterView, { name: 'AppSidebar' }) }, + }, + children: [ + { + name: 'collections', + path: '/collections/:collectionId', + component: Collections, + props: true + }, + { + name: 'collectionsTask', + path: '/collections/:collectionId/tasks/:taskId', + components: { default: Collections, AppSidebar }, + props: { default: true, AppSidebar: true }, + }, + { + name: 'collectionsParamTask', + path: '/collections/:collectionId/:collectionParam/tasks/:taskId', + components: { default: Collections, AppSidebar }, + props: { default: true, AppSidebar: true }, + }, + ] }, { - name: 'collectionsParamTask', - path: '/collections/:collectionId/:collectionParam/tasks/:taskId', - components: { default: Collections, sidebar: AppSidebar }, - props: { default: true, sidebar: true }, - }, - { - name: 'calendars', path: '/calendars/:calendarId', - component: Calendar, - props: true, - }, - { - name: 'calendarsTask', - path: '/calendars/:calendarId/tasks/:taskId', - components: { default: Calendar, sidebar: AppSidebar }, - props: { default: true, sidebar: true }, + components: { + default: { render: () => h(RouterView, { name: 'default' }) }, + AppSidebar: { render: () => h(RouterView, { name: 'AppSidebar' }) }, + }, + children: [ + { + name: 'calendars', + path: '/calendars/:calendarId', + component: Calendar, + props: true, + }, + { + name: 'calendarsTask', + path: '/calendars/:calendarId/tasks/:taskId', + components: { default: Calendar, AppSidebar }, + props: { default: true, AppSidebar: true }, + }, + ] }, ]