1
1
<template >
2
- <div class =" theme-container"
2
+ <div
3
+ class =" theme-container"
3
4
:class =" pageClasses"
4
5
@touchstart =" onTouchStart"
5
- @touchend =" onTouchEnd" >
6
- <Navbar v-if =" shouldShowNavbar" @toggle-sidebar =" toggleSidebar" />
7
- <div class =" sidebar-mask" @click =" toggleSidebar(false)" ></div >
8
- <Sidebar :items =" sidebarItems" @toggle-sidebar =" toggleSidebar" >
9
- <slot name =" sidebar-top" slot =" top" />
10
- <slot name =" sidebar-bottom" slot =" bottom" />
6
+ @touchend =" onTouchEnd"
7
+ >
8
+ <Navbar
9
+ v-if =" shouldShowNavbar"
10
+ @toggle-sidebar =" toggleSidebar"
11
+ />
12
+
13
+ <div
14
+ class =" sidebar-mask"
15
+ @click =" toggleSidebar(false)"
16
+ ></div >
17
+
18
+ <Sidebar
19
+ :items =" sidebarItems"
20
+ @toggle-sidebar =" toggleSidebar"
21
+ >
22
+ <slot
23
+ name =" sidebar-top"
24
+ slot =" top"
25
+ />
26
+ <slot
27
+ name =" sidebar-bottom"
28
+ slot =" bottom"
29
+ />
11
30
</Sidebar >
12
- <div class =" custom-layout" v-if =" $page.frontmatter.layout" >
31
+
32
+ <div
33
+ class =" custom-layout"
34
+ v-if =" $page.frontmatter.layout"
35
+ >
13
36
<component :is =" $page.frontmatter.layout" />
14
37
</div >
38
+
15
39
<Home v-else-if =" $page.frontmatter.home" />
16
- <Page v-else :sidebar-items =" sidebarItems" >
17
- <slot name =" page-top" slot =" top" />
18
- <slot name =" page-bottom" slot =" bottom" />
40
+
41
+ <Page
42
+ v-else
43
+ :sidebar-items =" sidebarItems"
44
+ >
45
+ <slot
46
+ name =" page-top"
47
+ slot =" top"
48
+ />
49
+ <slot
50
+ name =" page-bottom"
51
+ slot =" bottom"
52
+ />
19
53
</Page >
20
- <SWUpdatePopup :updateEvent =" swUpdateEvent" />
54
+
55
+ <SWUpdatePopup :updateEvent =" swUpdateEvent" />
21
56
</div >
22
57
</template >
23
58
@@ -33,6 +68,7 @@ import { resolveSidebarItems } from './util'
33
68
34
69
export default {
35
70
components: { Home, Page, Sidebar, Navbar, SWUpdatePopup },
71
+
36
72
data () {
37
73
return {
38
74
isSidebarOpen: false ,
@@ -57,6 +93,7 @@ export default {
57
93
this .$themeLocaleConfig .nav
58
94
)
59
95
},
96
+
60
97
shouldShowSidebar () {
61
98
const { frontmatter } = this .$page
62
99
return (
@@ -66,6 +103,7 @@ export default {
66
103
this .sidebarItems .length
67
104
)
68
105
},
106
+
69
107
sidebarItems () {
70
108
return resolveSidebarItems (
71
109
this .$page ,
@@ -74,6 +112,7 @@ export default {
74
112
this .$localePath
75
113
)
76
114
},
115
+
77
116
pageClasses () {
78
117
const userPageClass = this .$page .frontmatter .pageClass
79
118
return [
@@ -112,13 +151,15 @@ export default {
112
151
toggleSidebar (to ) {
113
152
this .isSidebarOpen = typeof to === ' boolean' ? to : ! this .isSidebarOpen
114
153
},
154
+
115
155
// side swipe
116
156
onTouchStart (e ) {
117
157
this .touchStart = {
118
158
x: e .changedTouches [0 ].clientX ,
119
159
y: e .changedTouches [0 ].clientY
120
160
}
121
161
},
162
+
122
163
onTouchEnd (e ) {
123
164
const dx = e .changedTouches [0 ].clientX - this .touchStart .x
124
165
const dy = e .changedTouches [0 ].clientY - this .touchStart .y
@@ -130,6 +171,7 @@ export default {
130
171
}
131
172
}
132
173
},
174
+
133
175
onSWUpdated (e ) {
134
176
this .swUpdateEvent = e
135
177
}
0 commit comments