Skip to content

Commit 4305077

Browse files
Fix router configuration
Signed-off-by: Raimund Schlüßler <[email protected]>
1 parent 9a64c21 commit 4305077

File tree

2 files changed

+46
-28
lines changed

2 files changed

+46
-28
lines changed

src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2727
<RouterView />
2828
</AppContent>
2929

30-
<RouterView name="sidebar" />
30+
<RouterView name="AppSidebar" />
3131
</Content>
3232
</template>
3333

src/router.js

+45-27
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,58 @@ import AppSidebar from './views/AppSidebar.vue'
2525
import Calendar from './views/AppContent/Calendar.vue'
2626
import Collections from './views/AppContent/Collections.vue'
2727

28-
import { createWebHashHistory, createRouter } from 'vue-router'
28+
import { h } from 'vue'
29+
import { createWebHashHistory, createRouter, RouterView } from 'vue-router'
2930

3031
const routes = [
31-
// using
32-
// { path: '/collections/all', component: CollectionGeneral, alias: '/' },
33-
// instead of
3432
{ path: '/', redirect: getInitialRoute() },
35-
// would also be an option, but it currently does not work
36-
// reliably with router-link due to
37-
// https://github.com/vuejs/vue-router/issues/419
38-
{ name: 'collections', path: '/collections/:collectionId', component: Collections, props: true },
3933
{
40-
name: 'collectionsTask',
41-
path: '/collections/:collectionId/tasks/:taskId',
42-
components: { default: Collections, sidebar: AppSidebar },
43-
props: { default: true, sidebar: true },
34+
path: '/collections/:collectionId',
35+
components: {
36+
default: { render: () => h(RouterView, { name: 'default' }) },
37+
AppSidebar: { render: () => h(RouterView, { name: 'AppSidebar' }) },
38+
},
39+
children: [
40+
{
41+
name: 'collections',
42+
path: '/collections/:collectionId',
43+
component: Collections,
44+
props: true
45+
},
46+
{
47+
name: 'collectionsTask',
48+
path: '/collections/:collectionId/tasks/:taskId',
49+
components: { default: Collections, AppSidebar },
50+
props: { default: true, AppSidebar: true },
51+
},
52+
{
53+
name: 'collectionsParamTask',
54+
path: '/collections/:collectionId/:collectionParam/tasks/:taskId',
55+
components: { default: Collections, AppSidebar },
56+
props: { default: true, AppSidebar: true },
57+
},
58+
]
4459
},
4560
{
46-
name: 'collectionsParamTask',
47-
path: '/collections/:collectionId/:collectionParam/tasks/:taskId',
48-
components: { default: Collections, sidebar: AppSidebar },
49-
props: { default: true, sidebar: true },
50-
},
51-
{
52-
name: 'calendars',
5361
path: '/calendars/:calendarId',
54-
component: Calendar,
55-
props: true,
56-
},
57-
{
58-
name: 'calendarsTask',
59-
path: '/calendars/:calendarId/tasks/:taskId',
60-
components: { default: Calendar, sidebar: AppSidebar },
61-
props: { default: true, sidebar: true },
62+
components: {
63+
default: { render: () => h(RouterView, { name: 'default' }) },
64+
AppSidebar: { render: () => h(RouterView, { name: 'AppSidebar' }) },
65+
},
66+
children: [
67+
{
68+
name: 'calendars',
69+
path: '/calendars/:calendarId',
70+
component: Calendar,
71+
props: true,
72+
},
73+
{
74+
name: 'calendarsTask',
75+
path: '/calendars/:calendarId/tasks/:taskId',
76+
components: { default: Calendar, AppSidebar },
77+
props: { default: true, AppSidebar: true },
78+
},
79+
]
6280
},
6381
]
6482

0 commit comments

Comments
 (0)