mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
[Build] revert site to webpack config (#3747)
This commit is contained in:
147
docs/site/components/DemoList.vue
Normal file
147
docs/site/components/DemoList.vue
Normal file
@@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<div class="side-nav">
|
||||
<div class="mobile-switch-lang">
|
||||
<span
|
||||
:class="{ active: $vantLang === 'zh-CN' }"
|
||||
@click="switchLang('zh-CN')"
|
||||
>
|
||||
中文
|
||||
</span>
|
||||
<span
|
||||
:class="{ active: $vantLang === 'en-US' }"
|
||||
@click="switchLang('en-US')"
|
||||
>
|
||||
EN
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 class="vant-title">
|
||||
<img src="https://img.yzcdn.cn/vant/logo.png">
|
||||
<span>Vant</span>
|
||||
</h1>
|
||||
<h2 class="vant-desc">{{ description }}</h2>
|
||||
<template v-for="item in navList">
|
||||
<mobile-nav
|
||||
v-for="(group, index) in item.groups"
|
||||
:group="group"
|
||||
:base="$vantLang"
|
||||
:key="index"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import docConfig from '../doc.config';
|
||||
import MobileNav from './MobileNav';
|
||||
import { setLang } from '../utils/lang';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MobileNav
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
docConfig
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
navList() {
|
||||
return (this.docConfig[this.$vantLang].nav || []).filter(item => item.showInMobile);
|
||||
},
|
||||
|
||||
description() {
|
||||
return this.$vantLang === 'zh-CN' ? '轻量、可靠的移动端 Vue 组件库' : 'Mobile UI Components built on Vue';
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
switchLang(lang) {
|
||||
const from = lang === 'zh-CN' ? 'en-US' : 'zh-CN';
|
||||
this.$router.push(this.$route.path.replace(from, lang));
|
||||
setLang(lang);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../../src/style/var';
|
||||
|
||||
.side-nav {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 64px 20px 20px;
|
||||
|
||||
.vant-title,
|
||||
.vant-desc {
|
||||
padding-left: 15px;
|
||||
font-weight: normal;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.vant-title {
|
||||
margin: 0 0 15px;
|
||||
|
||||
img,
|
||||
span {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 36px;
|
||||
}
|
||||
|
||||
span {
|
||||
margin-left: 15px;
|
||||
font-weight: 500;
|
||||
font-size: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.vant-desc {
|
||||
margin: 0 0 40px;
|
||||
color: #7d7e80;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-switch-lang {
|
||||
position: absolute;
|
||||
top: 24px;
|
||||
right: 24px;
|
||||
overflow: hidden;
|
||||
color: @blue;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
width: 48px;
|
||||
color: @gray-dark;
|
||||
line-height: 22px;
|
||||
text-align: center;
|
||||
background-color: #f7f8fa;
|
||||
border: 1px solid #dcdee0;
|
||||
|
||||
&:first-child {
|
||||
border-right: none;
|
||||
border-radius: 3px 0 0 3px;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-left: none;
|
||||
border-radius: 0 3px 3px 0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: @white;
|
||||
background-color: @blue;
|
||||
border-color: @blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
141
docs/site/components/DemoPages.vue
Normal file
141
docs/site/components/DemoPages.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<section class="van-doc-demo-pages">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<div class="card">
|
||||
<p>{{ $t('description') }}</p>
|
||||
<div class="van-doc-demo-pages__gallery">
|
||||
<div
|
||||
:class="['van-doc-demo-pages__item', { 'van-doc-demo-pages__item--active': index === currentDemo }]"
|
||||
v-for="(demo, index) in demos"
|
||||
>
|
||||
<h4>{{ demo.title }}</h4>
|
||||
<a
|
||||
:href="demo.source"
|
||||
target="_blank"
|
||||
>
|
||||
{{ $t('source') }}
|
||||
</a>
|
||||
<img
|
||||
:src="demo.preview"
|
||||
@click="onChangeDemo(demo, index)"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Locale } from '../../../src';
|
||||
|
||||
Locale.add({
|
||||
'zh-CN': {
|
||||
vanDocDemoPages: {
|
||||
title: '示例',
|
||||
source: '源代码',
|
||||
description: '下面是一些使用 Vant 搭建的示例页面,点击图片切换至对应示例。',
|
||||
goodsDetail: '商品详情',
|
||||
userCenter: '会员中心',
|
||||
shoppingCart: '购物车'
|
||||
}
|
||||
},
|
||||
'en-US': {
|
||||
vanDocDemoPages: {
|
||||
title: 'Demo Pages',
|
||||
source: 'Source code',
|
||||
description: 'Here are some of the demo pages built using Vant, click on the picture to switch to the corresponding demo.',
|
||||
goodsDetail: 'Goods Detail',
|
||||
userCenter: 'User Center',
|
||||
shoppingCart: 'Shopping Cart'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
name: 'van-doc-demo-pages',
|
||||
|
||||
data() {
|
||||
return {
|
||||
currentDemo: 0
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
demos() {
|
||||
return [{
|
||||
title: this.$t('goodsDetail'),
|
||||
preview: 'https://img.yzcdn.cn/public_files/2017/10/24/7070a8d1d6504b864c605114d32f2aae.png',
|
||||
url: 'https://youzan.github.io/vant-demo/#/goods',
|
||||
source: 'https://github.com/youzan/vant-demo/blob/master/base/src/view/goods/index.vue'
|
||||
}, {
|
||||
title: this.$t('userCenter'),
|
||||
preview: 'https://img.yzcdn.cn/public_files/2017/10/23/e1d70757e3ab88d39a360b704be8f43f.png',
|
||||
url: 'https://youzan.github.io/vant-demo/#/user',
|
||||
source: 'https://github.com/youzan/vant-demo/blob/master/base/src/view/user/index.vue'
|
||||
}, {
|
||||
title: this.$t('shoppingCart'),
|
||||
preview: 'https://img.yzcdn.cn/public_files/2017/10/24/06b8b5ed3692314d434db7f6854dcdbe.png',
|
||||
url: 'https://youzan.github.io/vant-demo/#/cart',
|
||||
source: 'https://github.com/youzan/vant-demo/blob/master/base/src/view/cart/index.vue'
|
||||
}];
|
||||
}
|
||||
},
|
||||
|
||||
beforeMount() {
|
||||
this.$emit('changeDemoURL', this.demos[0].url);
|
||||
},
|
||||
|
||||
methods: {
|
||||
onChangeDemo(demo, index) {
|
||||
this.currentDemo = index;
|
||||
this.$emit('changeDemoURL', demo.url);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.van-doc-demo-pages {
|
||||
&__gallery {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
&__item {
|
||||
display: inline-block;
|
||||
width: 28%;
|
||||
margin-bottom: 40px;
|
||||
text-align: center;
|
||||
|
||||
&:nth-child(3n+1),
|
||||
&:nth-child(3n+2) {
|
||||
margin-right: 4%;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a {
|
||||
display: inline-block;
|
||||
margin: 4px 0 7px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&--active {
|
||||
img {
|
||||
box-shadow: 0 1px 4px rgba(51, 136, 255, .4), 0 0 0 1px rgba(51, 136, 255, .4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
71
docs/site/components/MobileNav.vue
Normal file
71
docs/site/components/MobileNav.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<van-collapse
|
||||
v-model="active"
|
||||
:border="false"
|
||||
class="mobile-nav"
|
||||
>
|
||||
<van-collapse-item
|
||||
class="mobile-nav__item"
|
||||
:title="group.groupName"
|
||||
:name="group.groupName"
|
||||
>
|
||||
<van-icon
|
||||
:name="group.icon"
|
||||
slot="right-icon"
|
||||
class="mobile-nav__icon"
|
||||
/>
|
||||
<template v-for="(navItem, index) in group.list">
|
||||
<van-cell
|
||||
v-if="!navItem.disabled"
|
||||
:key="index"
|
||||
:to="'/' + base + navItem.path"
|
||||
:title="navItem.title"
|
||||
is-link
|
||||
/>
|
||||
</template>
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
base: String,
|
||||
group: Object
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: []
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.mobile-nav {
|
||||
&__item {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
font-size: 24px;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.van-collapse-item__content {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.van-collapse-item__title {
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 40px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user