diff --git a/build/compiler.js b/build/compiler.js index d5d05da9..49155108 100644 --- a/build/compiler.js +++ b/build/compiler.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const gulp = require('gulp'); const path = require('path'); const less = require('gulp-less'); @@ -16,8 +17,10 @@ const exampleConfig = path.resolve(__dirname, '../tsconfig.example.json'); const libDir = path.resolve(__dirname, '../lib'); const esDir = path.resolve(__dirname, '../dist'); -const exampleDir = path.resolve(__dirname, '../example/dist'); +const exampleDistDir = path.resolve(__dirname, '../example/dist'); +const examplePagesDir = path.resolve(__dirname, '../example/pages'); +const exampleAppJsonPath = path.resolve(__dirname, '../example/app.json'); const baseCssPath = path.resolve(__dirname, '../packages/common/index.wxss'); const lessCompiler = (dist) => @@ -101,18 +104,34 @@ const tasks = [ }, {}); tasks.buildExample = gulp.series( - cleaner(exampleDir), + cleaner(exampleDistDir), gulp.parallel( - tsCompiler(exampleDir, exampleConfig), - lessCompiler(exampleDir), - staticCopier(exampleDir), + tsCompiler(exampleDistDir, exampleConfig), + lessCompiler(exampleDistDir), + staticCopier(exampleDistDir), () => - gulp.src(`${icons}/**/*`).pipe(gulp.dest(`${exampleDir}/@vant/icons`)), + gulp + .src(`${icons}/**/*`) + .pipe(gulp.dest(`${exampleDistDir}/@vant/icons`)), () => { - gulp.watch(`${src}/**/*.less`, lessCompiler(exampleDir)); - gulp.watch(`${src}/**/*.wxml`, copier(exampleDir, 'wxml')); - gulp.watch(`${src}/**/*.wxs`, copier(exampleDir, 'wxs')); - gulp.watch(`${src}/**/*.json`, copier(exampleDir, 'json')); + const appJson = JSON.parse(fs.readFileSync(exampleAppJsonPath)); + appJson.pages.forEach((path) => { + const component = path.replace(/(pages\/|\/index)/g, ''); + fs.writeFileSync( + `${examplePagesDir}/${component}/index.js`, + "import Page from '../../common/page';Page();" + ); + fs.writeFileSync( + `${examplePagesDir}/${component}/index.wxml`, + `` + ); + }); + }, + () => { + gulp.watch(`${src}/**/*.less`, lessCompiler(exampleDistDir)); + gulp.watch(`${src}/**/*.wxml`, copier(exampleDistDir, 'wxml')); + gulp.watch(`${src}/**/*.wxs`, copier(exampleDistDir, 'wxs')); + gulp.watch(`${src}/**/*.json`, copier(exampleDistDir, 'json')); } ) ); diff --git a/example/app.json b/example/app.json index 5a772982..9063ba8c 100644 --- a/example/app.json +++ b/example/app.json @@ -63,122 +63,57 @@ }, "usingComponents": { "demo-block": "./components/demo-block/index", - "van-action-sheet": "./dist/action-sheet/index", "van-action-sheet-demo": "./dist/action-sheet/demo/index", - "van-area": "./dist/area/index", "van-area-demo": "./dist/area/demo/index", - "van-button": "./dist/button/index", "van-button-demo": "./dist/button/demo/index", - "van-card": "./dist/card/index", "van-card-demo": "./dist/card/demo/index", - "van-cell": "./dist/cell/index", "van-cell-demo": "./dist/cell/demo/index", - "van-cell-group": "./dist/cell-group/index", - "van-checkbox": "./dist/checkbox/index", "van-checkbox-demo": "./dist/checkbox/demo/index", - "van-checkbox-group": "./dist/checkbox-group/index", - "van-col": "./dist/col/index", "van-col-demo": "./dist/col/demo/index", - "van-count-down": "./dist/count-down/index", "van-count-down-demo": "./dist/count-down/demo/index", - "van-dialog": "./dist/dialog/index", "van-dialog-demo": "./dist/dialog/demo/index", - "van-divider": "./dist/divider/index", "van-divider-demo": "./dist/divider/demo/index", - "van-empty": "./dist/empty/index", "van-empty-demo": "./dist/empty/demo/index", - "van-field": "./dist/field/index", "van-field-demo": "./dist/field/demo/index", - "van-goods-action": "./dist/goods-action/index", "van-goods-action-demo": "./dist/goods-action/demo/index", - "van-goods-action-icon": "./dist/goods-action-icon/index", - "van-goods-action-button": "./dist/goods-action-button/index", - "van-icon": "./dist/icon/index", "van-icon-demo": "./dist/icon/demo/index", - "van-image": "./dist/image/index", "van-image-demo": "./dist/image/demo/index", - "van-loading": "./dist/loading/index", "van-loading-demo": "./dist/loading/demo/index", - "van-nav-bar": "./dist/nav-bar/index", "van-nav-bar-demo": "./dist/nav-bar/demo/index", - "van-notice-bar": "./dist/notice-bar/index", "van-notice-bar-demo": "./dist/notice-bar/demo/index", - "van-notify": "./dist/notify/index", "van-notify-demo": "./dist/notify/demo/index", - "van-panel": "./dist/panel/index", "van-panel-demo": "./dist/panel/demo/index", - "van-popup": "./dist/popup/index", "van-popup-demo": "./dist/popup/demo/index", - "van-progress": "./dist/progress/index", "van-progress-demo": "./dist/progress/demo/index", - "van-radio": "./dist/radio/index", "van-radio-demo": "./dist/radio/demo/index", - "van-radio-group": "./dist/radio-group/index", - "van-row": "./dist/row/index", - "van-search": "./dist/search/index", "van-search-demo": "./dist/search/demo/index", - "van-sidebar": "./dist/sidebar/index", "van-sidebar-demo": "./dist/sidebar/demo/index", - "van-sidebar-item": "./dist/sidebar-item/index", - "van-slider": "./dist/slider/index", "van-slider-demo": "./dist/slider/demo/index", - "van-stepper": "./dist/stepper/index", "van-stepper-demo": "./dist/stepper/demo/index", - "van-steps": "./dist/steps/index", "van-steps-demo": "./dist/steps/demo/index", - "van-sticky": "./dist/sticky/index", "van-sticky-demo": "./dist/sticky/demo/index", - "van-submit-bar": "./dist/submit-bar/index", "van-submit-bar-demo": "./dist/submit-bar/demo/index", - "van-swipe-cell": "./dist/swipe-cell/index", "van-swipe-cell-demo": "./dist/swipe-cell/demo/index", - "van-uploader": "./dist/uploader/index", "van-uploader-demo": "./dist/uploader/demo/index", - "van-switch": "./dist/switch/index", "van-switch-demo": "./dist/switch/demo/index", - "van-tab": "./dist/tab/index", "van-tab-demo": "./dist/tab/demo/index", - "van-tabs": "./dist/tabs/index", - "van-tabbar": "./dist/tabbar/index", "van-tabbar-demo": "./dist/tabbar/demo/index", - "van-tabbar-item": "./dist/tabbar-item/index", - "van-tag": "./dist/tag/index", "van-tag-demo": "./dist/tag/demo/index", - "van-toast": "./dist/toast/index", "van-toast-demo": "./dist/toast/demo/index", - "van-transition": "./dist/transition/index", "van-transition-demo": "./dist/transition/demo/index", - "van-tree-select": "./dist/tree-select/index", "van-tree-select-demo": "./dist/tree-select/demo/index", - "van-datetime-picker": "./dist/datetime-picker/index", "van-datetime-picker-demo": "./dist/datetime-picker/demo/index", - "van-rate": "./dist/rate/index", "van-rate-demo": "./dist/rate/demo/index", - "van-collapse": "./dist/collapse/index", "van-collapse-demo": "./dist/collapse/demo/index", - "van-collapse-item": "./dist/collapse-item/index", - "van-picker": "./dist/picker/index", "van-picker-demo": "./dist/picker/demo/index", - "van-overlay": "./dist/overlay/index", "van-overlay-demo": "./dist/overlay/demo/index", - "van-circle": "./dist/circle/index", "van-circle-demo": "./dist/circle/demo/index", - "van-index-bar": "./dist/index-bar/index", "van-index-bar-demo": "./dist/index-bar/demo/index", - "van-index-anchor": "./dist/index-anchor/index", - "van-grid": "./dist/grid/index", "van-grid-demo": "./dist/grid/demo/index", - "van-grid-item": "./dist/grid-item/index", - "van-dropdown-menu": "./dist/dropdown-menu/index", "van-dropdown-menu-demo": "./dist/dropdown-menu/demo/index", - "van-dropdown-item": "./dist/dropdown-item/index", - "van-skeleton": "./dist/skeleton/index", "van-skeleton-demo": "./dist/skeleton/demo/index", - "van-calendar": "./dist/calendar/index", "van-calendar-demo": "./dist/calendar/demo/index", - "van-share-sheet": "./dist/share-sheet/index", "van-share-sheet-demo": "./dist/share-sheet/demo/index", - "van-config-provider": "./dist/config-provider/index", "van-config-provider-demo": "./dist/config-provider/demo/index" }, "sitemapLocation": "sitemap.json" diff --git a/example/pages/action-sheet/index.wxml b/example/pages/action-sheet/index.wxml index c574b5da..20c79f83 100644 --- a/example/pages/action-sheet/index.wxml +++ b/example/pages/action-sheet/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/area/index.wxml b/example/pages/area/index.wxml index 762dc53e..457bbc51 100644 --- a/example/pages/area/index.wxml +++ b/example/pages/area/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/button/index.wxml b/example/pages/button/index.wxml index e0638ef8..6820e8e4 100644 --- a/example/pages/button/index.wxml +++ b/example/pages/button/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/calendar/index.wxml b/example/pages/calendar/index.wxml index b760ab6b..50d72345 100644 --- a/example/pages/calendar/index.wxml +++ b/example/pages/calendar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/card/index.wxml b/example/pages/card/index.wxml index b3be7bb6..320fced3 100644 --- a/example/pages/card/index.wxml +++ b/example/pages/card/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/cell/index.wxml b/example/pages/cell/index.wxml index 93689ab5..ce9d5170 100644 --- a/example/pages/cell/index.wxml +++ b/example/pages/cell/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/checkbox/index.wxml b/example/pages/checkbox/index.wxml index 9a3e22d4..7d69caf9 100644 --- a/example/pages/checkbox/index.wxml +++ b/example/pages/checkbox/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/circle/index.wxml b/example/pages/circle/index.wxml index 29cc62a5..1a616ed2 100644 --- a/example/pages/circle/index.wxml +++ b/example/pages/circle/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/col/index.wxml b/example/pages/col/index.wxml index e2008cfa..94c25e53 100644 --- a/example/pages/col/index.wxml +++ b/example/pages/col/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/collapse/index.wxml b/example/pages/collapse/index.wxml index b6944fa0..1136f6d7 100644 --- a/example/pages/collapse/index.wxml +++ b/example/pages/collapse/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/config-provider/index.wxml b/example/pages/config-provider/index.wxml index 260a1ac7..c8419cb0 100644 --- a/example/pages/config-provider/index.wxml +++ b/example/pages/config-provider/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/count-down/index.wxml b/example/pages/count-down/index.wxml index d5fa784d..11d6cecf 100644 --- a/example/pages/count-down/index.wxml +++ b/example/pages/count-down/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/dashboard/index.js b/example/pages/dashboard/index.js index b48a761e..cc11dfda 100644 --- a/example/pages/dashboard/index.js +++ b/example/pages/dashboard/index.js @@ -1,8 +1,3 @@ -import list from '../../config'; import Page from '../../common/page'; -Page({ - data: { - list - }, -}); +Page(); diff --git a/example/pages/dashboard/index.wxml b/example/pages/dashboard/index.wxml index c07a5491..a0e9bc9b 100644 --- a/example/pages/dashboard/index.wxml +++ b/example/pages/dashboard/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/datetime-picker/index.wxml b/example/pages/datetime-picker/index.wxml index 4cfc1ab4..c8e5b95d 100644 --- a/example/pages/datetime-picker/index.wxml +++ b/example/pages/datetime-picker/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/dialog/index.wxml b/example/pages/dialog/index.wxml index 6921745b..a31cf455 100644 --- a/example/pages/dialog/index.wxml +++ b/example/pages/dialog/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/divider/index.wxml b/example/pages/divider/index.wxml index 39778490..b2bd6e6e 100644 --- a/example/pages/divider/index.wxml +++ b/example/pages/divider/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/dropdown-menu/index.wxml b/example/pages/dropdown-menu/index.wxml index 9f2813d0..9d25b3d0 100644 --- a/example/pages/dropdown-menu/index.wxml +++ b/example/pages/dropdown-menu/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/empty/index.wxml b/example/pages/empty/index.wxml index 29f239b9..8ed5b92a 100644 --- a/example/pages/empty/index.wxml +++ b/example/pages/empty/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/field/index.wxml b/example/pages/field/index.wxml index 26b32034..2fa975e6 100644 --- a/example/pages/field/index.wxml +++ b/example/pages/field/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/goods-action/index.wxml b/example/pages/goods-action/index.wxml index d78cf234..7f7c28f8 100644 --- a/example/pages/goods-action/index.wxml +++ b/example/pages/goods-action/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/grid/index.wxml b/example/pages/grid/index.wxml index 04f433f0..7cc62789 100644 --- a/example/pages/grid/index.wxml +++ b/example/pages/grid/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/icon/index.wxml b/example/pages/icon/index.wxml index ef139ded..1f7849f8 100644 --- a/example/pages/icon/index.wxml +++ b/example/pages/icon/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/image/index.wxml b/example/pages/image/index.wxml index 127c3598..d555e9b2 100644 --- a/example/pages/image/index.wxml +++ b/example/pages/image/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/index-bar/index.wxml b/example/pages/index-bar/index.wxml index 8b13a82a..cf1d4332 100644 --- a/example/pages/index-bar/index.wxml +++ b/example/pages/index-bar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/loading/index.wxml b/example/pages/loading/index.wxml index 7f313b0e..5d22eb2f 100644 --- a/example/pages/loading/index.wxml +++ b/example/pages/loading/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/nav-bar/index.wxml b/example/pages/nav-bar/index.wxml index 024f956e..af29f4cc 100644 --- a/example/pages/nav-bar/index.wxml +++ b/example/pages/nav-bar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/notice-bar/index.wxml b/example/pages/notice-bar/index.wxml index d84e1d4f..cf90c14f 100644 --- a/example/pages/notice-bar/index.wxml +++ b/example/pages/notice-bar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/notify/index.wxml b/example/pages/notify/index.wxml index 29eac634..37cd1327 100644 --- a/example/pages/notify/index.wxml +++ b/example/pages/notify/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/overlay/index.wxml b/example/pages/overlay/index.wxml index b8f74971..85eab347 100644 --- a/example/pages/overlay/index.wxml +++ b/example/pages/overlay/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/panel/index.wxml b/example/pages/panel/index.wxml index 2e681cf0..916ca9bc 100644 --- a/example/pages/panel/index.wxml +++ b/example/pages/panel/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/picker/index.wxml b/example/pages/picker/index.wxml index 08a7743b..103106d1 100644 --- a/example/pages/picker/index.wxml +++ b/example/pages/picker/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/popup/index.wxml b/example/pages/popup/index.wxml index fd33a985..7cd06468 100644 --- a/example/pages/popup/index.wxml +++ b/example/pages/popup/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/progress/index.wxml b/example/pages/progress/index.wxml index ff0df46f..ca0ffd1c 100644 --- a/example/pages/progress/index.wxml +++ b/example/pages/progress/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/radio/index.wxml b/example/pages/radio/index.wxml index ecc4a0bd..99ce2366 100644 --- a/example/pages/radio/index.wxml +++ b/example/pages/radio/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/rate/index.wxml b/example/pages/rate/index.wxml index 83af809d..03efa7af 100644 --- a/example/pages/rate/index.wxml +++ b/example/pages/rate/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/search/index.wxml b/example/pages/search/index.wxml index 8079da56..46db13dd 100644 --- a/example/pages/search/index.wxml +++ b/example/pages/search/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/share-sheet/index.wxml b/example/pages/share-sheet/index.wxml index c560ff7b..3df439a5 100644 --- a/example/pages/share-sheet/index.wxml +++ b/example/pages/share-sheet/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/sidebar/index.wxml b/example/pages/sidebar/index.wxml index 3316e8e8..917b5355 100644 --- a/example/pages/sidebar/index.wxml +++ b/example/pages/sidebar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/skeleton/index.wxml b/example/pages/skeleton/index.wxml index c84e5ec3..7f46a95f 100644 --- a/example/pages/skeleton/index.wxml +++ b/example/pages/skeleton/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/slider/index.wxml b/example/pages/slider/index.wxml index 7e03ef7f..82702051 100644 --- a/example/pages/slider/index.wxml +++ b/example/pages/slider/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/stepper/index.wxml b/example/pages/stepper/index.wxml index 34ac9353..a65edca5 100644 --- a/example/pages/stepper/index.wxml +++ b/example/pages/stepper/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/steps/index.wxml b/example/pages/steps/index.wxml index ff137196..e30d4962 100644 --- a/example/pages/steps/index.wxml +++ b/example/pages/steps/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/sticky/index.wxml b/example/pages/sticky/index.wxml index f98ee221..ed1e9e51 100644 --- a/example/pages/sticky/index.wxml +++ b/example/pages/sticky/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/submit-bar/index.wxml b/example/pages/submit-bar/index.wxml index 634f3580..f688bd11 100644 --- a/example/pages/submit-bar/index.wxml +++ b/example/pages/submit-bar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/swipe-cell/index.wxml b/example/pages/swipe-cell/index.wxml index 317c98be..59cfbf65 100644 --- a/example/pages/swipe-cell/index.wxml +++ b/example/pages/swipe-cell/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/switch/index.wxml b/example/pages/switch/index.wxml index 065d3ffe..876d0588 100644 --- a/example/pages/switch/index.wxml +++ b/example/pages/switch/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/tab/index.wxml b/example/pages/tab/index.wxml index 7600bfd3..5335f8b5 100644 --- a/example/pages/tab/index.wxml +++ b/example/pages/tab/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/tabbar/index.wxml b/example/pages/tabbar/index.wxml index 7c14aa38..f5fdbcd5 100644 --- a/example/pages/tabbar/index.wxml +++ b/example/pages/tabbar/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/tag/index.wxml b/example/pages/tag/index.wxml index ed48ac94..774a8899 100644 --- a/example/pages/tag/index.wxml +++ b/example/pages/tag/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/toast/index.wxml b/example/pages/toast/index.wxml index 99081a39..bb106198 100644 --- a/example/pages/toast/index.wxml +++ b/example/pages/toast/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/transition/index.wxml b/example/pages/transition/index.wxml index 5cc62eea..3272ec0c 100644 --- a/example/pages/transition/index.wxml +++ b/example/pages/transition/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/tree-select/index.wxml b/example/pages/tree-select/index.wxml index 1e3d91d2..44af85d4 100644 --- a/example/pages/tree-select/index.wxml +++ b/example/pages/tree-select/index.wxml @@ -1 +1 @@ - + \ No newline at end of file diff --git a/example/pages/uploader/index.wxml b/example/pages/uploader/index.wxml index 96ab2cc7..d5bd9cb0 100644 --- a/example/pages/uploader/index.wxml +++ b/example/pages/uploader/index.wxml @@ -1 +1 @@ - + \ No newline at end of file