Skip to content

Commit c111330

Browse files
committed
fix: add document title
1 parent 3d24b72 commit c111330

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

components/upload/__tests__/uploadlist.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { mount } from '@vue/test-utils'
22
import Vue from 'vue'
33
import Upload from '..'
4-
import Form from '../../form'
54
import { errorRequest, successRequest } from './requests'
65
import PropsTypes from '../../_util/vue-types'
76
import { UploadListProps } from '../interface'

site/components/layout.vue

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ import _ from 'lodash'
77
import { isZhCN } from '../util'
88
import { Provider, create } from '../../components/_util/store'
99
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+
1019
export default {
1120
props: {
1221
name: String,
@@ -82,23 +91,31 @@ export default {
8291
)
8392
},
8493
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-
]
9394
const docsMenu = []
94-
docs.forEach(({ key, enTitle, title }) => {
95+
docsList.forEach(({ key, enTitle, title }) => {
9596
const k = isCN ? `${key}-cn` : key
9697
docsMenu.push(<a-menu-item key={k}>
9798
<router-link to={`/ant-design/docs/vue/${k}/`}>{isCN ? title : enTitle }</router-link>
9899
</a-menu-item>)
99100
})
100101
return docsMenu
101102
},
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+
},
102119
},
103120
render () {
104121
const name = this.name
@@ -122,7 +139,8 @@ export default {
122139
menuConfig[type] = menuConfig[type] || []
123140
menuConfig[type].push(d)
124141
}
125-
const Demo = AllDemo[titleMap[name.replace(/-cn\/?$/, '')]]
142+
const reName = name.replace(/-cn\/?$/, '')
143+
const Demo = AllDemo[titleMap[reName]]
126144
const MenuGroup = []
127145
for (const [type, menus] of Object.entries(menuConfig)) {
128146
const MenuItems = []
@@ -149,6 +167,7 @@ export default {
149167
if (!isCN) {
150168
locale = enUS
151169
}
170+
this.resetDocumentTitle(Demo, reName, isCN)
152171
return (
153172
<div class='page-wrapper'>
154173
<Header searchData={searchData} name={name}/>

0 commit comments

Comments
 (0)