diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index 3343ac7a6..b58e200be 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -3,6 +3,7 @@ var fs = require('fs'); var render = require('json-templater/string'); var uppercamelcase = require('uppercamelcase'); var path = require('path'); +var chalk = require('chalk'); var OUTPUT_PATH = path.join(__dirname, '../../src/index.js'); var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';'; @@ -70,5 +71,5 @@ var template = render(MAIN_TEMPLATE, { }); fs.writeFileSync(OUTPUT_PATH, template); -console.log('[build entry] DONE:', OUTPUT_PATH); +console.log(chalk.green('[build entry] DONE:' + OUTPUT_PATH)); diff --git a/build/genExamples.js b/build/genExamples.js index d59b81681..129dc1e0e 100644 --- a/build/genExamples.js +++ b/build/genExamples.js @@ -3,8 +3,10 @@ var markdownItContainer = require('markdown-it-container'); var fs = require('fs'); var path = require('path'); var cheerio = require('cheerio'); +var chalk = require('chalk'); var striptags = require('./strip-tags'); -var Components = require('../components.json'); +var navs = require('../docs/nav.config.json'); +navs = navs['zh-CN']; var parser = markdownIt('default', { html: true @@ -69,17 +71,32 @@ parser.use(markdownItContainer, 'demo', { }); var docsDir = path.resolve(__dirname, '../docs'); -for (var item in Components) { - var itemMdFile = `${docsDir}/examples-docs/${item}.md`; +var components = []; +for (var i = 0; i < navs.length; i++) { + var navItem = navs[i]; + + if (!navItem.showInMobile) continue; + + if (!navItem.groups) { + components.push(navs[i]); + } else { + for (var j = 0; j < navItem.groups.length; j++) { + components = components.concat(navItem.groups[j].list); + } + } +} +for (var i = 0; i < components.length; i++) { + var item = components[i]; + var itemMdFile = `${docsDir}/examples-docs${item.path}.md`; if (!fs.existsSync(itemMdFile)) { continue; } - var itemMd = fs.readFileSync(`${docsDir}/examples-docs/${item}.md`).toString(); + var itemMd = fs.readFileSync(`${docsDir}/examples-docs${item.path}.md`).toString(); var content = parser.render(itemMd); - var result = renderVueTemplate(content, item); + var result = renderVueTemplate(content, item.path.slice(1)); - var exampleVueName = `${docsDir}/examples-dist/${item}.vue`; + var exampleVueName = `${docsDir}/examples-dist/${item.path}.vue`; // 新建一个文件 if (!fs.existsSync(exampleVueName)) { @@ -90,5 +107,5 @@ for (var item in Components) { }); } -console.log('generate examples success!'); +console.log(chalk.green('generate examples success!')); diff --git a/build/webpack.config.js b/build/webpack.config.js index f67f32fef..d10a4eada 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -48,7 +48,7 @@ module.exports = { path.join(__dirname, '../node_modules'), 'node_modules' ], - extensions: ['.js', '.vue', '.pcss'], + extensions: ['.js', '.vue', '.css'], alias: { 'vue$': 'vue/dist/vue.runtime.common.js', 'zanui': path.join(__dirname, '..'), @@ -97,20 +97,7 @@ module.exports = { }, devtool: 'source-map', plugins: [ - StyleExtractPlugin, new ProgressBarPlugin(), - new HtmlWebpackPlugin({ - chunks: ['vendor', 'zan-docs'], - template: 'docs/index.tpl', - filename: 'index.html', - inject: true - }), - new HtmlWebpackPlugin({ - chunks: ['vendor', 'zan-examples'], - template: 'docs/index.tpl', - filename: 'examples.html', - inject: true - }), new webpack.LoaderOptionsPlugin({ minimize: true, options: { @@ -160,7 +147,20 @@ module.exports = { } } } - }) + }), + new HtmlWebpackPlugin({ + chunks: ['vendor', 'zan-docs'], + template: 'docs/index.tpl', + filename: 'index.html', + inject: true + }), + new HtmlWebpackPlugin({ + chunks: ['vendor', 'zan-examples'], + template: 'docs/index.tpl', + filename: 'examples.html', + inject: true + }), + StyleExtractPlugin ] }; diff --git a/docs/ExamplesDocsApp.vue b/docs/ExamplesDocsApp.vue index 120bab31f..8f62fd33f 100644 --- a/docs/ExamplesDocsApp.vue +++ b/docs/ExamplesDocsApp.vue @@ -1,22 +1,6 @@ diff --git a/docs/assets/docs.css b/docs/assets/docs.css index a5a1c852a..188432d43 100644 --- a/docs/assets/docs.css +++ b/docs/assets/docs.css @@ -41,13 +41,13 @@ ul, ol { list-style: none; } -.hljs { - line-height: 1.8; +code.hljs { + line-height: 1.5; font-family: Menlo, Monaco, Consolas, Courier, monospace; font-size: 12px; - padding: 18px 24px; - background-color: #f9fafc; - border: solid 1px #eaeefb; + padding: 20px; + background-color: #f8f8f8; + border: solid 1px #E5E5E5; margin-bottom: 25px; border-radius: 4px; -webkit-font-smoothing: auto; @@ -66,64 +66,8 @@ ul, ol { } } -.page-header { - height: 60px; - background-color: #fbfbfb; - overflow: hidden; - padding-right: 62px; - position: relative; -} - -.page-header-logo { - float: left; - - > a { - display: block; - width: 78px; - height: 20px; - background-image: url(https://img.yzcdn.cn/upload_files/2017/03/30/Fjm3aSwID8ROIV_5TO6dZdJ_IEgz.png); - background-size: contain; - background-repeat: no-repeat; - margin: 20px 0 0 20px; - } -} - -.page-header-navs { - float: right; - - li { - float: left; - } - - a { - display: block; - line-height: 60px; - color: #333; - font-size: 16px; - margin: 0 20px; - - &.active, - &:hover { - color: #3388FF; - } - } -} - -.github-logo { - position: absolute; - top: 19px; - right: 20px; - width: 22px; - height: 0; - padding-top: 22px; - overflow: hidden; - background-image: url(https://img.yzcdn.cn/upload_files/2017/03/30/Fil9peDfgzvk3kj-oFCsElS4FS1x.png); - background-size: contain; - background-repeat: no-repeat; -} - .main-content { - margin: 40px 15px; + margin: 50px 15px 40px; } .page-container { @@ -263,9 +207,3 @@ ul, ol { padding: 10px; } } - -.page-footer { - height: 72px; - margin-top: 40px; - background-color: #34383B; -} diff --git a/docs/components/demo-block.vue b/docs/components/demo-block.vue index d9e9dc495..50dfb211e 100644 --- a/docs/components/demo-block.vue +++ b/docs/components/demo-block.vue @@ -30,8 +30,8 @@ export default { .examples { width: 320px; box-sizing: border-box; - padding: 10px 0 0; - min-height: 200px; + padding: 10px 0; + min-height: 60px; max-height: 500px; overflow: auto; background-color: #F8F8F8; diff --git a/docs/components/mobile-computed.js b/docs/components/mobile-computed.js index b59fb80e9..e052c93bb 100644 --- a/docs/components/mobile-computed.js +++ b/docs/components/mobile-computed.js @@ -7,7 +7,11 @@ export default { computed: { mobileUrl() { - return '/examples.html#' + location.pathname.slice(4); + if (process.env.NODE_ENV === 'production') { + return '/vue/examples#' + location.pathname.slice(4); + } else { + return '/examples.html#' + location.pathname.slice(4); + } } }, diff --git a/docs/components/mobile-popup.vue b/docs/components/mobile-popup.vue index 160872d5b..b767556f5 100644 --- a/docs/components/mobile-popup.vue +++ b/docs/components/mobile-popup.vue @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/docs/examples-dist/lazyload.vue b/docs/examples-dist/lazyload.vue new file mode 100644 index 000000000..f3bb7137d --- /dev/null +++ b/docs/examples-dist/lazyload.vue @@ -0,0 +1,78 @@ + + + \ No newline at end of file diff --git a/docs/examples-dist/loading.vue b/docs/examples-dist/loading.vue index ff83d7b07..8f761de57 100644 --- a/docs/examples-dist/loading.vue +++ b/docs/examples-dist/loading.vue @@ -1,40 +1,35 @@ -