Compare commits

...

6 Commits

Author SHA1 Message Date
chenjiahan
e9bab1bc39 chore: remove unused site files 2021-04-11 16:30:58 +08:00
chenjiahan
8d01c3c641 chore: remove unused deps 2021-04-11 16:30:58 +08:00
chenjiahan
edae2e3ad1 build: update release script 2021-04-11 16:30:58 +08:00
chenjiahan
2417219266 build: update husky config 2021-04-11 16:30:58 +08:00
chenjiahan
ce3193a245 docs: update vant config 2021-04-11 16:30:58 +08:00
chenjiahan
da2e0faaec docs: using @vant/cli to build site 2021-04-11 16:30:58 +08:00
21 changed files with 6655 additions and 3498 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
.idea
.vscode
node_modules
site
docs/dist
example/dist
.history

1
.husky/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
_

4
.husky/commit-msg Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install vant-cli commit-lint $1

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install lint-staged

View File

@ -4,9 +4,8 @@ module.exports = {
'@babel/preset-env',
{
loose: true,
modules: false
}
]
modules: false,
},
],
],
plugins: ['@babel/plugin-syntax-dynamic-import']
};

View File

@ -1,12 +1,15 @@
const path = require('path');
const serve = require('webpack-serve');
const config = require('./webpack.doc.dev');
const { dev } = require('@vant/cli');
const { exec } = require('child_process');
const gulpConfig = path.resolve(__dirname, './compiler.js');
serve({}, { config });
async function run() {
await dev();
const p = exec(`npx gulp -f ${gulpConfig} buildExample --color`);
p.stdout.on('data', (stdout) => console.info(stdout));
p.stderr.on('data', (stderr) => console.info(stderr));
const p = exec(`npx gulp -f ${gulpConfig} buildExample --color`);
p.stdout.on('data', (stdout) => console.info(stdout));
p.stderr.on('data', (stderr) => console.info(stderr));
}
run();

View File

@ -1,10 +0,0 @@
#!/usr/bin/env sh
rm -rf docs/dist
npx cross-env NODE_ENV=production webpack --config build/webpack.doc.prd.js
superman-cdn /vant-weapp ./docs/dist/*.js
rm -rf docs/dist/*.js
gh-pages -d docs/dist --add

View File

@ -36,4 +36,7 @@ then
git checkout dev
git rebase master
git push origin dev
# changelog
vant-cli changelog
fi

View File

@ -1,81 +0,0 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const { VueLoaderPlugin } = require('vue-loader');
module.exports = {
mode: 'development',
entry: {
'vant-docs': './docs/src/index.js',
'vant-preview': './docs/src/preview.js',
},
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: '/',
chunkFilename: 'async_[name].js',
},
stats: {
modules: false,
children: false,
},
serve: {
open: true,
host: '0.0.0.0',
devMiddleware: {
logLevel: 'warn',
},
hotClient: {
logLevel: 'warn',
allEntries: true,
},
},
resolve: {
extensions: ['.js', '.vue', '.css'],
},
module: {
rules: [
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false,
},
},
},
],
},
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.(css|less)$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'],
},
{
test: /\.md$/,
use: ['vue-loader', '@vant/markdown-loader'],
},
],
},
plugins: [
new VueLoaderPlugin(),
new ProgressBarPlugin(),
new HtmlWebpackPlugin({
chunks: ['vant-docs'],
template: 'docs/src/index.tpl',
filename: 'index.html',
inject: true,
}),
new HtmlWebpackPlugin({
chunks: ['vant-preview'],
template: 'docs/src/index.tpl',
filename: 'preview.html',
inject: true,
}),
],
};

View File

@ -1,14 +0,0 @@
const path = require('path');
const config = require('./webpack.doc.dev.js');
delete config.serve;
module.exports = Object.assign(config, {
mode: 'production',
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: 'https://b.yzcdn.cn/vant-weapp/',
filename: '[name].[hash:8].js',
chunkFilename: 'async_[name].[chunkhash:8].js',
},
});

View File

@ -1,85 +0,0 @@
<template>
<van-doc
active="小程序组件"
:config="config"
:github="github"
:versions="versions"
:simulator="simulator"
@switch-version="onSwitchVersion"
>
<router-view />
</van-doc>
</template>
<script>
import pkgJson from '../../package.json';
import docConfig, { github, versions } from './doc.config';
const UNSHARED = ['common', 'quickstart', 'changelog', 'intro', 'transition'];
export default {
data() {
return {
github,
versions,
};
},
computed: {
config() {
return docConfig;
},
simulator() {
let prefix = '';
const { path } = this.$route.meta;
if (
location.hostname === '0.0.0.0' ||
location.hostname === 'localhost'
) {
prefix = 'https://youzan.github.io';
}
if (!UNSHARED.includes(path)) {
return `${prefix}/vant/mobile.html?hide_nav=1&weapp=1#/zh-CN/${path}`;
}
return `./preview.html#${path}`;
},
},
methods: {
onSwitchVersion(version) {
if (version !== pkgJson.version) {
location.href = `https://youzan.github.io/vant-weapp/${version}`;
}
},
},
};
</script>
<style lang="less">
.van-doc-intro {
padding-top: 20px;
font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
text-align: center;
&__logo {
width: 120px;
height: 120px;
}
h2 {
font-weight: normal;
font-size: 32px;
line-height: 60px;
}
p {
margin-bottom: 20px;
color: #455a64;
font-size: 15px;
}
}
</style>

View File

@ -1,99 +0,0 @@
<template>
<div>
<img
:class="['preview-image', `preview-image--${imageName}`]"
:src="image"
/>
<div class="preview-popup">
<div class="preview-content">
<img src="https://img.yzcdn.cn/vant-weapp/qrcode-201808101114.jpg" />
<p>微信扫码体验</p>
</div>
</div>
</div>
</template>
<script>
const PREFIX = 'https://img.yzcdn.cn/vant-weapp/';
const MAP = {
index: 'index-20190715.png',
transition: 'transition-20180821.png',
};
export default {
computed: {
imageName() {
return location.hash.slice(1);
},
image() {
return PREFIX + (MAP[this.imageName] || MAP.index);
},
},
};
</script>
<style lang="less">
body {
margin: 0;
color: #323233;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB',
'Microsoft Yahei', sans-serif;
line-height: 1;
background-color: #f7f8fa;
-webkit-font-smoothing: antialiased;
}
.preview {
&-image {
display: block;
width: 100%;
&--transition {
margin-top: -62px;
}
}
&-popup {
position: fixed;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
text-align: center;
background-color: rgba(255, 255, 255, 0.95);
opacity: 0;
transition: 0.3s;
&:hover {
opacity: 1;
}
}
&-content {
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 200px;
text-align: center;
transform: translateY(-60%);
user-select: none;
img {
display: inline-block;
width: 180px;
height: 180px;
margin-bottom: 15px;
}
p {
margin: 0;
color: #34495e;
font-size: 16px;
line-height: 1.5;
}
}
}
</style>

View File

@ -1,74 +0,0 @@
/* eslint-disable */
import packageJson from '../../package.json';
import components from '../../example/config';
const { version } = packageJson;
export const github = 'https://github.com/youzan/vant-weapp';
export const versions = [version, '0.x'];
export default {
header: {
logo: {
image: 'https://img.yzcdn.cn/vant/logo.png',
title: 'Vant Weapp',
href: '#/',
},
nav: {
logoLink: [
{
image: 'https://img.yzcdn.cn/vant/vant-o.svg',
url: '/vant',
},
{
image: 'https://img.yzcdn.cn/vant/logo/github.svg',
url: github,
},
],
},
},
nav: [
{
name: '开发指南',
groups: [
{
list: [
{
path: '/intro',
title: '介绍',
md: true,
},
{
path: '/quickstart',
title: '快速上手',
md: true,
},
{
path: '/changelog',
title: '更新日志',
md: true,
},
{
path: '/common',
title: '内置样式',
},
{
path: '/custom-style',
title: '样式覆盖',
md: true,
},
{
path: '/theme',
title: '定制主题',
md: true,
},
],
},
],
},
{
name: '组件',
groups: components,
},
],
};

View File

@ -1,55 +0,0 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './App';
import routes from './router';
import VantDoc from '@vant/doc';
Vue.use(VueRouter).use(VantDoc);
const router = new VueRouter({
mode: 'hash',
routes: routes(),
scrollBehavior(to) {
if (to.hash) {
return { selector: to.hash };
}
return { x: 0, y: 0 };
},
});
const ua = navigator.userAgent.toLowerCase();
const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
router.beforeEach((route, redirect, next) => {
if (isMobile) {
location.replace('/vant/mobile.html?weapp=1');
}
next();
});
router.afterEach(() => {
window.scrollTo(0, 0);
});
Vue.config.productionTip = false;
new Vue({
el: '#app',
mounted() {
setTimeout(() => {
// wait page init
if (this.$route.hash) {
const el = document.querySelector(this.$route.hash);
if (el) {
el.scrollIntoView({
behavior: 'smooth',
});
}
}
}, 1000);
},
render: (h) => h(App),
router,
});

View File

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-Equiv="Cache-Control" Content="no-cache" />
<meta http-Equiv="Pragma" Content="no-cache" />
<meta http-Equiv="Expires" Content="0" />
<link rel="shortcut icon" href="https://img.yzcdn.cn/zanui/vant/vant-2017-12-18.ico">
<title>Vant Weapp - 轻量、可靠的小程序 UI 组件库</title>
<script>window.Promise || document.write('<script src="//img.yzcdn.cn/huiyi/build/h5/js/pinkie.min.js"><\/script>');</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?ad6b5732c36321f2dafed737ac2da92f";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body ontouchstart>
<div id="app"></div>
</body>
</html>

View File

@ -1,9 +0,0 @@
import Vue from 'vue';
import Preview from './Preview.vue';
Vue.config.productionTip = false;
new Vue({
el: '#app',
render: (h) => h(Preview),
});

View File

@ -1,52 +0,0 @@
import docConfig from './doc.config';
const registerRoute = () => {
const route = [
{
path: '*',
redirect: () => `/intro`,
},
];
const navs = docConfig.nav || [];
function addRoute(page) {
let { path } = page;
if (path) {
path = path.replace('/', '');
const component = () =>
page.md
? import(`../markdown/${path}.md`)
: import(`../../packages/${path}/README.md`);
if (!component) {
return;
}
route.push({
name: '/' + path,
component,
path: `/${path}`,
meta: {
path,
name: page.title,
},
});
}
}
navs.forEach((nav) => {
if (nav.groups) {
nav.groups.forEach((group) => {
group.list.forEach((page) => addRoute(page));
});
} else {
addRoute(nav);
}
});
return route;
};
export default registerRoute;

View File

@ -11,10 +11,11 @@
"scripts": {
"dev": "node build/dev.js",
"lint": "eslint ./packages --ext .js,.ts --fix && stylelint \"packages/**/*.less\" --fix",
"prepare": "husky install",
"release": "sh build/release.sh",
"release:site": "sh build/release-site.sh",
"release:site": "vant-cli build-site && gh-pages -d site --add",
"build:lib": "yarn && npx gulp -f build/compiler.js --series buildEs buildLib",
"build:changelog": "vant changelog --tag v1.3.0 ./docs/markdown/changelog.generated.md",
"build:changelog": "vant-cli changelog",
"upload:weapp": "node build/upload.js"
},
"files": [
@ -25,12 +26,6 @@
"type": "git",
"url": "git+ssh://git@github.com/youzan/vant-weapp.git"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "vant commit-lint"
}
},
"lint-staged": {
"*.{ts,js}": [
"eslint --fix",
@ -43,48 +38,19 @@
},
"homepage": "https://github.com/youzan/vant-weapp#readme",
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.5.5",
"@vant/cli": "^1.0.3",
"@vant/doc": "^2.5.5",
"@vant/eslint-config": "^2.2.2",
"@vant/cli": "^3.10.0",
"@vant/icons": "1.5.2",
"@vant/markdown-loader": "^2.3.0",
"@vant/stylelint-config": "^1.3.0",
"autoprefixer": "^10.0.0",
"babel-loader": "^8.0.0",
"cross-env": "^7.0.0",
"css-loader": "^5.0.0",
"cssnano": "^4.1.10",
"eslint": "^6.1.0",
"gh-pages": "^3.0.0",
"gulp": "^4.0.2",
"gulp-insert": "^0.5.0",
"gulp-less": "^4.0.1",
"gulp-postcss": "^9.0.0",
"gulp-rename": "^2.0.0",
"html-webpack-plugin": "^4.0.0",
"less": "^3.9.0",
"less-loader": "^7.0.0",
"lint-staged": "^10.0.0",
"miniprogram-api-typings": "^3.1.6",
"miniprogram-ci": "^1.0.27",
"postcss": "^8.1.1",
"postcss-loader": "^4.0.0",
"prettier": "^2.0.5",
"progress-bar-webpack-plugin": "^2.0.0",
"style-loader": "^2.0.0",
"stylelint": "^13.0.0",
"less": "^3.0.0",
"tscpaths": "^0.0.9",
"typescript": "^4.0.0",
"vue": "2.6.10",
"vue-loader": "^15.7.1",
"vue-router": "^3.1.1",
"vue-template-compiler": "2.6.10",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.6",
"webpack-serve": "^2.0.3"
"vue": "^3.0.0",
"@vue/compiler-sfc": "^3.0.0"
},
"prettier": {
"singleQuote": true,
@ -94,6 +60,5 @@
"Chrome >= 53",
"ChromeAndroid >= 53",
"iOS >= 8"
],
"dependencies": {}
]
}

309
vant.config.js Normal file
View File

@ -0,0 +1,309 @@
module.exports = {
name: 'vant-weapp',
build: {
srcDir: 'packages',
site: {
publicPath: '/vant-weapp/',
},
},
site: {
versions: [{ label: '0.x', link: '/vant-weapp/0.x' }],
title: 'Vant Weapp',
description: '轻量、可靠的小程序 UI 组件库',
logo: 'https://img.yzcdn.cn/vant/logo.png',
simulator: {
url: 'https://vant-contrib.gitee.io/vant/mobile.html?weapp=1',
routeMapper: (path) => {
const map = {
'/common': '/style',
'/transition': '/style',
};
return `/zh-CN${map[path] || path}`;
},
syncPathFromSimulator: false,
},
links: [
{
logo: 'https://img.yzcdn.cn/vant/vant-o.svg',
url: 'https://vant-contrib.gitee.io/vant/',
},
{
logo: 'https://b.yzcdn.cn/vant/logo/github.svg',
url: 'https://github.com/youzan/vant-weapp',
},
],
baiduAnalytics: {
seed: 'ad6b5732c36321f2dafed737ac2da92f',
},
nav: [
{
title: '开发指南',
items: [
{
path: 'home',
title: '介绍',
},
{
path: 'quickstart',
title: '快速上手',
},
{
path: 'changelog',
title: '更新日志',
},
{
path: 'custom-style',
title: '样式覆盖',
},
{
path: 'theme',
title: '定制主题',
},
],
},
{
title: '基础组件',
items: [
{
path: 'button',
title: 'Button 按钮',
},
{
path: 'cell',
title: 'Cell 单元格',
},
{
path: 'icon',
title: 'Icon 图标',
},
{
path: 'image',
title: 'Image 图片',
},
{
path: 'col',
title: 'Layout 布局',
},
{
path: 'popup',
title: 'Popup 弹出层',
},
{
path: 'common',
title: 'Style 内置样式',
},
{
path: 'toast',
title: 'Toast 轻提示',
},
{
path: 'transition',
title: 'transition 动画',
},
],
},
{
title: '表单组件',
items: [
{
path: 'calendar',
title: 'Calendar 日历',
},
{
path: 'checkbox',
title: 'Checkbox 复选框',
},
{
path: 'datetime-picker',
title: 'DatetimePicker 时间选择',
},
{
path: 'field',
title: 'Field 输入框',
},
{
path: 'picker',
title: 'Picker 选择器',
},
{
path: 'radio',
title: 'Radio 单选框',
},
{
path: 'rate',
title: 'Rate 评分',
},
{
path: 'search',
title: 'Search 搜索',
},
{
path: 'slider',
title: 'Slider 滑块',
},
{
path: 'stepper',
title: 'Stepper 步进器',
},
{
path: 'switch',
title: 'Switch 开关',
},
{
path: 'uploader',
title: 'Uploader 文件上传',
},
],
},
{
title: '反馈组件',
items: [
{
path: 'action-sheet',
title: 'ActionSheet 动作面板',
},
{
path: 'dialog',
title: 'Dialog 弹出框',
},
{
path: 'dropdown-menu',
title: 'DropdownMenu 下拉菜单',
},
{
path: 'loading',
title: 'Loading 加载',
},
{
path: 'notify',
title: 'Notify 消息通知',
},
{
path: 'overlay',
title: 'Overlay 遮罩层',
},
{
path: 'share-sheet',
title: 'ShareSheet 分享面板',
},
{
path: 'swipe-cell',
title: 'SwipeCell 滑动单元格',
},
],
},
{
title: '展示组件',
items: [
{
path: 'circle',
title: 'Circle 环形进度条',
},
{
path: 'collapse',
title: 'Collapse 折叠面板',
},
{
path: 'count-down',
title: 'CountDown 倒计时',
},
{
path: 'divider',
title: 'Divider 分割线',
},
{
path: 'empty',
title: 'Empty 空状态',
},
{
path: 'notice-bar',
title: 'NoticeBar 通知栏',
},
{
path: 'progress',
title: 'Progress 进度条',
},
{
path: 'skeleton',
title: 'Skeleton 骨架屏',
},
{
path: 'steps',
title: 'Steps 步骤条',
},
{
path: 'sticky',
title: 'Sticky 粘性布局',
},
{
path: 'tag',
title: 'Tag 标签',
},
],
},
{
title: '导航组件',
items: [
{
path: 'grid',
title: 'Grid 宫格',
},
{
path: 'index-bar',
title: 'IndexBar 索引栏',
},
{
path: 'nav-bar',
title: 'NavBar 导航栏',
},
{
path: 'sidebar',
title: 'Sidebar 侧边导航',
},
{
path: 'tab',
title: 'Tab 标签页',
},
{
path: 'tabbar',
title: 'Tabbar 标签栏',
},
{
path: 'tree-select',
title: 'TreeSelect 分类选择',
},
],
},
{
title: '业务组件',
items: [
{
path: 'area',
title: 'Area 省市区选择',
},
{
path: 'card',
title: 'Card 商品卡片',
},
{
path: 'submit-bar',
title: 'SubmitBar 提交订单栏',
},
{
path: 'goods-action',
title: 'GoodsAction 商品导航',
},
],
},
{
title: '废弃',
items: [
{
path: 'panel',
title: 'Panel 面板',
},
],
},
],
},
};

9252
yarn.lock

File diff suppressed because it is too large Load Diff