@@ -7,6 +7,15 @@ import _ from 'lodash'
7
7
import { isZhCN } from ' ../util'
8
8
import { Provider , create } from ' ../../components/_util/store'
9
9
10
+ const docsList = [
11
+ { key: ' introduce' , enTitle: ' Ant Design of Vue' , title: ' Ant Design of Vue' },
12
+ { key: ' getting-started' , enTitle: ' Getting Started' , title: ' 快速上手' },
13
+ { key: ' use-with-vue-cli' , enTitle: ' Use in vue-cli' , title: ' 在 vue-cli 中使用' },
14
+ { key: ' customize-theme' , enTitle: ' Customize Theme' , title: ' 定制主题' },
15
+ { key: ' changelog' , enTitle: ' Change Log' , title: ' 更新日志' },
16
+ { key: ' i18n' , enTitle: ' Internationalization' , title: ' 国际化' },
17
+ ]
18
+
10
19
export default {
11
20
props: {
12
21
name: String ,
@@ -82,23 +91,31 @@ export default {
82
91
)
83
92
},
84
93
getDocsMenu (isCN ) {
85
- const docs = [
86
- { key: ' introduce' , enTitle: ' Ant Design of Vue' , title: ' Ant Design of Vue' },
87
- { key: ' getting-started' , enTitle: ' Getting Started' , title: ' 快速上手' },
88
- { key: ' use-with-vue-cli' , enTitle: ' Use in vue-cli' , title: ' 在 vue-cli 中使用' },
89
- { key: ' customize-theme' , enTitle: ' Customize Theme' , title: ' 定制主题' },
90
- { key: ' changelog' , enTitle: ' Change Log' , title: ' 更新日志' },
91
- { key: ' i18n' , enTitle: ' Internationalization' , title: ' 国际化' },
92
- ]
93
94
const docsMenu = []
94
- docs .forEach (({ key, enTitle, title }) => {
95
+ docsList .forEach (({ key, enTitle, title }) => {
95
96
const k = isCN ? ` ${ key} -cn` : key
96
97
docsMenu .push (< a- menu- item key= {k}>
97
98
< router- link to= {` /ant-design/docs/vue/${ k} /` }> {isCN ? title : enTitle }< / router- link>
98
99
< / a- menu- item> )
99
100
})
100
101
return docsMenu
101
102
},
103
+ resetDocumentTitle (component , name , isCN ) {
104
+ let titleStr = ' Vue Antd'
105
+ if (component) {
106
+ const { subtitle , title } = component
107
+ const componentName = isCN ? subtitle + ' ' + title : title
108
+ titleStr = componentName + ' - ' + titleStr
109
+ } else {
110
+ const currentKey = docsList .filter ((item ) => {
111
+ return item .key === name
112
+ })
113
+ if (currentKey .length ) {
114
+ titleStr = (isCN ? currentKey[0 ][' title' ] : currentKey[0 ][' enTitle' ]) + ' - ' + titleStr
115
+ }
116
+ }
117
+ document .title = titleStr
118
+ },
102
119
},
103
120
render () {
104
121
const name = this .name
@@ -122,7 +139,8 @@ export default {
122
139
menuConfig[type] = menuConfig[type] || []
123
140
menuConfig[type].push (d)
124
141
}
125
- const Demo = AllDemo[titleMap[name .replace (/ -cn\/ ? $ / , ' ' )]]
142
+ const reName = name .replace (/ -cn\/ ? $ / , ' ' )
143
+ const Demo = AllDemo[titleMap[reName]]
126
144
const MenuGroup = []
127
145
for (const [type , menus ] of Object .entries (menuConfig)) {
128
146
const MenuItems = []
@@ -149,6 +167,7 @@ export default {
149
167
if (! isCN) {
150
168
locale = enUS
151
169
}
170
+ this .resetDocumentTitle (Demo, reName, isCN)
152
171
return (
153
172
< div class = ' page-wrapper' >
154
173
< Header searchData= {searchData} name= {name}/ >
0 commit comments