2018-04-04 18:39:21 +08:00
|
|
|
<script>
|
2019-01-12 11:33:27 +08:00
|
|
|
import { isZhCN } from '../util';
|
|
|
|
import sortBy from 'lodash/sortBy';
|
|
|
|
import packageInfo from '../../package.json';
|
2019-02-16 14:32:46 +08:00
|
|
|
import logo from '../logo.svg';
|
|
|
|
import antDesignVue from '../ant-design-vue.svg';
|
2018-09-22 21:28:36 +08:00
|
|
|
|
2018-04-04 18:39:21 +08:00
|
|
|
export default {
|
|
|
|
props: {
|
2018-04-09 22:49:58 +08:00
|
|
|
name: String,
|
2018-04-11 13:32:18 +08:00
|
|
|
searchData: Array,
|
2018-04-04 18:39:21 +08:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2018-04-11 13:32:18 +08:00
|
|
|
value: null,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-04-04 18:39:21 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleClick () {
|
2019-01-12 11:33:27 +08:00
|
|
|
const name = this.name;
|
|
|
|
const path = this.$route.path;
|
|
|
|
const newName = isZhCN(name) ? name.replace(/-cn\/?$/, '') : `${name}-cn`;
|
2018-04-04 18:39:21 +08:00
|
|
|
this.$router.push({
|
2018-04-09 22:49:58 +08:00
|
|
|
path: path.replace(name, newName),
|
2019-01-12 11:33:27 +08:00
|
|
|
});
|
|
|
|
this.$i18n.locale = isZhCN(name) ? 'en-US' : 'zh-CN';
|
2018-04-04 18:39:21 +08:00
|
|
|
},
|
2018-04-11 13:32:18 +08:00
|
|
|
onSelect (val) {
|
2019-01-12 11:33:27 +08:00
|
|
|
this.$router.push(val);
|
|
|
|
this.value = val;
|
2018-04-11 13:32:18 +08:00
|
|
|
},
|
2018-04-04 18:39:21 +08:00
|
|
|
},
|
|
|
|
render () {
|
2019-01-12 11:33:27 +08:00
|
|
|
const name = this.name;
|
|
|
|
const searchData = sortBy(this.searchData, ['title']);
|
|
|
|
const isCN = isZhCN(name);
|
2018-04-04 18:39:21 +08:00
|
|
|
return (
|
|
|
|
<header id='header'>
|
|
|
|
<a-row>
|
2018-08-05 22:25:51 +08:00
|
|
|
<a-col class='header-left' xxl={4} xl={5} lg={5} md={6} sm={24} xs={24}>
|
2019-02-16 16:51:21 +08:00
|
|
|
<router-link to={{ path: '/' }} id='logo'>
|
2019-02-16 14:32:46 +08:00
|
|
|
<img alt='logo' height='32' src={logo} />
|
|
|
|
<img alt='logo' height='16' src={antDesignVue} />
|
2018-04-04 18:39:21 +08:00
|
|
|
</router-link>
|
2018-08-05 22:25:51 +08:00
|
|
|
<a-button ghost size='small' onClick={this.handleClick} class='header-lang-button' key='lang-button'>
|
|
|
|
{isCN ? 'English' : '中文'}
|
|
|
|
</a-button>
|
2018-04-04 18:39:21 +08:00
|
|
|
</a-col>
|
|
|
|
<a-col xxl={20} xl={19} lg={19} md={18} sm={0} xs={0}>
|
2019-01-12 17:19:57 +08:00
|
|
|
<div id='search-box'>
|
2018-04-11 13:32:18 +08:00
|
|
|
<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 18:39:21 +08:00
|
|
|
</div>
|
|
|
|
<a-button ghost size='small' onClick={this.handleClick} class='header-lang-button' key='lang-button'>
|
|
|
|
{isCN ? 'English' : '中文'}
|
|
|
|
</a-button>
|
2018-09-22 21:28:36 +08: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 18:39:21 +08:00
|
|
|
<a-menu selectedKeys={['components']} mode='horizontal' class='menu-site' id='nav'>
|
|
|
|
<a-menu-item key='components'>
|
|
|
|
{isCN ? '组件' : 'Components'}
|
|
|
|
</a-menu-item>
|
2019-01-12 17:19:57 +08:00
|
|
|
<a-sub-menu key="Ecosystem" title={isCN ? '生态系统' : 'Ecosystem'}>
|
|
|
|
<a-menu-item key="design">
|
2019-02-16 16:51:21 +08:00
|
|
|
<router-link to={{ path: isCN ? '/docs/vue/download-cn/' : '/docs/vue/download/'}}>
|
2019-01-12 17:19:57 +08:00
|
|
|
{isCN ? '设计资源' : 'Design Resources'}
|
|
|
|
</router-link>
|
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key="vscode">
|
|
|
|
<a target="_blank" href='https://marketplace.visualstudio.com/items?itemName=ant-design-vue.vscode-ant-design-vue-helper'>
|
|
|
|
VS Code Extension
|
2018-12-16 14:22:18 +08:00
|
|
|
</a>
|
2019-01-12 17:19:57 +08:00
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key="awesome">
|
|
|
|
<a target="_blank" href='https://github.com/vueComponent/ant-design-vue-awesome'>
|
|
|
|
Awesome
|
|
|
|
</a>
|
|
|
|
</a-menu-item>
|
2019-01-26 16:04:32 +08:00
|
|
|
<a-menu-item key="github">
|
|
|
|
<a target="_blank" href='https://github.com/vueComponent/ant-design-vue'>GitHub</a>
|
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key='wechat'>
|
|
|
|
<a-popover placement='right'>
|
|
|
|
<template slot='content'>
|
|
|
|
<img
|
|
|
|
width='160'
|
|
|
|
height='160'
|
|
|
|
alt='wechat'
|
2019-02-16 16:51:21 +08:00
|
|
|
src='https://cdn.nlark.com/yuque/0/2019/jpeg/87084/1550303926433-assets/web-upload/3bf5b121-fea2-44bb-9ef9-0d61616c85e3.jpeg'
|
2019-01-26 16:04:32 +08:00
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<a>
|
|
|
|
{isCN ? '微信' : 'WeChat'}
|
|
|
|
</a>
|
|
|
|
</a-popover>
|
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key='qq'>
|
|
|
|
<a-popover placement='right'>
|
2019-01-12 17:19:57 +08:00
|
|
|
<template slot='content'>
|
|
|
|
<img
|
|
|
|
width='160'
|
2019-01-26 16:04:32 +08:00
|
|
|
height='160'
|
|
|
|
alt='qq'
|
|
|
|
src='https://cdn.nlark.com/yuque/0/2019/png/87084/1548484520571-assets/web-upload/ca2259e1-6600-461b-8c5b-31018e8bcc07.png'
|
2019-01-12 17:19:57 +08:00
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<a>
|
2019-01-26 16:04:32 +08:00
|
|
|
{isCN ? 'QQ(217490093)' : 'QQ(217490093)'}
|
2019-01-12 17:19:57 +08:00
|
|
|
</a>
|
|
|
|
</a-popover>
|
|
|
|
</a-menu-item>
|
|
|
|
</a-sub-menu>
|
|
|
|
<a-menu-item key="sponsor">
|
2019-02-16 16:51:21 +08:00
|
|
|
<router-link to={{ path: isCN ? '/docs/vue/sponsor-cn/' : '/docs/vue/sponsor/'}}>
|
2019-01-12 17:19:57 +08:00
|
|
|
{isCN ? '支持我们' : 'Support us'}
|
|
|
|
</router-link>
|
2018-12-14 21:35:19 +08:00
|
|
|
</a-menu-item>
|
2018-04-04 18:39:21 +08:00
|
|
|
</a-menu>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</header>
|
2019-01-12 11:33:27 +08:00
|
|
|
);
|
2018-04-04 18:39:21 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-04-04 18:39:21 +08:00
|
|
|
</script>
|