docs: support switch version

This commit is contained in:
陈嘉涵 2019-09-20 16:03:45 +08:00
parent 82fb7c17f5
commit ff894c54b8
2 changed files with 24 additions and 15 deletions

View File

@ -5,12 +5,14 @@
:github="github" :github="github"
:versions="versions" :versions="versions"
:simulator="simulator" :simulator="simulator"
@switch-version="onSwitchVersion"
> >
<router-view /> <router-view />
</van-doc> </van-doc>
</template> </template>
<script> <script>
import pkgJson from '../../package.json';
import docConfig, { github, versions } from './doc.config'; import docConfig, { github, versions } from './doc.config';
const UNSHARED = [ const UNSHARED = [
@ -48,15 +50,23 @@ export default {
return `./preview.html#${path}`; return `./preview.html#${path}`;
} }
},
methods: {
onSwitchVersion(version) {
if (version !== pkgJson.version) {
location.href = `https://youzan.github.io/vant-weapp/${version}`;
}
}
} }
}; };
</script> </script>
<style lang="less"> <style lang="less">
.van-doc-intro { .van-doc-intro {
text-align: center;
padding-top: 20px; 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 { &__logo {
width: 120px; width: 120px;
@ -64,15 +74,15 @@ export default {
} }
h2 { h2 {
font-weight: normal;
font-size: 32px; font-size: 32px;
line-height: 60px; line-height: 60px;
font-weight: normal;
} }
p { p {
font-size: 15px;
color: #455a64;
margin-bottom: 20px; margin-bottom: 20px;
color: #455a64;
font-size: 15px;
} }
} }
</style> </style>

View File

@ -33,17 +33,16 @@ export default {
body { body {
margin: 0; margin: 0;
color: #333; color: #333;
font-family: 'PingFang SC', Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, Arial, sans-serif;
line-height: 1; line-height: 1;
background-color: #f2f3f5; background-color: #f2f3f5;
font-family: 'PingFang SC', Helvetica, 'STHeiti STXihei', 'Microsoft YaHei',
Tohoma, Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
.preview { .preview {
&-image { &-image {
width: 100%;
display: block; display: block;
width: 100%;
&--transition { &--transition {
margin-top: -62px; margin-top: -62px;
@ -51,16 +50,16 @@ body {
} }
&-popup { &-popup {
opacity: 0;
z-index: 1;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
z-index: 1;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: rgba(255, 255, 255, .95);
transition: .3s;
text-align: center; text-align: center;
background-color: rgba(255, 255, 255, .95);
opacity: 0;
transition: .3s;
&:hover { &:hover {
opacity: 1; opacity: 1;
@ -68,27 +67,27 @@ body {
} }
&-content { &-content {
left: 0; position: absolute;
top: 50%; top: 50%;
left: 0;
width: 100%; width: 100%;
height: 200px; height: 200px;
position: absolute;
text-align: center; text-align: center;
transform: translateY(-60%); transform: translateY(-60%);
user-select: none; user-select: none;
img { img {
display: inline-block;
width: 180px; width: 180px;
height: 180px; height: 180px;
margin-bottom: 15px; margin-bottom: 15px;
display: inline-block;
} }
p { p {
margin: 0; margin: 0;
color: #34495e; color: #34495e;
line-height: 1.5;
font-size: 16px; font-size: 16px;
line-height: 1.5;
} }
} }
} }