diff --git a/build/bin/build-lib.js b/build/bin/build-lib.js index d20e2ba7c..23b8dd6dd 100644 --- a/build/bin/build-lib.js +++ b/build/bin/build-lib.js @@ -1,18 +1,14 @@ /** * Build npm lib * Steps: - * 1. 清理目录 + * 1. 代码格式校验 * 2. 构建 JS 入口文件 - * 3. 代码格式校验 * 4. 构建每个组件对应的 [component].js - * 5. 构建 vant-css + * 4. 构建 vant-css + * 5. 打包 JS 文件:vant.js && vant.min.js * 6. 生成每个组件目录下的 style 入口 - * 7. 打包 JS 文件:vant.js && vant.min.js */ -const fs = require('fs'); -const path = require('path'); -const components = require('./get-components')(); const chalk = require('chalk'); require('shelljs/global'); @@ -36,26 +32,16 @@ log('Starting', 'build:vant-css'); exec('npm run build:vant-css --silent'); log('Finished', 'build:vant-css'); -// 5. build style entrys -log('Starting', 'build:style-entries'); -components.forEach((componentName) => { - const dir = path.join(__dirname, '../../lib/', componentName, '/style'); - const file = path.join(dir, 'index.js'); - const cssPath = path.join(__dirname, '../../lib/vant-css/', `${componentName}.css`); - const content = []; - if (fs.existsSync(cssPath)) { - content.push(`require('../../vant-css/${componentName}.css');`); - } - mkdir(dir); - writeFile(file, content.join('\n')); -}); -log('Finished', 'build:style-entries'); - -// 6. build vant.js +// 5. build vant.js log('Starting', 'build:vant'); exec('npm run build:vant --silent'); log('Finished', 'build:vant'); +// 6. build style entrys +log('Starting', 'build:style-entries'); +exec('npm run build:style-entry --silent'); +log('Finished', 'build:style-entries'); + // helpers function log(status, action, breakLine) { const now = new Date(); @@ -66,16 +52,3 @@ function log(status, action, breakLine) { function padZero(num) { return (num < 10 ? '0' : '') + num; } - -function writeFile(pathname, content) { - if (!fs.existsSync(pathname)) { - fs.closeSync(fs.openSync(pathname, 'w')); - } - fs.writeFileSync(pathname, content, { encoding: 'utf8' }); -} - -function mkdir(pathname) { - if (!fs.existsSync(pathname)) { - fs.mkdirSync(pathname); - } -} diff --git a/build/bin/build-style-entry.js b/build/bin/build-style-entry.js new file mode 100644 index 000000000..b075026ed --- /dev/null +++ b/build/bin/build-style-entry.js @@ -0,0 +1,48 @@ +/** + * 生成每个组件目录下的 style 入口 + */ + +const fs = require('fs-extra'); +const path = require('path'); +const components = require('./get-components')(); +const source = require('../../lib/vant'); + +components.forEach(componentName => { + const dependencies = analyzeDependencies(componentName); + const styleDir = path.join(__dirname, '../../lib/', componentName, '/style'); + const content = dependencies.map(component => `require('../../vant-css/${component}.css');`); + fs.outputFileSync(path.join(styleDir, './index.js'), content.join('\n')); +}); + +// 递归分析组件依赖 +// 样式引入顺序:基础样式, 组件依赖样式,组件本身样式 +function analyzeDependencies(componentName) { + const checkList = ['base']; + const search = component => { + const componentSource = source[toPascal(component)]; + if (componentSource && componentSource.components) { + Object.keys(componentSource.components).forEach(name => { + name = name.replace('van-', ''); + if (checkList.indexOf(name) === -1) { + search(name); + } + }); + } + if (checkList.indexOf(component) === -1) { + checkList.push(component); + } + } + + search(componentName); + return checkList.filter(component => checkComponentHasStyle(component)); +} + +// 判断组件是否有样式 +function checkComponentHasStyle(componentName) { + const cssPath = path.join(__dirname, '../../lib/vant-css/', `${componentName}.css`); + return fs.existsSync(cssPath); +} + +function toPascal(str) { + return ('_' + str).replace(/[_.-](\w|$)/g, (_, x) => x.toUpperCase()); +} diff --git a/build/webpack.config.dev.js b/build/webpack.config.dev.js index e38ba86e3..a70c778a0 100644 --- a/build/webpack.config.dev.js +++ b/build/webpack.config.dev.js @@ -23,6 +23,7 @@ extractExample({ module.exports = { entry: { + vendor: ['packages'], 'vant-docs': './docs/src/index.js', 'vant-examples': './docs/src/examples.js' }, @@ -87,7 +88,18 @@ module.exports = { }, { test: /\.md/, - loader: 'vue-markdown-loader' + loader: 'vue-markdown-loader', + options: { + preventExtract: true, + use: [[require('markdown-it-container'), 'demo']], + preprocess(MarkdownIt, source) { + const styleRegexp = /)<[^<]*)*<\/style>/i; + const scriptRegexp = /)<[^<]*)*<\/script>/i; + MarkdownIt.renderer.rules.table_open = () => + ''; + return source.replace(styleRegexp, '').replace(scriptRegexp, ''); + } + } }, { test: /\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/, @@ -98,37 +110,6 @@ module.exports = { devtool: 'source-map', plugins: [ new ProgressBarPlugin(), - new webpack.LoaderOptionsPlugin({ - minimize: true, - options: { - vue: { - autoprefixer: false - }, - vueMarkdown: { - use: [ - [ - require('markdown-it-container'), - 'demo', - { - validate: function(params) { - return params.trim().match(/^demo\s*(.*)$/); - }, - - render: function(tokens, idx) { - return tokens[idx].nesting === 1 - ? `
` - :`
\n`; - } - } - ] - ], - preprocess: function(MarkdownIt, source) { - MarkdownIt.renderer.rules.table_open = () => '
'; - return source; - } - } - } - }), new HtmlWebpackPlugin({ chunks: ['vendor', 'vant-docs'], template: 'docs/src/index.tpl', @@ -143,9 +124,9 @@ module.exports = { }), new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', - minChunks: 2 + minChunks: 2, + filename: isProduction ? 'vendor.[hash:8].js' : 'vendor.js' }), - new webpack.HotModuleReplacementPlugin(), new OptimizeCssAssetsPlugin(), new ExtractTextPlugin({ filename: isProduction ? '[name].[hash:8].css' : '[name].css', diff --git a/build/webpack.config.prod.js b/build/webpack.config.prod.js index 204bf81a5..74c54b30e 100644 --- a/build/webpack.config.prod.js +++ b/build/webpack.config.prod.js @@ -27,10 +27,6 @@ module.exports = merge(devConfig, { comments: false }, sourceMap: false - }), - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - minChunks: Infinity }) ] }); diff --git a/docs/examples-docs/actionsheet.md b/docs/examples-docs/actionsheet.md index 09cd0fef6..f1ccf7955 100644 --- a/docs/examples-docs/actionsheet.md +++ b/docs/examples-docs/actionsheet.md @@ -73,8 +73,9 @@ Vue.component(Actionsheet.name, Actionsheet); 弹出actionsheet +``` - ``` ::: @@ -122,8 +122,9 @@ export default { 弹出带取消按钮的actionsheet +``` - ``` ::: diff --git a/docs/examples-docs/area.md b/docs/examples-docs/area.md new file mode 100644 index 000000000..78b04fddb --- /dev/null +++ b/docs/examples-docs/area.md @@ -0,0 +1,133 @@ + + +## Area 省市县选择组件 + +### 使用指南 + +``` javascript +import { Area } from 'vant'; + +Vue.component(Area.name, Area); +``` + +### 代码演示 + +#### 基础用法 + +要初始化一个`Area`组件,你需要传入一个`areaList`属性,`areaList`数据格式具体可看下面数据格式章节。 + +:::demo 基础用法 +```html + + + +``` +::: + +#### 选中省市县 + +如果想选中某个省市县,需要传入一个`value`属性,绑定对应的省市县`code`。 + +:::demo 选中省市县 +```html + +``` +::: + +#### 配置显示列 + +可以通过`columnsNum`属性配置省市县显示的列数,默认情况下会显示省市县,当你设置为`2`,则只会显示省市选择。 + +:::demo 配置显示列 +```html + +``` +::: + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| value | 当前选中的省市区`code` | `String` | - | | +| areaList | 省市县数据,必须与`province_list`、`city_list`和`county_list`为key | `Object` | | | +| columnsNum | 省市县显示列数,3-省市县,2-省市,1-省 | `String`,`Number` | 3 | | + +### Event + +| 事件名称 | 说明 | 回调参数 | +|-----------|-----------|-----------| +| confirm | 点击右上方完成按钮 | 一个数组参数,具体格式看下方数据格式章节 | +| cancel | 点击取消按钮时 | - | + +### 数据格式 + +#### 省市县列表数据格式 + +整体是一个Object,包含 `province_list`, `city_list`, `county_list` 三个key。 + +每项以省市区编码作为key,省市区名字作为value。编码为6位数字,前两位代表省份,中间两位代表城市,后两位代表区县,以0补足6位。如北京编码为 `11`,以零补足6位,为 `110000`。 + +`AreaList`具体格式如下: +```javascript +{ + province_list: { + 110000: '北京市', + 120000: '天津市' + }, + city_list: { + 110100: '北京市', + 110200: '县', + 120100: '天津市', + 120200: '县' + }, + county_list: { + 110101: '东城区', + 110102: '西城区', + 110105: '朝阳区', + 110106: '丰台区' + 120101: '和平区', + 120102: '河东区', + 120103: '河西区', + 120104: '南开区', + 120105: '河北区', + // .... + } +} +``` + +#### 点击完成时返回的数据格式 +返回的数据整体为一个数组,数组内包含 `columnsNum` 个数据, 每个数据对应一列选项中被选中的数据。 + +`code` 代表被选中的地区编码, `name` 代表被选中的地区名称 +```javascript +[{ + code: '110000', + name: '北京市' +}, { + code: '110100', + name: '北京市' +},{ + code: '110101', + name: '东城区' +}] +``` diff --git a/docs/examples-docs/card.md b/docs/examples-docs/card.md index 2c586a78a..99719d7d0 100644 --- a/docs/examples-docs/card.md +++ b/docs/examples-docs/card.md @@ -23,25 +23,29 @@ Vue.component(Card.name, Card); :::demo 基础用法 ```html - + ``` ::: #### 高级用法 - -可以使用具名`slot`重写标题等信息,其中包含`title`、`desc`、`footer`和`tag`四个`slot`。 +可以通过具名`slot`添加定制内容 :::demo 高级用法 ```html - -
-

商品名称

- ¥ 2.00 -
-
- x 2 -
- +``` - ``` ::: @@ -133,8 +133,9 @@ export default { 复选框{{item}} +``` - ``` ::: @@ -164,8 +164,9 @@ export default { +``` - ``` ::: diff --git a/docs/examples-docs/datetime-picker.md b/docs/examples-docs/datetime-picker.md index dd4973ea6..9465a6ecf 100644 --- a/docs/examples-docs/datetime-picker.md +++ b/docs/examples-docs/datetime-picker.md @@ -50,8 +50,9 @@ Vue.component(DatetimePicker.name, DatetimePicker); :max-date="maxDate" @change="handlePickerChange"> +``` - ``` ::: diff --git a/docs/examples-docs/deep-select.md b/docs/examples-docs/deep-select.md index 846fdd9c5..0c32a8f61 100644 --- a/docs/examples-docs/deep-select.md +++ b/docs/examples-docs/deep-select.md @@ -119,7 +119,6 @@ export default { } } } - ``` ::: diff --git a/docs/examples-docs/dialog.md b/docs/examples-docs/dialog.md index cb71eacc0..a1f6a77a5 100644 --- a/docs/examples-docs/dialog.md +++ b/docs/examples-docs/dialog.md @@ -7,7 +7,7 @@ ``` ::: @@ -89,8 +89,9 @@ export default { :::demo 消息确认 ```html Confirm +``` - ``` ::: diff --git a/docs/examples-docs/express-way.md b/docs/examples-docs/express-way.md index ee4d0ded4..0ab6453dd 100644 --- a/docs/examples-docs/express-way.md +++ b/docs/examples-docs/express-way.md @@ -1,7 +1,7 @@ ## ExpressWay 配送方式 @@ -47,17 +43,16 @@ Vue.component(ExpressWay.name, ExpressWay); :::demo 基础用法 ```html - diff --git a/docs/src/components/demo-list.vue b/docs/src/components/demo-list.vue index ae59d4043..301b4d072 100644 --- a/docs/src/components/demo-list.vue +++ b/docs/src/components/demo-list.vue @@ -3,11 +3,9 @@

Zan UI Wap

有赞移动wap端组件库

- +
+ +
@@ -19,8 +17,6 @@ import MobileNav from './mobile-nav'; export default { data() { return { - highlights: [], - navState: [], data: docConfig['zh-CN'].nav, base: '/component' }; diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js index 844406b25..b51fa8856 100644 --- a/docs/src/doc.config.js +++ b/docs/src/doc.config.js @@ -176,6 +176,10 @@ module.exports = { "path": "/picker", "title": "Picker 选择器" }, + { + "path": "/pull-refresh", + "title": "PullRefresh 下拉刷新" + }, { "path": "/toast", "title": "Toast 轻提示" @@ -201,6 +205,10 @@ module.exports = { "path": "/invalid-goods", "title": "InvalidGoods 不可用商品列表" }, + { + "path": "/order-coupon", + "title": "OrderCoupon 下单页优惠券" + }, { "path": "/order-goods", "title": "OrderGoods 下单页商品列表" @@ -212,6 +220,10 @@ module.exports = { { "path": "/switch-cell", "title": "SwitchCell 开关单元格" + }, + { + "path": "/area", + "title": "Area 省市区选择" } ] } diff --git a/docs/src/examples.js b/docs/src/examples.js index 235d2fb2c..674f838a2 100644 --- a/docs/src/examples.js +++ b/docs/src/examples.js @@ -18,21 +18,24 @@ Vue.use(VueRouter); const routesConfig = routes(true); routesConfig.push({ path: '/', - component: DemoList.default || DemoList + component: DemoList }); const router = new VueRouter({ mode: 'history', base: '/zanui/vue/examples', routes: routesConfig }); -router.beforeEach((to, from, next) => { + +router.afterEach(() => { const container = document.querySelector('.examples-container'); if (container) { document.querySelector('.examples-container').scrollTop = 0; } - next(); + window.syncPath(); }); +window.vueRouter = router; + new Vue({ // eslint-disable-line render: h => h(App), router diff --git a/docs/src/iframe-router.js b/docs/src/iframe-router.js new file mode 100644 index 000000000..f02baddaa --- /dev/null +++ b/docs/src/iframe-router.js @@ -0,0 +1,41 @@ +/** + * 同步父窗口和 iframe 的 vue-router 状态 + */ + +import isMobile from './is-mobile'; + +window.syncPath = function(dir) { + const router = window.vueRouter; + const isInIframe = window !== window.top; + const currentDir = router.history.current.path; + const iframe = document.querySelector('iframe'); + + if (!isInIframe && !isMobile && iframe) { + iframeReady(iframe, () => { + iframe.contentWindow.changePath(currentDir); + }); + } +}; + +window.changePath = function(path) { + window.vueRouter.replace(path); +}; + +function iframeReady(iframe, callback) { + const doc = iframe.contentDocument || iframe.contentWindow.document; + const interval = () => { + if (iframe.contentWindow.changePath) { + callback(); + } else { + setTimeout(() => { + interval(); + }, 50); + } + }; + + if (doc.readyState === 'complete') { + interval(); + } else { + iframe.onload = interval; + } +} diff --git a/docs/src/index.js b/docs/src/index.js index 0b1484d7f..6c6b36dd6 100644 --- a/docs/src/index.js +++ b/docs/src/index.js @@ -3,17 +3,10 @@ import VueRouter from 'vue-router'; import App from './ExamplesDocsApp'; import routes from './router.config'; import ZanDoc from 'zan-doc'; -import DemoBlock from './components/demo-block'; - -const isMobile = (function() { - var platform = navigator.userAgent.toLowerCase(); - return (/(android|bb\d+|meego).+mobile|kdtunion|weibo|m2oapp|micromessenger|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i).test(platform) || - (/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i).test(platform.substr(0, 4)); -})(); +import isMobile from './is-mobile'; Vue.use(VueRouter); Vue.use(ZanDoc); -Vue.component(DemoBlock.name, DemoBlock); const routesConfig = routes(); routesConfig.push({ @@ -30,18 +23,18 @@ const router = new VueRouter({ router.beforeEach((route, redirect, next) => { if (isMobile) { window.location.replace('/zanui/vue/examples'); - return; } document.title = route.meta.title || document.title; next(); }); router.afterEach(() => { - if (!isMobile) { - window.scrollTo(0, 0); - } + window.scrollTo(0, 0); + window.syncPath(); }); +window.vueRouter = router; + new Vue({ // eslint-disable-line render: h => h(App), router diff --git a/docs/src/index.tpl b/docs/src/index.tpl index 260f318a5..5266d0fbb 100644 --- a/docs/src/index.tpl +++ b/docs/src/index.tpl @@ -6,7 +6,7 @@ ZanUI - 移动端 - +
diff --git a/docs/src/is-mobile.js b/docs/src/is-mobile.js new file mode 100644 index 000000000..1338e318d --- /dev/null +++ b/docs/src/is-mobile.js @@ -0,0 +1,7 @@ +const isMobile = (function() { + var platform = navigator.userAgent.toLowerCase(); + return (/(android|bb\d+|meego).+mobile|kdtunion|weibo|m2oapp|micromessenger|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i).test(platform) || + (/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i).test(platform.substr(0, 4)); +})(); + +export default isMobile; diff --git a/docs/src/router.config.js b/docs/src/router.config.js index b49e01ca1..1b952f8a9 100644 --- a/docs/src/router.config.js +++ b/docs/src/router.config.js @@ -1,9 +1,16 @@ -const navs = require('./doc.config')['zh-CN'].nav; +import docConfig from './doc.config'; import componentDocs from '../examples-dist/entry-docs'; import componentDemos from '../examples-dist/entry-demos'; +import './iframe-router'; + +const navs = docConfig['zh-CN'].nav; const registerRoute = (isExample) => { - let route = []; + const route = [{ + path: '*', + redirect: '/' + }]; + navs.forEach(nav => { if (isExample && !nav.showInMobile) { return; diff --git a/package.json b/package.json index 49ac4b8a0..06ba811fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vant", - "version": "0.8.9", + "version": "0.9.1", "description": "有赞vue wap组件库", "main": "lib/vant.js", "style": "lib/vant-css/index.css", @@ -17,6 +17,7 @@ "build:components": "node build/bin/build-components.js --color", "build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color && mkdir lib/vant-css && cp -R packages/vant-css/lib/ lib/vant-css", "build:vant": "cross-env NODE_ENV=production webpack --progress --hide-modules --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --progress --hide-modules --color --config build/webpack.build.js", + "build:style-entry": "VUE_ENV=server node build/bin/build-style-entry.js", "deploy": "npm run deploy:docs && npm run deploy:cdn && gh-pages -d docs/dist --remote youzan && rimraf docs/dist", "deploy:cdn": "superman cdn /zanui/vue docs/dist/*.js docs/dist/*.css", "deploy:docs": "rimraf docs/dist && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.prod.js", @@ -42,7 +43,7 @@ "license": "ISC", "dependencies": { "babel-runtime": "6.x", - "vue-lazyload": "^1.1.2" + "vue-lazyload": "^1.1.3" }, "peerDependencies": { "vue": "2.4.2" @@ -61,7 +62,7 @@ "babel-plugin-transform-vue-jsx": "^3.5.0", "babel-polyfill": "^6.26.0", "babel-preset-env": "^1.6.0", - "chai": "^4.1.1", + "chai": "^4.1.2", "cheerio": "^0.22.0", "codecov": "^2.2.0", "cross-env": "^5.0.5", @@ -107,7 +108,6 @@ "uppercamelcase": "^3.0.0", "url-loader": "^0.5.9", "vue": "^2.4.2", - "vue-html-loader": "^1.2.4", "vue-loader": "^13.0.4", "vue-markdown-loader": "^2.1.0", "vue-router": "^2.7.0", @@ -117,6 +117,6 @@ "webpack": "^3.5.5", "webpack-dev-server": "^2.7.1", "webpack-merge": "^4.1.0", - "zan-doc": "^0.2.10" + "zan-doc": "^0.2.12" } } diff --git a/packages/actionsheet/index.vue b/packages/actionsheet/index.vue index 04f206ba2..0ce765aaa 100644 --- a/packages/actionsheet/index.vue +++ b/packages/actionsheet/index.vue @@ -1,7 +1,7 @@