1
1
<script >
2
2
import AllDemo from ' ../demo'
3
3
import Header from ' ./header'
4
+ import Footer from ' ./footer'
4
5
import zhCN from ' antd/locale-provider/zh_CN'
5
6
import enUS from ' antd/locale-provider/default'
6
7
import sortBy from ' lodash/sortBy'
7
8
import { isZhCN } from ' ../util'
8
9
import { Provider , create } from ' ../../components/_util/store'
9
10
import NProgress from ' nprogress'
10
- import debounce from ' lodash/debounce'
11
- import addDOMEventListener from ' add-dom-event-listener'
12
11
13
12
const docsList = [
14
13
{ key: ' introduce' , enTitle: ' Ant Design of Vue' , title: ' Ant Design of Vue' },
@@ -18,27 +17,6 @@ const docsList = [
18
17
{ key: ' changelog' , enTitle: ' Change Log' , title: ' 更新日志' },
19
18
{ key: ' i18n' , enTitle: ' Internationalization' , title: ' 国际化' },
20
19
]
21
- function getOffsetTop (element , container = window ) {
22
- if (! element) {
23
- return 0
24
- }
25
-
26
- if (! element .getClientRects ().length ) {
27
- return 0
28
- }
29
-
30
- const rect = element .getBoundingClientRect ()
31
-
32
- if (rect .width || rect .height ) {
33
- if (container === window ) {
34
- container = element .ownerDocument .documentElement
35
- return rect .top - container .clientTop
36
- }
37
- return rect .top - container .getBoundingClientRect ().top
38
- }
39
-
40
- return rect .top
41
- }
42
20
43
21
export default {
44
22
props: {
@@ -83,12 +61,6 @@ export default {
83
61
nprogressHiddenStyle .parentNode .removeChild (nprogressHiddenStyle)
84
62
}, 0 )
85
63
}
86
-
87
- this .updateHeight ()
88
- this .debouncedResize = debounce (() => {
89
- this .updateHeight ()
90
- }, 200 )
91
- this .resizeEvent = addDOMEventListener (window , ' resize' , this .debouncedResize )
92
64
})
93
65
},
94
66
watch: {
@@ -98,12 +70,6 @@ export default {
98
70
},
99
71
},
100
72
methods: {
101
- updateHeight () {
102
- const el = this .$refs .sidebar .$el
103
- const offsetTop = getOffsetTop (el)
104
- const docHeight = document .documentElement .offsetHeight
105
- this .sidebarHeight = docHeight - offsetTop
106
- },
107
73
addSubMenu () {
108
74
if (this .$route .path .indexOf (' /docs/vue/' ) !== - 1 ) {
109
75
this .$nextTick (() => {
@@ -141,10 +107,14 @@ export default {
141
107
< / a- anchor>
142
108
)
143
109
},
144
- getDocsMenu (isCN ) {
110
+ getDocsMenu (isCN , pagesKey ) {
145
111
const docsMenu = []
146
- docsList .forEach (({ key, enTitle, title }) => {
112
+ docsList .forEach (({ key, enTitle, title }, index ) => {
147
113
const k = isCN ? ` ${ key} -cn` : key
114
+ pagesKey .push ({ name: k,
115
+ url: ` /ant-design-vue/docs/vue/${ k} /` ,
116
+ title: isCN ? title : enTitle,
117
+ })
148
118
docsMenu .push (< a- menu- item key= {k}>
149
119
< router- link to= {` /ant-design-vue/docs/vue/${ k} /` }> {isCN ? title : enTitle }< / router- link>
150
120
< / a- menu- item> )
@@ -176,7 +146,6 @@ export default {
176
146
render () {
177
147
const name = this .name
178
148
const isCN = isZhCN (name)
179
- // name = name.replace(/-cn\/?$/, '')
180
149
const titleMap = {}
181
150
const menuConfig = {
182
151
General: [],
@@ -187,6 +156,9 @@ export default {
187
156
Feedback: [],
188
157
Other: [],
189
158
}
159
+ const pagesKey = []
160
+ let prevPage = null
161
+ let nextPage = null
190
162
const searchData = []
191
163
for (const [title , d ] of Object .entries (AllDemo)) {
192
164
const type = d .type || ' Other'
@@ -196,14 +168,8 @@ export default {
196
168
menuConfig[type] = menuConfig[type] || []
197
169
menuConfig[type].push (d)
198
170
}
171
+ const docsMenu = this .getDocsMenu (isCN, pagesKey)
199
172
const reName = name .replace (/ -cn\/ ? $ / , ' ' )
200
- // const Demo = new Vue({
201
- // template: '<demo-component/>',
202
- // components: {
203
- // 'demo-component': () => import(`../../components/${AllDemo[titleMap[reName]].key}/demo/index.vue`),
204
- // },
205
- // })
206
- // AllDemo[titleMap[reName]]
207
173
const MenuGroup = []
208
174
for (const [type , menus ] of Object .entries (menuConfig)) {
209
175
const MenuItems = []
@@ -215,6 +181,11 @@ export default {
215
181
if (isCN) {
216
182
key = ` ${ key} -cn`
217
183
}
184
+ pagesKey .push ({
185
+ name: key,
186
+ url: ` /ant-design-vue/components/${ key} /` ,
187
+ title: isCN ? ` ${ title} ${ subtitle} ` : title,
188
+ })
218
189
searchData .push ({
219
190
title,
220
191
subtitle,
@@ -226,29 +197,34 @@ export default {
226
197
})
227
198
MenuGroup .push (< a- menu- item- group title= {type}> {MenuItems}< / a- menu- item- group> )
228
199
}
200
+ pagesKey .forEach ((item , index ) => {
201
+ if (item .name === name) {
202
+ prevPage = pagesKey[index - 1 ]
203
+ nextPage = pagesKey[index + 1 ]
204
+ }
205
+ })
229
206
let locale = zhCN
230
207
if (! isCN) {
231
208
locale = enUS
232
209
}
233
210
const config = AllDemo[titleMap[reName]]
234
211
this .resetDocumentTitle (config, reName, isCN)
235
- const { showSideBars , sidebarHeight } = this
212
+ const { showSideBars } = this
236
213
return (
237
214
< div class = ' page-wrapper' >
238
215
< Header searchData= {searchData} name= {name}/ >
239
216
< a- locale- provider locale= {locale}>
240
217
< div class = ' main-wrapper' >
241
218
< a- row>
242
- < a- col v- show= {showSideBars} style = {{ height : ` ${ sidebarHeight } px ` }} ref= ' sidebar' class = ' site-sidebar' xxl= {4 } xl= {5 } lg= {5 } md= {6 } sm= {8 } xs= {12 }>
219
+ < a- col v- show= {showSideBars} ref= ' sidebar' class = ' site-sidebar' xxl= {4 } xl= {5 } lg= {5 } md= {6 } sm= {8 } xs= {12 }>
243
220
< div class = ' drawer-mask' onClick= {() => { this .showSideBars = false }}>< / div>
244
221
< a- menu
245
-
246
222
class = ' aside-container menu-site'
247
223
selectedKeys= {[name]}
248
224
defaultOpenKeys= {[' Components' ]}
249
225
inlineIndent= {40 }
250
226
mode= ' inline' >
251
- {this . getDocsMenu (isCN) }
227
+ {docsMenu }
252
228
< a- sub- menu title= {` Components(${ searchData .length } )` } key= ' Components' >
253
229
{MenuGroup}
254
230
< / a- sub- menu>
@@ -287,12 +263,15 @@ export default {
287
263
>< / router- view>
288
264
< / div> : ' ' }
289
265
< / div>
266
+ < section class = ' prev-next-nav' >
267
+ {prevPage ? < router- link class = ' prev-page' to= {` ${ prevPage .url } ` }> {prevPage .title }< / router- link> : ' ' }
268
+ {nextPage ? < router- link class = ' next-page' to= {` ${ nextPage .url } ` }> {nextPage .title }< / router- link> : ' ' }
269
+ < / section>
290
270
< / a- col>
291
271
< / a- row>
292
-
293
272
< / div>
294
273
< / a- locale- provider>
295
-
274
+ < Footer ref = ' footer ' isCN = {isCN} / >
296
275
{ name .indexOf (' back-top' ) === - 1 ? < a- back- top / > : null }
297
276
< / div>
298
277
)
0 commit comments