mirror of
https://github.com/youzan/vant.git
synced 2026-04-01 02:01:29 +08:00
[Doc] support pick document version
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
<van-doc
|
||||
:base="base"
|
||||
:config="config"
|
||||
active="Vue 组件"
|
||||
:lang="$vantLang"
|
||||
:github="github"
|
||||
:versions="versions"
|
||||
:simulators="simulators"
|
||||
:search-config="searchConfig"
|
||||
:current-simulator="currentSimulator"
|
||||
@switch-version="onSwitchVersion"
|
||||
>
|
||||
<router-view @changeDemoURL="onChangeDemoURL" />
|
||||
</van-doc>
|
||||
@@ -15,11 +17,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import docConfig from './doc.config';
|
||||
import pkgJson from '../../package.json';
|
||||
import docConfig, { github, versions, searchConfig } from './doc.config';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
this.searchConfig = docConfig.searchConfig;
|
||||
this.github = github;
|
||||
this.versions = versions;
|
||||
this.searchConfig = searchConfig;
|
||||
|
||||
return {
|
||||
simulators: [`mobile.html${location.hash}`],
|
||||
demoURL: ''
|
||||
@@ -44,6 +50,12 @@ export default {
|
||||
methods: {
|
||||
onChangeDemoURL(url) {
|
||||
this.simulators = [this.simulators[0], url];
|
||||
},
|
||||
|
||||
onSwitchVersion(version) {
|
||||
if (version !== pkgJson.version) {
|
||||
location.href = `https://youzan.github.io/vant/${version}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -52,7 +64,7 @@ export default {
|
||||
<style lang="less">
|
||||
.van-doc-intro {
|
||||
padding-top: 20px;
|
||||
font-family: "Dosis", "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
|
||||
font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
|
||||
text-align: center;
|
||||
|
||||
&__logo {
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
/* eslint-disable */
|
||||
const version = require('../../package.json').version;
|
||||
import pkgJson from '../../package.json';
|
||||
|
||||
module.exports = {
|
||||
searchConfig: {
|
||||
apiKey: '90067aecdaa2c85220e2783cd305caac',
|
||||
indexName: 'vant',
|
||||
},
|
||||
const { version } = pkgJson;
|
||||
|
||||
export const searchConfig = {
|
||||
apiKey: '90067aecdaa2c85220e2783cd305caac',
|
||||
indexName: 'vant'
|
||||
};
|
||||
|
||||
export const versions = [version, '1.x'];
|
||||
|
||||
export const github = 'https://github.com/youzan/vant';
|
||||
|
||||
export default {
|
||||
'zh-CN': {
|
||||
header: {
|
||||
logo: {
|
||||
@@ -18,8 +24,7 @@ module.exports = {
|
||||
text: 'En',
|
||||
from: 'zh-CN',
|
||||
to: 'en-US'
|
||||
},
|
||||
github: 'https://github.com/youzan/vant'
|
||||
}
|
||||
}
|
||||
},
|
||||
nav: [
|
||||
@@ -343,7 +348,8 @@ module.exports = {
|
||||
'en-US': {
|
||||
header: {
|
||||
logo: {
|
||||
image: 'https://img.yzcdn.cn/public_files/2017/12/18/fd78cf6bb5d12e2a119d0576bedfd230.png',
|
||||
image:
|
||||
'https://img.yzcdn.cn/public_files/2017/12/18/fd78cf6bb5d12e2a119d0576bedfd230.png',
|
||||
title: 'Vant',
|
||||
href: '#/'
|
||||
},
|
||||
@@ -352,8 +358,7 @@ module.exports = {
|
||||
text: '中文',
|
||||
from: 'en-US',
|
||||
to: 'zh-CN'
|
||||
},
|
||||
github: 'https://github.com/youzan/vant'
|
||||
}
|
||||
}
|
||||
},
|
||||
nav: [
|
||||
|
||||
Reference in New Issue
Block a user