1
1
<script setup lang="ts">
2
2
import { useHead } from ' @vueuse/head'
3
- import { ref , computed } from ' vue'
3
+ import { ref , computed , watch } from ' vue'
4
4
import { useTimestamp } from ' @vueuse/core'
5
- import { total , currentPage , currentRoute , nextRoute , clicks , clicksElements , useSwipeControls , clicksTotal , hasNext } from ' ../logic/nav'
5
+ import type { RouteRecordRaw } from ' vue-router'
6
+ import { total , currentPage , currentRoute , nextRoute , clicks , clicksElements , useSwipeControls , clicksTotal , hasNext , rawRoutes } from ' ../logic/nav'
6
7
import { showOverview } from ' ../state'
7
8
import { configs } from ' ../env'
8
9
import { registerShotcuts } from ' ../logic/shortcuts'
@@ -11,9 +12,18 @@ import NavControls from './NavControls.vue'
11
12
import SlidesOverview from ' ./SlidesOverview.vue'
12
13
import NoteEditor from ' ./NoteEditor.vue'
13
14
import Goto from ' ./Goto.vue'
15
+ import SlideWrapper from ' ./SlideWrapper.vue'
14
16
15
17
registerShotcuts ()
16
18
19
+ // preload next route
20
+ watch (currentRoute , () => {
21
+ if (currentRoute .value ?.meta )
22
+ currentRoute .value .meta .loaded = true
23
+ if (nextRoute .value ?.meta )
24
+ nextRoute .value .meta .loaded = true
25
+ }, { immediate: true })
26
+
17
27
useHead ({
18
28
title: configs .title ? ` Presenter - ${configs .title } - Slidev ` : ' Presenter - Slidev' ,
19
29
})
@@ -56,6 +66,13 @@ const nextSlide = computed(() => {
56
66
})
57
67
58
68
useSwipeControls (main )
69
+
70
+ const getClass = (route : RouteRecordRaw ) => {
71
+ const no = route ?.meta ?.slide ?.no
72
+ if (no != null )
73
+ return ` slidev-page-${no } `
74
+ return ' '
75
+ }
59
76
</script >
60
77
61
78
<template >
@@ -79,23 +96,37 @@ useSwipeControls(main)
79
96
<div ref =" main" class =" grid-section main flex flex-col p-4" >
80
97
<SlideContainer
81
98
key =" main"
82
- v-model:clicks =" clicks"
83
- v-model:clicks-elements =" clicksElements"
84
99
class =" h-full w-full"
85
- :route =" currentRoute"
86
- :clicks-disabled =" false"
87
- />
100
+ >
101
+ <template #>
102
+ <template v-for =" route of rawRoutes " :key =" route .path " >
103
+ <SlideWrapper
104
+ :is =" route?.component"
105
+ v-if =" route.meta.loaded"
106
+ :style =" { display: route === currentRoute ? null : 'none' }"
107
+ :clicks =" route === currentRoute ? clicks : 0"
108
+ :clicks-elements =" route.meta.clicksElements"
109
+ :clicks-disabled =" false"
110
+ :class =" getClass(route)"
111
+ />
112
+ </template >
113
+ </template >
114
+ </SlideContainer >
88
115
</div >
89
116
<div class =" grid-section next flex flex-col p-4" >
90
117
<SlideContainer
91
118
v-if =" nextSlide"
92
119
key =" next"
93
- v-model:clicks-elements =" nextTabElements"
94
120
class =" h-full w-full"
95
- :clicks =" nextSlide.clicks"
96
- :route =" nextSlide.route"
97
- :clicks-disabled =" false"
98
- />
121
+ >
122
+ <SlideWrapper
123
+ :is =" nextSlide.route?.component"
124
+ v-model:clicks-elements =" nextTabElements"
125
+ :clicks =" nextSlide.clicks"
126
+ :clicks-disabled =" false"
127
+ :class =" getClass(nextSlide.route)"
128
+ />
129
+ </SlideContainer >
99
130
</div >
100
131
<div class =" grid-section note" >
101
132
<NoteEditor class =" w-full h-full p-4 overflow-auto" />
0 commit comments