2018-04-04 10:39:21 +00:00
|
|
|
<script>
|
|
|
|
import { isZhCN } from '../util'
|
2018-07-14 09:10:50 +00:00
|
|
|
import sortBy from 'lodash/sortBy'
|
2018-09-22 13:28:36 +00:00
|
|
|
import packageInfo from '../../package.json'
|
|
|
|
|
2018-04-04 10:39:21 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
2018-04-09 14:49:58 +00:00
|
|
|
name: String,
|
2018-04-11 05:32:18 +00:00
|
|
|
searchData: Array,
|
2018-04-04 10:39:21 +00:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2018-04-11 05:32:18 +00:00
|
|
|
value: null,
|
2018-04-04 10:39:21 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleClick () {
|
2018-04-09 14:49:58 +00:00
|
|
|
const name = this.name
|
|
|
|
const path = this.$route.path
|
|
|
|
const newName = isZhCN(name) ? name.replace(/-cn\/?$/, '') : `${name}-cn`
|
2018-04-04 10:39:21 +00:00
|
|
|
this.$router.push({
|
2018-04-09 14:49:58 +00:00
|
|
|
path: path.replace(name, newName),
|
2018-04-04 10:39:21 +00:00
|
|
|
})
|
2018-11-27 10:25:38 +00:00
|
|
|
this.$i18n.locale = isZhCN(name) ? 'en-US' : 'zh-CN'
|
2018-04-04 10:39:21 +00:00
|
|
|
},
|
2018-04-11 05:32:18 +00:00
|
|
|
onSelect (val) {
|
|
|
|
this.$router.push(val)
|
|
|
|
this.value = val
|
|
|
|
},
|
2018-04-04 10:39:21 +00:00
|
|
|
},
|
|
|
|
render () {
|
2018-04-09 14:49:58 +00:00
|
|
|
const name = this.name
|
2018-07-14 09:10:50 +00:00
|
|
|
const searchData = sortBy(this.searchData, ['title'])
|
2018-04-04 10:39:21 +00:00
|
|
|
const isCN = isZhCN(name)
|
|
|
|
return (
|
|
|
|
<header id='header'>
|
|
|
|
<a-row>
|
2018-08-05 14:25:51 +00:00
|
|
|
<a-col class='header-left' xxl={4} xl={5} lg={5} md={6} sm={24} xs={24}>
|
2018-08-04 09:52:11 +00:00
|
|
|
<router-link to={{ path: '/ant-design-vue' }} id='logo'>
|
|
|
|
<img alt='logo' height='32' src='https://raw.githubusercontent.com/vueComponent/ant-design-vue/master/logo.png' />
|
2018-08-10 06:52:26 +00:00
|
|
|
<span style='color: black;font-size: 16px;font-weight: 400;'>Ant Design Vue</span>
|
2018-04-04 10:39:21 +00:00
|
|
|
</router-link>
|
2018-08-05 14:25:51 +00:00
|
|
|
<a-button ghost size='small' onClick={this.handleClick} class='header-lang-button' key='lang-button'>
|
|
|
|
{isCN ? 'English' : '中文'}
|
|
|
|
</a-button>
|
2018-04-04 10:39:21 +00:00
|
|
|
</a-col>
|
|
|
|
<a-col xxl={20} xl={19} lg={19} md={18} sm={0} xs={0}>
|
2018-04-11 05:32:18 +00:00
|
|
|
<div id='search-box' style='display: block'>
|
|
|
|
<a-icon type='search' />
|
|
|
|
<a-select
|
|
|
|
ref='selectBox'
|
|
|
|
placeholder={isCN ? '搜索组件...' : 'input search text'}
|
|
|
|
style='width: 200px'
|
|
|
|
defaultActiveFirstOption={false}
|
|
|
|
showArrow={false}
|
|
|
|
showSearch
|
|
|
|
onSelect={this.onSelect}
|
|
|
|
optionFilterProp='children'
|
|
|
|
key={this.value}
|
|
|
|
>
|
|
|
|
{
|
|
|
|
searchData.map(({ title, subtitle, url }) =>
|
|
|
|
<a-select-option key={url}>
|
|
|
|
{title} {isCN && subtitle}
|
|
|
|
</a-select-option>)
|
|
|
|
}
|
|
|
|
</a-select>
|
2018-04-04 10:39:21 +00:00
|
|
|
</div>
|
|
|
|
<a-button ghost size='small' onClick={this.handleClick} class='header-lang-button' key='lang-button'>
|
|
|
|
{isCN ? 'English' : '中文'}
|
|
|
|
</a-button>
|
2018-09-22 13:28:36 +00:00
|
|
|
<a-select size='small' defaultValue={packageInfo.version} class='version'>
|
|
|
|
<a-select-option value={packageInfo.version}>{packageInfo.version}</a-select-option>
|
|
|
|
</a-select>
|
2018-04-04 10:39:21 +00:00
|
|
|
<a-menu selectedKeys={['components']} mode='horizontal' class='menu-site' id='nav'>
|
|
|
|
<a-menu-item key='components'>
|
|
|
|
{isCN ? '组件' : 'Components'}
|
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key='github'>
|
2018-08-04 09:52:11 +00:00
|
|
|
<a href='https://github.com/vueComponent/ant-design-vue'>GitHub</a>
|
2018-04-04 10:39:21 +00:00
|
|
|
</a-menu-item>
|
2018-12-14 13:35:19 +00:00
|
|
|
<a-menu-item key='sponsor'>
|
|
|
|
<router-link to={{ path: '/ant-design-vue/docs/vue/sponsor' }}>
|
|
|
|
{isCN ? '赞助我们' : 'Sponsor'}
|
|
|
|
</router-link>
|
|
|
|
</a-menu-item>
|
2018-04-04 10:39:21 +00:00
|
|
|
</a-menu>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</header>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|