mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-27 20:06:36 +08:00
Merge branch 'dev' into next
This commit is contained in:
commit
f79fee5297
12
README.md
12
README.md
@ -65,12 +65,20 @@ Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md) bef
|
|||||||
|
|
||||||
Modern browsers and Android 4.0+, iOS 8.0+.
|
Modern browsers and Android 4.0+, iOS 8.0+.
|
||||||
|
|
||||||
|
## Ecosystem
|
||||||
|
|
||||||
|
| Project | Description |
|
||||||
|
|-----|------|
|
||||||
|
| [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection |
|
||||||
|
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
||||||
|
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
|
||||||
|
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons |
|
||||||
|
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
* [Documentation](https://youzan.github.io/vant)
|
* [Documentation](https://youzan.github.io/vant)
|
||||||
* [Changelog](https://youzan.github.io/vant#/en-US/changelog)
|
* [Changelog](https://youzan.github.io/vant#/en-US/changelog)
|
||||||
* [Vant Demo](https://github.com/youzan/vant-demo)
|
|
||||||
* [Vant Weapp](https://github.com/youzan/vant-weapp)
|
|
||||||
|
|
||||||
## Preview
|
## Preview
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
🔥 <a href="https://youzan.github.io/vant">文档网站</a>
|
🔥 <a href="https://youzan.github.io/vant">文档网站</a>
|
||||||
|
|
||||||
🇬🇧 <a href="./README.md">英文版介绍</a>
|
|
||||||
|
|
||||||
🚀 <a href="https://github.com/youzan/vant-weapp" target="_blank">小程序版</a>
|
🚀 <a href="https://github.com/youzan/vant-weapp" target="_blank">小程序版</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -80,13 +78,21 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手
|
|||||||
- <a target="_blank" href="https://tech.youzan.com/tag/front-end/">团队博客</a>
|
- <a target="_blank" href="https://tech.youzan.com/tag/front-end/">团队博客</a>
|
||||||
- <a target="_blank" href="https://github.com/youzan">开源项目</a>
|
- <a target="_blank" href="https://github.com/youzan">开源项目</a>
|
||||||
|
|
||||||
|
## 生态
|
||||||
|
|
||||||
|
| 项目 | 描述 |
|
||||||
|
|-----|------|
|
||||||
|
| [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 |
|
||||||
|
| [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 |
|
||||||
|
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 |
|
||||||
|
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 |
|
||||||
|
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
|
||||||
|
|
||||||
## 链接
|
## 链接
|
||||||
|
|
||||||
* [详细文档](https://youzan.github.io/vant)
|
* [详细文档](https://youzan.github.io/vant)
|
||||||
* [更新日志](https://youzan.github.io/vant#/zh-CN/changelog)
|
* [更新日志](https://youzan.github.io/vant#/zh-CN/changelog)
|
||||||
* [码云镜像](https://gitee.com/organizations/vant-contrib)
|
* [码云镜像](https://gitee.com/organizations/vant-contrib)
|
||||||
* [Vant 示例仓库](https://github.com/youzan/vant-demo)
|
|
||||||
* [VantWeapp 小程序组件](https://github.com/youzan/vant-weapp)
|
|
||||||
|
|
||||||
## 手机预览
|
## 手机预览
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
presets: ['@vant/cli/preset']
|
presets: ['@vant/cli/preset'],
|
||||||
};
|
};
|
||||||
|
@ -1,52 +1,126 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### [v2.4.2-beta.2](https://github.com/youzan/vant/compare/v2.4.2-beta.1...v2.4.2-beta.2)
|
### [v2.4.6](https://github.com/youzan/vant/compare/v2.4.5...v2.4.6)
|
||||||
`2020-01-10`
|
`2020-02-01`
|
||||||
|
|
||||||
**Feature**
|
|
||||||
|
|
||||||
* Field: add formatter prop [#5534](https://github.com/youzan/vant/issues/5534)
|
|
||||||
* Swipe: add prev、next method [#5548](https://github.com/youzan/vant/issues/5548)
|
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
* Calendar: missing info when selected [#5536](https://github.com/youzan/vant/issues/5536)
|
* Picker: should watch columns change [#5614](https://github.com/youzan/vant/issues/5614)
|
||||||
* PullRefresh: should set height when using head-height [028747](https://github.com/youzan/vant/commit/028747c35471f33e8c2b0baa6fb8915510daac22)
|
|
||||||
|
|
||||||
|
|
||||||
### [v2.4.2-beta.1](https://github.com/youzan/vant/compare/v2.4.2-beta.0...v2.4.2-beta.1)
|
### [v2.4.5](https://github.com/youzan/vant/compare/v2.4.4...v2.4.5)
|
||||||
`2020-01-09`
|
`2020-02-01`
|
||||||
|
|
||||||
**Feature**
|
**Feature**
|
||||||
|
|
||||||
* Field: add digit type [#5524](https://github.com/youzan/vant/issues/5524)
|
* Picker: support cascade columns [#4247](https://github.com/youzan/vant/issues/4247)
|
||||||
* Sku: add properties support [#5525](https://github.com/youzan/vant/issues/5525)
|
* Slider: add button-size prop [1e9b8c](https://github.com/youzan/vant/commit/1e9b8c846674562d56ab638a0982baab4bb6870e)
|
||||||
* Calendar: scroll to current month when show [#5526](https://github.com/youzan/vant/issues/5526)
|
* Optimize the props type. The original number type props now support string.
|
||||||
|
|
||||||
|
**Style**
|
||||||
|
|
||||||
|
* DropdownItem: add @dropdown-item-z-index less var [6f4c6f](https://github.com/youzan/vant/commit/6f4c6f5aa6614559cfc24bc361e68c9c938bbb61)
|
||||||
|
* IndexBar: add @index-anchor-z-index less var [89ee8e](https://github.com/youzan/vant/commit/89ee8e38723dadb2daa6ee31c325cdd2ad03ba99)
|
||||||
|
* IndexBar: add @index-bar-sidebar-z-index less var [89ee8e](https://github.com/youzan/vant/commit/89ee8e38723dadb2daa6ee31c325cdd2ad03ba99)
|
||||||
|
* IndexBar: add @index-bar-index-active-color less var [0011db](https://github.com/youzan/vant/commit/0011db75365b60699ae140d85e54b9e477f46a22)
|
||||||
|
* Notify: add @notify-text-color less var [9dcf57](https://github.com/youzan/vant/commit/9dcf57c65f5e046318e953f2e8ce87918b1cb312)
|
||||||
|
* Overlay: add @overlay-z-index less var [95d19f](https://github.com/youzan/vant/commit/95d19f70d1c90efc752074ff764b07787d89cf1e)
|
||||||
|
* Rate: add @rate-icon-disabled-color less var [8b8471](https://github.com/youzan/vant/commit/8b8471945c4313735a5fe59402212f37a31acfea)
|
||||||
|
* Rate: add @rate-icon-full-color less var [5c804c](https://github.com/youzan/vant/commit/5c804cf920b75c5bdf962fa49eae31363783f32f)
|
||||||
|
* Rate: add @rate-icon-void-color less var [f90015](https://github.com/youzan/vant/commit/f90015efe7619af055b9ebd4c8be7da1f17b8da0)
|
||||||
|
* Slider: add @slider-bar-height less var [a5819c](https://github.com/youzan/vant/commit/a5819c286e06469bc41e8aa9e0ed44cc21625dad)
|
||||||
|
* Search: add @search-content-background-color less var [ea7419](https://github.com/youzan/vant/commit/ea74194990314bd1ff1e8237c221be92fdb8ae37)
|
||||||
|
* Step: add @step-active-color less var [9e7a68](https://github.com/youzan/vant/commit/9e7a6874141fa05f0158ca8006c268d0a3d92679)
|
||||||
|
* Tabbar: add @tabbar-z-index less var [0441f7](https://github.com/youzan/vant/commit/0441f7ba098aca24b797de29d10af8f47cf32d15)
|
||||||
|
* NavBar: add @nav-bar-z-index less var [a2d870](https://github.com/youzan/vant/commit/a2d870ad8ee4912226ec8871cc4c2d56ef870902)
|
||||||
|
* NumberKeyboard: add @number-keyboard-z-index less var [760938](https://github.com/youzan/vant/commit/760938962399e0589b4a258ff29e7fe2f3ba90f1)
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
* CouponList: incorrect click feedback [#5521](https://github.com/youzan/vant/issues/5521)
|
* ImagePreview: limit max-zoom when double clicking [1baa60](https://github.com/youzan/vant/commit/1baa60f2244b4605dc82f6dcf564671f5c623023)
|
||||||
* Field: should limit number input in iOS [#5520](https://github.com/youzan/vant/issues/5520)
|
* Popup: duration prop not work when position is center [44072e](https://github.com/youzan/vant/commit/44072e8c3f548cff78401780213ab7ef213372c3)
|
||||||
* Tabs: can not render line when wrapper is fixed [#5496](https://github.com/youzan/vant/issues/5496)
|
* Step: active-color should be effective for line [cfadce](https://github.com/youzan/vant/commit/cfadcefb0a1c29dfb1d940fbb7add746595158bd)
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.4.4](https://github.com/youzan/vant/compare/v2.4.3...v2.4.4)
|
||||||
|
`2020-01-24`
|
||||||
|
|
||||||
|
**Feature**
|
||||||
|
|
||||||
|
* Card: change thumb fit mode to cover [e766d5](https://github.com/youzan/vant/commit/e766d5d5743e7f492b3601ce4010b8524fb2b016)
|
||||||
|
* Calendar: add get-contaienr prop [#5609](https://github.com/youzan/vant/issues/5609)
|
||||||
|
* Calendar: add close-on-popstate prop [2b82dc](https://github.com/youzan/vant/commit/2b82dcc3dd2dba678aba5e0533e0ff6af7c55b11)
|
||||||
|
* CountDown: add change event [#5599](https://github.com/youzan/vant/issues/5599)
|
||||||
|
* GoodsActionButton: add icon prop [b83bed](https://github.com/youzan/vant/commit/b83bed3b6c41d0896386b3c4b6380c9568bd3ef2)
|
||||||
|
|
||||||
|
**Bug Fixes**
|
||||||
|
|
||||||
|
* Sku: get-container can be string type [#5608](https://github.com/youzan/vant/issues/5608)
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.4.3](https://github.com/youzan/vant/compare/v2.4.3-beta.0...v2.4.3)
|
||||||
|
`2020-01-19`
|
||||||
|
|
||||||
|
**Feature**
|
||||||
|
|
||||||
|
* Calendar: add max-range、range-prompt prop [#5583](https://github.com/youzan/vant/issues/5583)
|
||||||
|
* ImagePreview: add @image-preview-index-text-shadow var [e2f302](https://github.com/youzan/vant/commit/e2f30242eaaebd36d9816e2746fe6c44323e6aca)
|
||||||
|
* Stepper: add long-press prop [2f3ec6](https://github.com/youzan/vant/commit/2f3ec6a3d48a9d56f8127d27d51c3337f6e72cab)
|
||||||
|
* Swipe: pause autoplay when page hidden [113157](https://github.com/youzan/vant/commit/11315787ec980767973a3fded50fb5858e51e298)
|
||||||
|
|
||||||
**Improvement**
|
**Improvement**
|
||||||
|
|
||||||
* CouponList: update style [#5501](https://github.com/youzan/vant/issues/5501)
|
* Icon: update share icon [2f77ac](https://github.com/youzan/vant/commit/2f77acfc6cef23ea664defc38c4cd806ceca1ee4)
|
||||||
* AddressList: update style [#5507](https://github.com/youzan/vant/issues/5507)
|
* Field: imporve readonly cursor [60173d](https://github.com/youzan/vant/commit/60173dd6bc004339333c50218d7c6b2f6c1bc07b)
|
||||||
|
* Stepper: improve disable-input behavior [959eca](https://github.com/youzan/vant/commit/959eca136c4ca6a39e22d36512db74b93ad100c6)
|
||||||
|
|
||||||
### [v2.4.2-beta.0](https://github.com/youzan/vant/compare/v2.4.1...v2.4.2-beta.0)
|
|
||||||
`2020-01-06`
|
|
||||||
|
|
||||||
**Feature**
|
|
||||||
|
|
||||||
* Image: add error-icon prop [#5470](https://github.com/youzan/vant/issues/5470)
|
|
||||||
* Image: add loading-icon prop [#5469](https://github.com/youzan/vant/issues/5469)
|
|
||||||
* AddressEdit: show error message in field [#5479](https://github.com/youzan/vant/issues/5479)
|
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
|
* Calendar: should show range prompt after select [ff0901](https://github.com/youzan/vant/commit/ff09011e0ef18ab29dd70b51f412625dd10bb4cb)
|
||||||
|
* GoodsAction: should set wrapper height [#5593](https://github.com/youzan/vant/issues/5593)
|
||||||
|
|
||||||
|
**Types**
|
||||||
|
|
||||||
|
* Calendar: fix missing type definition [#5588](https://github.com/youzan/vant/issues/5588)
|
||||||
|
* Toast: incorrect definition of setDefaultOptions method [#5582](https://github.com/youzan/vant/issues/5582)
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.4.2](https://github.com/youzan/vant/compare/v2.4.2-beta.1...v2.4.2)
|
||||||
|
`2020-01-14`
|
||||||
|
|
||||||
|
**Feature**
|
||||||
|
|
||||||
|
* Sku: add properties prop [#5525](https://github.com/youzan/vant/issues/5525)
|
||||||
|
* Field: add digit type [#5524](https://github.com/youzan/vant/issues/5524)
|
||||||
|
* Image: add error-icon prop [#5470](https://github.com/youzan/vant/issues/5470)
|
||||||
|
* Image: add loading-icon prop [#5469](https://github.com/youzan/vant/issues/5469)
|
||||||
|
* Field: add formatter prop [#5534](https://github.com/youzan/vant/issues/5534)
|
||||||
|
* Swipe: add prev、next method [#5548](https://github.com/youzan/vant/issues/5548)
|
||||||
|
* GoodsAcitonIcon: add color prop [#5576](https://github.com/youzan/vant/issues/5576)
|
||||||
|
|
||||||
|
**Improvement**
|
||||||
|
|
||||||
|
* AddressEdit: show error message in field [#5479](https://github.com/youzan/vant/issues/5479)
|
||||||
|
* ActionSheet: update close icon style [#5574](https://github.com/youzan/vant/issues/5574)
|
||||||
|
* AddressList: update style [#5507](https://github.com/youzan/vant/issues/5507)
|
||||||
|
* CouponList: update style [#5501](https://github.com/youzan/vant/issues/5501)
|
||||||
|
* Calendar: scroll to current month when show [#5526](https://github.com/youzan/vant/issues/5526)
|
||||||
|
* ImagePreview: improve error image style [#5570](https://github.com/youzan/vant/issues/5570)
|
||||||
|
* improve cursor of all components [c1a535](https://github.com/youzan/vant/commit/c1a535b0dd9470f8eb526e86aa59cf6dec022f3a)
|
||||||
|
|
||||||
|
**Bug Fixes**
|
||||||
|
|
||||||
|
* Button: should not have click feedback when loading [0a70d3](https://github.com/youzan/vant/commit/0a70d344124ef756a73ea9edfee07303f394d880)
|
||||||
* Card: thumb image border-radius become effective [#5480](https://github.com/youzan/vant/issues/5480)
|
* Card: thumb image border-radius become effective [#5480](https://github.com/youzan/vant/issues/5480)
|
||||||
|
* Calendar: incorrect month title after auto scroll [#5569](https://github.com/youzan/vant/issues/5569)
|
||||||
|
* Calendar: missing info when selected [#5536](https://github.com/youzan/vant/issues/5536)
|
||||||
|
* Checkbox: only the icon is clickable when label-disabled [3d10d4](https://github.com/youzan/vant/commit/3d10d42fccadd1b9df46860d758a91f7825073e9)
|
||||||
|
* CouponList: incorrect click feedback [#5521](https://github.com/youzan/vant/issues/5521)
|
||||||
|
* Field: should limit number input in iOS [#5520](https://github.com/youzan/vant/issues/5520)
|
||||||
|
* ImagePreview: disable desktop browser image drag [#4487](https://github.com/youzan/vant/issues/4487)
|
||||||
|
* Picker: optimize the click experience [5cbb9e](https://github.com/youzan/vant/commit/5cbb9e29989ac58d44a4ec503cbb984269c8f18e)
|
||||||
|
* PullRefresh: should set height when using head-height [028747](https://github.com/youzan/vant/commit/028747c35471f33e8c2b0baa6fb8915510daac22)
|
||||||
|
* Tabs: can not render line when wrapper is fixed [#5496](https://github.com/youzan/vant/issues/5496)
|
||||||
|
|
||||||
|
|
||||||
### [v2.4.1](https://github.com/youzan/vant/compare/v2.4.0...v2.4.1)
|
### [v2.4.1](https://github.com/youzan/vant/compare/v2.4.0...v2.4.1)
|
||||||
|
@ -10,54 +10,126 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
|
|||||||
- 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。
|
- 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。
|
||||||
- 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。
|
- 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。
|
||||||
|
|
||||||
### [v2.4.2-beta.2](https://github.com/youzan/vant/compare/v2.4.2-beta.1...v2.4.2-beta.2)
|
|
||||||
`2020-01-10`
|
|
||||||
|
|
||||||
**Feature**
|
### [v2.4.6](https://github.com/youzan/vant/compare/v2.4.5...v2.4.6)
|
||||||
|
`2020-02-01`
|
||||||
* Field: 新增 formatter 属性 [#5534](https://github.com/youzan/vant/issues/5534)
|
|
||||||
* Swipe: 新增 prev、next 方法 [#5548](https://github.com/youzan/vant/issues/5548)
|
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
* Calendar: 修复选中的日期无法展示提示信息的问题 [#5536](https://github.com/youzan/vant/issues/5536)
|
* Picker: 修复更新 columns 数据不生效的问题 [#5614](https://github.com/youzan/vant/issues/5614)
|
||||||
* PullRefresh:修复 head-height 属性未正确设置高度的问题 [028747](https://github.com/youzan/vant/commit/028747c35471f33e8c2b0baa6fb8915510daac22)
|
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.4.5](https://github.com/youzan/vant/compare/v2.4.4...v2.4.5)
|
||||||
### [v2.4.2-beta.1](https://github.com/youzan/vant/compare/v2.4.2-beta.0...v2.4.2-beta.1)
|
`2020-02-01`
|
||||||
`2020-01-09`
|
|
||||||
|
|
||||||
**Feature**
|
**Feature**
|
||||||
|
|
||||||
* Field: 新增 digit 类型 [#5524](https://github.com/youzan/vant/issues/5524)
|
* Picker: 支持级联选择 [#4247](https://github.com/youzan/vant/issues/4247)
|
||||||
* Sku: 支持 properties 数据结构 [#5525](https://github.com/youzan/vant/issues/5525)
|
* Slider: 新增 button-size 属性 [1e9b8c](https://github.com/youzan/vant/commit/1e9b8c846674562d56ab638a0982baab4bb6870e)
|
||||||
* Calendar: 弹出时自动滚动到当前选中的日期 [#5526](https://github.com/youzan/vant/issues/5526)
|
* 优化 props 类型,原有 number 类型的 props 现在支持传入 string
|
||||||
|
|
||||||
|
**Style**
|
||||||
|
|
||||||
|
* DropdownItem: 新增 @dropdown-item-z-index 变量 [6f4c6f](https://github.com/youzan/vant/commit/6f4c6f5aa6614559cfc24bc361e68c9c938bbb61)
|
||||||
|
* IndexBar: 新增 @index-anchor-z-index 变量 [89ee8e](https://github.com/youzan/vant/commit/89ee8e38723dadb2daa6ee31c325cdd2ad03ba99)
|
||||||
|
* IndexBar: 新增 @index-bar-sidebar-z-index 变量 [89ee8e](https://github.com/youzan/vant/commit/89ee8e38723dadb2daa6ee31c325cdd2ad03ba99)
|
||||||
|
* IndexBar: 新增 @index-bar-index-active-color 变量 [0011db](https://github.com/youzan/vant/commit/0011db75365b60699ae140d85e54b9e477f46a22)
|
||||||
|
* Notify: 新增 @notify-text-color 变量 [9dcf57](https://github.com/youzan/vant/commit/9dcf57c65f5e046318e953f2e8ce87918b1cb312)
|
||||||
|
* Overlay: 新增 @overlay-z-index 变量 [95d19f](https://github.com/youzan/vant/commit/95d19f70d1c90efc752074ff764b07787d89cf1e)
|
||||||
|
* Rate: 新增 @rate-icon-disabled-color 变量 [8b8471](https://github.com/youzan/vant/commit/8b8471945c4313735a5fe59402212f37a31acfea)
|
||||||
|
* Rate: 新增 @rate-icon-full-color 变量 [5c804c](https://github.com/youzan/vant/commit/5c804cf920b75c5bdf962fa49eae31363783f32f)
|
||||||
|
* Rate: 新增 @rate-icon-void-color 变量 [f90015](https://github.com/youzan/vant/commit/f90015efe7619af055b9ebd4c8be7da1f17b8da0)
|
||||||
|
* Slider: 新增 @slider-bar-height 变量 [a5819c](https://github.com/youzan/vant/commit/a5819c286e06469bc41e8aa9e0ed44cc21625dad)
|
||||||
|
* Search: 新增 @search-content-background-color 变量 [ea7419](https://github.com/youzan/vant/commit/ea74194990314bd1ff1e8237c221be92fdb8ae37)
|
||||||
|
* Step: 新增 @step-active-color 变量 [9e7a68](https://github.com/youzan/vant/commit/9e7a6874141fa05f0158ca8006c268d0a3d92679)
|
||||||
|
* Tabbar: 新增 @tabbar-z-index 变量 [0441f7](https://github.com/youzan/vant/commit/0441f7ba098aca24b797de29d10af8f47cf32d15)
|
||||||
|
* NavBar: 新增 @nav-bar-z-index 变量 [a2d870](https://github.com/youzan/vant/commit/a2d870ad8ee4912226ec8871cc4c2d56ef870902)
|
||||||
|
* NumberKeyboard: 新增 @number-keyboard-z-index 变量 [760938](https://github.com/youzan/vant/commit/760938962399e0589b4a258ff29e7fe2f3ba90f1)
|
||||||
|
|
||||||
|
**Bug Fixes**
|
||||||
|
|
||||||
|
* ImagePreview: 修复双击缩放时 max-zoom 属性不生效的问题 [1baa60](https://github.com/youzan/vant/commit/1baa60f2244b4605dc82f6dcf564671f5c623023)
|
||||||
|
* Popup: 修复 position 为 center 时 duration 属性不生效的问题 [44072e](https://github.com/youzan/vant/commit/44072e8c3f548cff78401780213ab7ef213372c3)
|
||||||
|
* Step: 修复 active-color 未改变分隔线颜色的问题 [cfadce](https://github.com/youzan/vant/commit/cfadcefb0a1c29dfb1d940fbb7add746595158bd)
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.4.4](https://github.com/youzan/vant/compare/v2.4.3...v2.4.4) 🐭
|
||||||
|
`2020-01-24`
|
||||||
|
|
||||||
|
**Feature**
|
||||||
|
|
||||||
|
* Card: 优化图片拉伸模式 [e766d5](https://github.com/youzan/vant/commit/e766d5d5743e7f492b3601ce4010b8524fb2b016)
|
||||||
|
* Calendar: 新增 get-contaienr 属性 [#5609](https://github.com/youzan/vant/issues/5609)
|
||||||
|
* Calendar: 新增 close-on-popstate 属性 [2b82dc](https://github.com/youzan/vant/commit/2b82dcc3dd2dba678aba5e0533e0ff6af7c55b11)
|
||||||
|
* CountDown: 新增 change 事件 [#5599](https://github.com/youzan/vant/issues/5599)
|
||||||
|
* GoodsActionButton: 新增 icon 属性 [b83bed](https://github.com/youzan/vant/commit/b83bed3b6c41d0896386b3c4b6380c9568bd3ef2)
|
||||||
|
|
||||||
|
**Bug Fixes**
|
||||||
|
|
||||||
|
* Sku: 修复 get-container 属性不能为 string 类型的问题 [#5608](https://github.com/youzan/vant/issues/5608)
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.4.3](https://github.com/youzan/vant/compare/v2.4.3-beta.0...v2.4.3)
|
||||||
|
`2020-01-19`
|
||||||
|
|
||||||
|
**Feature**
|
||||||
|
|
||||||
|
* Swipe: 页面隐藏时暂停自动轮播 [113157](https://github.com/youzan/vant/commit/11315787ec980767973a3fded50fb5858e51e298)
|
||||||
|
* Stepper: 新增 long-press 属性 [2f3ec6](https://github.com/youzan/vant/commit/2f3ec6a3d48a9d56f8127d27d51c3337f6e72cab)
|
||||||
|
* Calendar: 新增 max-range、range-prompt 属性 [#5583](https://github.com/youzan/vant/issues/5583)
|
||||||
|
* ImagePreview: 新增 @image-preview-index-text-shadow 变量 [e2f302](https://github.com/youzan/vant/commit/e2f30242eaaebd36d9816e2746fe6c44323e6aca)
|
||||||
|
|
||||||
**Improvement**
|
**Improvement**
|
||||||
|
|
||||||
* CouponList: 优化样式细节 [#5501](https://github.com/youzan/vant/issues/5501)
|
* Icon: 更新 share 图标 [2f77ac](https://github.com/youzan/vant/commit/2f77acfc6cef23ea664defc38c4cd806ceca1ee4)
|
||||||
* AddressList: 优化样式细节 [#5507](https://github.com/youzan/vant/issues/5507)
|
* Field: 优化 readonly 状态下的光标类型 [60173d](https://github.com/youzan/vant/commit/60173dd6bc004339333c50218d7c6b2f6c1bc07b)
|
||||||
|
* Stepper: 优化 disable-input 状态下的输入框颜色 [959eca](https://github.com/youzan/vant/commit/959eca136c4ca6a39e22d36512db74b93ad100c6)
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
* CouponList: 修复点击反馈区域错误的问题 [#5521](https://github.com/youzan/vant/issues/5521)
|
* GoodsAction: 修复未设置容器高度的问题 [#5593](https://github.com/youzan/vant/issues/5593)
|
||||||
* Tabs: 修复容器设置 fixed 布局时无法渲染底部条的问题 [#5496](https://github.com/youzan/vant/issues/5496)
|
|
||||||
* Field: 修复 type 为 number 时在 iOS 上仍然能输入非数字字符的问题 [#5520](https://github.com/youzan/vant/issues/5520)
|
**Types**
|
||||||
|
|
||||||
|
* Calendar: 新增类型定义 [dac60c](https://github.com/youzan/vant/commit/dac60c8a37d3b2b3686dc25c1c34b4029a963d1b)
|
||||||
|
* Toast: 修复 setDefaultOptions 方法参数定义错误 [#5582](https://github.com/youzan/vant/issues/5582)
|
||||||
|
|
||||||
|
|
||||||
### [v2.4.2-beta.0](https://github.com/youzan/vant/compare/v2.4.1...v2.4.2-beta.0)
|
### [v2.4.2](https://github.com/youzan/vant/compare/v2.4.2-beta.1...v2.4.2)
|
||||||
`2020-01-06`
|
`2020-01-14`
|
||||||
|
|
||||||
**Feature**
|
**Feature**
|
||||||
|
|
||||||
|
* Sku: 新增 properties 属性 [#5525](https://github.com/youzan/vant/issues/5525)
|
||||||
|
* Field: 新增 digit 类型 [#5524](https://github.com/youzan/vant/issues/5524)
|
||||||
|
* Field: 新增 formatter 属性 [#5534](https://github.com/youzan/vant/issues/5534)
|
||||||
* Image: 新增 error-icon 属性 [#5470](https://github.com/youzan/vant/issues/5470)
|
* Image: 新增 error-icon 属性 [#5470](https://github.com/youzan/vant/issues/5470)
|
||||||
* Image: 新增 loading-icon 属性 [#5469](https://github.com/youzan/vant/issues/5469)
|
* Image: 新增 loading-icon 属性 [#5469](https://github.com/youzan/vant/issues/5469)
|
||||||
|
* Swipe: 新增 prev、next 方法 [#5548](https://github.com/youzan/vant/issues/5548)
|
||||||
|
* GoodsAcitonIcon: 新增 color 属性 [#5576](https://github.com/youzan/vant/issues/5576)
|
||||||
|
|
||||||
|
**Improvement**
|
||||||
|
|
||||||
|
* AddressList: 优化样式细节 [#5507](https://github.com/youzan/vant/issues/5507)
|
||||||
* AddressEdit: 优化错误提示展示方式 [#5479](https://github.com/youzan/vant/issues/5479)
|
* AddressEdit: 优化错误提示展示方式 [#5479](https://github.com/youzan/vant/issues/5479)
|
||||||
|
* ActionSheet: 优化关闭按钮样式 [#5574](https://github.com/youzan/vant/issues/5574)
|
||||||
|
* CouponList: 优化样式细节 [#5501](https://github.com/youzan/vant/issues/5501)
|
||||||
|
* Calendar: 弹出时自动滚动到当前选中的日期 [#5526](https://github.com/youzan/vant/issues/5526)
|
||||||
|
* ImagePreview: 优化图片加载失败提示样式 [#5570](https://github.com/youzan/vant/issues/5570)
|
||||||
|
* 优化所有组件的光标类型 [c1a535](https://github.com/youzan/vant/commit/c1a535b0dd9470f8eb526e86aa59cf6dec022f3a)
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
|
* Button: 修复加载状态下仍会有点击反馈的问题 [0a70d3](https://github.com/youzan/vant/commit/0a70d344124ef756a73ea9edfee07303f394d880)
|
||||||
* Card: 修复图片圆角样式未生效的问题 [#5480](https://github.com/youzan/vant/issues/5480)
|
* Card: 修复图片圆角样式未生效的问题 [#5480](https://github.com/youzan/vant/issues/5480)
|
||||||
|
* Calendar: 修复选中的日期无法展示提示信息的问题 [#5536](https://github.com/youzan/vant/issues/5536)
|
||||||
|
* Checkbox: 修复设置 label-disabled 后空白区域仍然可以点击的问题 [3d10d4](https://github.com/youzan/vant/commit/3d10d42fccadd1b9df46860d758a91f7825073e9)
|
||||||
|
* CouponList: 修复点击反馈区域错误的问题 [#5521](https://github.com/youzan/vant/issues/5521)
|
||||||
|
* Field: 修复 type 为 number 时在 iOS 上仍然能输入非数字字符的问题 [#5520](https://github.com/youzan/vant/issues/5520)
|
||||||
|
* ImagePreview: 修复在桌面端使用时无法拖拽的问题 [#4487](https://github.com/youzan/vant/issues/4487)
|
||||||
|
* Picker: 修复点击事件偶尔会丢失的问题 [5cbb9e](https://github.com/youzan/vant/commit/5cbb9e29989ac58d44a4ec503cbb984269c8f18e)
|
||||||
|
* PullRefresh:修复 head-height 属性未正确设置高度的问题 [028747](https://github.com/youzan/vant/commit/028747c35471f33e8c2b0baa6fb8915510daac22)
|
||||||
|
* Tabs: 修复容器设置 fixed 布局时无法渲染底部条的问题 [#5496](https://github.com/youzan/vant/issues/5496)
|
||||||
|
|
||||||
|
|
||||||
### [v2.4.1](https://github.com/youzan/vant/compare/v2.4.0...v2.4.1)
|
### [v2.4.1](https://github.com/youzan/vant/compare/v2.4.0...v2.4.1)
|
||||||
|
@ -29,12 +29,20 @@ Please make sure to read the [Contributing Guide](https://github.com/youzan/vant
|
|||||||
|
|
||||||
Modern browsers and Android 4.0+, iOS 8.0+.
|
Modern browsers and Android 4.0+, iOS 8.0+.
|
||||||
|
|
||||||
|
### Ecosystem
|
||||||
|
|
||||||
|
| Project | Description |
|
||||||
|
|-----|------|
|
||||||
|
| [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection |
|
||||||
|
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
||||||
|
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
|
||||||
|
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons |
|
||||||
|
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
|
||||||
|
|
||||||
### Links
|
### Links
|
||||||
|
|
||||||
* [Feedback](https://github.com/youzan/vant/issues)
|
* [Feedback](https://github.com/youzan/vant/issues)
|
||||||
* [Changelog](#/en-US/changelog)
|
* [Changelog](#/en-US/changelog)
|
||||||
* [Vant Demo](https://github.com/youzan/vant-demo)
|
|
||||||
* [Vant Weapp](https://github.com/youzan/vant-weapp)
|
|
||||||
|
|
||||||
### LICENSE
|
### LICENSE
|
||||||
|
|
||||||
|
@ -45,13 +45,21 @@
|
|||||||
- <a target="_blank" href="https://tech.youzan.com/tag/front-end/">团队博客</a>
|
- <a target="_blank" href="https://tech.youzan.com/tag/front-end/">团队博客</a>
|
||||||
- <a target="_blank" href="https://github.com/youzan">开源项目</a>
|
- <a target="_blank" href="https://github.com/youzan">开源项目</a>
|
||||||
|
|
||||||
|
### 生态
|
||||||
|
|
||||||
|
| 项目 | 描述 |
|
||||||
|
|-----|------|
|
||||||
|
| [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 |
|
||||||
|
| [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 |
|
||||||
|
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 |
|
||||||
|
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 |
|
||||||
|
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
|
||||||
|
|
||||||
### 链接
|
### 链接
|
||||||
|
|
||||||
* [意见反馈](https://github.com/youzan/vant/issues)
|
* [意见反馈](https://github.com/youzan/vant/issues)
|
||||||
* [更新日志](#/zh-CN/changelog)
|
* [更新日志](#/zh-CN/changelog)
|
||||||
* [码云镜像](https://gitee.com/organizations/vant-contrib)
|
* [码云镜像](https://gitee.com/organizations/vant-contrib)
|
||||||
* [Vant 示例仓库](https://github.com/youzan/vant-demo)
|
|
||||||
* [VantWeapp 小程序组件](https://github.com/youzan/vant-weapp)
|
|
||||||
|
|
||||||
### 开源协议
|
### 开源协议
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
### 脚手架
|
### 脚手架
|
||||||
|
|
||||||
推荐使用 Vue 官方提供的脚手架 [Vue Cli](https://cli.vuejs.org/zh/) 创建项目
|
在新项目中使用 Vant 时,推荐使用 Vue 官方提供的脚手架 [Vue Cli](https://cli.vuejs.org/zh/) 创建项目
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 安装 Vue Cli
|
# 安装 Vue Cli
|
||||||
@ -19,7 +19,9 @@ vue ui
|
|||||||
|
|
||||||
在图形化界面中,点击`依赖` -> `安装依赖`,然后将 `vant` 添加到依赖中即可。
|
在图形化界面中,点击`依赖` -> `安装依赖`,然后将 `vant` 添加到依赖中即可。
|
||||||
|
|
||||||
### 安装
|
### 通过 npm 安装
|
||||||
|
|
||||||
|
在现有项目中使用 Vant 时,可以通过`npm`或`yarn`安装
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 通过 npm 安装
|
# 通过 npm 安装
|
||||||
@ -189,3 +191,28 @@ iPhone X 等机型底部存在底部指示条,指示条的操作区域与页
|
|||||||
```
|
```
|
||||||
|
|
||||||
<img src="https://b.yzcdn.cn/vant/safearea.png" style="margin-top: 30px;">
|
<img src="https://b.yzcdn.cn/vant/safearea.png" style="margin-top: 30px;">
|
||||||
|
|
||||||
|
### 组件实例方法
|
||||||
|
|
||||||
|
Vant 中的许多组件提供了实例方法,调用实例方法时,我们需要通过 [ref](https://cn.vuejs.org/v2/api/#ref) 来注册组件引用信息,引用信息将会注册在父组件的`$refs`对象上。注册完成后,我们可以通过`this.$refs.xxx`访问到对应的组件实例,并调用上面的实例方法。
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- 将该组件绑定到 this.$refs.checkbox 上 -->
|
||||||
|
<van-checkbox v-model="checked" ref="checkbox">
|
||||||
|
复选框
|
||||||
|
</van-checkbox>
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
checked: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// 注意:组件挂载后才能访问到 ref 对象
|
||||||
|
mounted() {
|
||||||
|
this.$refs.checkbox.toggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -6,16 +6,18 @@ import { camelize } from '../../src/utils/format/string';
|
|||||||
import enUS from '../../src/locale/lang/en-US';
|
import enUS from '../../src/locale/lang/en-US';
|
||||||
|
|
||||||
Vue.use(Lazyload, {
|
Vue.use(Lazyload, {
|
||||||
lazyComponent: true
|
lazyComponent: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
Locale.add({
|
Locale.add({
|
||||||
'en-US': enUS
|
'en-US': enUS,
|
||||||
});
|
});
|
||||||
|
|
||||||
// flag for vant-weapp demos
|
// flag for vant-weapp demos
|
||||||
const isWeapp = location.search.indexOf('weapp=1') !== -1;
|
const isWeapp = location.search.indexOf('weapp=1') !== -1;
|
||||||
|
|
||||||
|
let demoUid = 0;
|
||||||
|
|
||||||
// helper for demo locales
|
// helper for demo locales
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
computed: {
|
computed: {
|
||||||
@ -33,10 +35,14 @@ Vue.mixin({
|
|||||||
|
|
||||||
isWeapp() {
|
isWeapp() {
|
||||||
return isWeapp;
|
return isWeapp;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
|
if (!this.$options.name) {
|
||||||
|
this.$options.name = `demo-${demoUid++}`;
|
||||||
|
}
|
||||||
|
|
||||||
const { i18n, name } = this.$options;
|
const { i18n, name } = this.$options;
|
||||||
|
|
||||||
if (i18n && name) {
|
if (i18n && name) {
|
||||||
@ -49,7 +55,7 @@ Vue.mixin({
|
|||||||
|
|
||||||
Locale.add(locales);
|
Locale.add(locales);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// switch lang after routing
|
// switch lang after routing
|
||||||
@ -91,7 +97,7 @@ Locale.add({
|
|||||||
advancedUsage: '高级用法',
|
advancedUsage: '高级用法',
|
||||||
loadingStatus: '加载状态',
|
loadingStatus: '加载状态',
|
||||||
usernamePlaceholder: '请输入用户名',
|
usernamePlaceholder: '请输入用户名',
|
||||||
passwordPlaceholder: '请输入密码'
|
passwordPlaceholder: '请输入密码',
|
||||||
},
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
add: 'Add',
|
add: 'Add',
|
||||||
@ -119,6 +125,6 @@ Locale.add({
|
|||||||
basicUsage: 'Basic Usage',
|
basicUsage: 'Basic Usage',
|
||||||
advancedUsage: 'Advanced Usage',
|
advancedUsage: 'Advanced Usage',
|
||||||
usernamePlaceholder: 'Username',
|
usernamePlaceholder: 'Username',
|
||||||
passwordPlaceholder: 'Password'
|
passwordPlaceholder: 'Password',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vant",
|
"name": "vant",
|
||||||
"version": "2.4.2-beta.2",
|
"version": "2.4.7-beta.0",
|
||||||
"description": "Mobile UI Components built on Vue",
|
"description": "Mobile UI Components built on Vue",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -19,7 +19,6 @@
|
|||||||
"test": "vant-cli test",
|
"test": "vant-cli test",
|
||||||
"build": "vant-cli build",
|
"build": "vant-cli build",
|
||||||
"release": "vant-cli release",
|
"release": "vant-cli release",
|
||||||
"changelog": "vant-cli changelog",
|
|
||||||
"test:watch": "vant-cli test --watch",
|
"test:watch": "vant-cli test --watch",
|
||||||
"release:site": "sh docs/site/release.sh",
|
"release:site": "sh docs/site/release.sh",
|
||||||
"test:coverage": "open test/coverage/index.html"
|
"test:coverage": "open test/coverage/index.html"
|
||||||
@ -31,6 +30,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
"*.{ts,tsx,js,vue,less}": [
|
||||||
|
"prettier --write",
|
||||||
|
"git add"
|
||||||
|
],
|
||||||
"*.{ts,tsx,js,vue}": [
|
"*.{ts,tsx,js,vue}": [
|
||||||
"eslint --fix",
|
"eslint --fix",
|
||||||
"git add"
|
"git add"
|
||||||
@ -52,7 +55,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "7.x",
|
"@babel/runtime": "7.x",
|
||||||
"@vant/icons": "1.2.0",
|
"@vant/icons": "1.2.1",
|
||||||
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
|
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
|
||||||
"vue-lazyload": "1.2.3"
|
"vue-lazyload": "1.2.3"
|
||||||
},
|
},
|
||||||
@ -60,7 +63,7 @@
|
|||||||
"vue": ">= 2.5.22"
|
"vue": ">= 2.5.22"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vant/cli": "^2.1.6",
|
"@vant/cli": "^2.2.2",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-template-compiler": "^2.6.11"
|
"vue-template-compiler": "^2.6.11"
|
||||||
},
|
},
|
||||||
@ -86,7 +89,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"singleQuote": true
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"Android >= 4.0",
|
"Android >= 4.0",
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: ['@vant/cli/preset'],
|
||||||
|
};
|
@ -0,0 +1,11 @@
|
|||||||
|
# 介绍
|
||||||
|
|
||||||
|
### 关于
|
||||||
|
|
||||||
|
这是一段组件库的介绍
|
||||||
|
|
||||||
|
### 特性
|
||||||
|
|
||||||
|
- 特性一
|
||||||
|
- 特性二
|
||||||
|
- 特性三
|
@ -0,0 +1,11 @@
|
|||||||
|
# 快速上手
|
||||||
|
|
||||||
|
### 安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 通过 npm 安装
|
||||||
|
npm i <%= name %> -S
|
||||||
|
|
||||||
|
# 通过 yarn 安装
|
||||||
|
yarn add <%= name %>
|
||||||
|
```
|
@ -0,0 +1,4 @@
|
|||||||
|
es
|
||||||
|
lib
|
||||||
|
dist
|
||||||
|
node_modules
|
@ -0,0 +1,17 @@
|
|||||||
|
*.log*
|
||||||
|
.cache
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# npm
|
||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
# dist file
|
||||||
|
es
|
||||||
|
lib
|
||||||
|
site
|
||||||
|
|
||||||
|
# test
|
||||||
|
test/coverage
|
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"name": "<%= name %>",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "lib/<%= name %>.js",
|
||||||
|
"style": "lib/index.css",
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"es"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vant-cli dev",
|
||||||
|
"test": "vant-cli test",
|
||||||
|
"lint": "vant-cli lint",
|
||||||
|
"build": "vant-cli build",
|
||||||
|
"release": "vant-cli release",
|
||||||
|
"test:coverage": "open test/coverage/index.html",
|
||||||
|
"build-site": "vant-cli build-site && gh-pages -d site"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "lint-staged",
|
||||||
|
"commit-msg": "vant-cli commit-lint"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{ts,tsx,js,jsx,vue}": [
|
||||||
|
"eslint --fix",
|
||||||
|
"git add"
|
||||||
|
],
|
||||||
|
"*.{vue,css,less,scss}": [
|
||||||
|
"stylelint --fix",
|
||||||
|
"git add"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"vue": "^2.6.11",
|
||||||
|
"vue-template-compiler": "^2.6.11"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vant/cli": "^2.0.0",
|
||||||
|
"babel-plugin-import": "^1.13.0",
|
||||||
|
"vue": "^2.6.11",
|
||||||
|
"vue-template-compiler": "^2.6.11"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"root": true,
|
||||||
|
"extends": [
|
||||||
|
"@vant"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"stylelint": {
|
||||||
|
"extends": [
|
||||||
|
"@vant/stylelint-config"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"prettier": {
|
||||||
|
"singleQuote": true
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"Android >= 4.0",
|
||||||
|
"iOS >= 8"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
# DemoButton 按钮
|
||||||
|
|
||||||
|
### 介绍
|
||||||
|
|
||||||
|
DemoButton 是一个示例按钮组件
|
||||||
|
|
||||||
|
### 引入
|
||||||
|
|
||||||
|
```js
|
||||||
|
import Vue from 'vue';
|
||||||
|
import { DemoButton } from '<%= name %>';
|
||||||
|
|
||||||
|
Vue.use(DemoButton);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 代码演示
|
||||||
|
|
||||||
|
### 基础用法
|
||||||
|
|
||||||
|
```html
|
||||||
|
<demo-button type="primary" />
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### Props
|
||||||
|
|
||||||
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
|
|------|------|------|------|
|
||||||
|
| type | 按钮类型 | *string* | `primary` |
|
||||||
|
| color `1.0.0` | 按钮颜色 | *string* | - |
|
||||||
|
|
||||||
|
### Events
|
||||||
|
|
||||||
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|
|------|------|------|
|
||||||
|
| click | 点击时触发 | event: Event |
|
||||||
|
|
||||||
|
### Slots
|
||||||
|
|
||||||
|
| 名称 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| default | 默认插槽 |
|
@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
<demo-section>
|
||||||
|
<demo-block title="基础用法">
|
||||||
|
<demo-button type="primary" style="margin-left: 15px;">按钮</demo-button>
|
||||||
|
</demo-block>
|
||||||
|
|
||||||
|
<demo-block title="自定义颜色">
|
||||||
|
<demo-button color="#03a9f4" style="margin-left: 15px;">按钮</demo-button>
|
||||||
|
</demo-block>
|
||||||
|
</demo-section>
|
||||||
|
</template>
|
@ -0,0 +1,31 @@
|
|||||||
|
<template>
|
||||||
|
<button class="demo-button">
|
||||||
|
<slot />
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'demo-button',
|
||||||
|
|
||||||
|
props: {
|
||||||
|
color: String,
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'primary',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="<%= cssLang %>">
|
||||||
|
.demo-button {
|
||||||
|
min-width: 120px;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 36px;
|
||||||
|
background-color: #f44;
|
||||||
|
border: none;
|
||||||
|
border-radius: 30px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,3 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`render demo button 1`] = `<button class="demo-button"></button>`;
|
@ -0,0 +1,7 @@
|
|||||||
|
import { mount } from '@vue/test-utils';
|
||||||
|
import DemoButton from '..';
|
||||||
|
|
||||||
|
test('render demo button', () => {
|
||||||
|
const wrapper = mount(DemoButton);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
@ -0,0 +1,39 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: '<%= name %>',
|
||||||
|
build: {
|
||||||
|
css: {
|
||||||
|
preprocessor: '<%= preprocessor %>',
|
||||||
|
},
|
||||||
|
site: {
|
||||||
|
publicPath: '/<%= name %>/',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
site: {
|
||||||
|
title: '<%= name %>',
|
||||||
|
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
||||||
|
nav: [
|
||||||
|
{
|
||||||
|
title: '开发指南',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
path: 'home',
|
||||||
|
title: '介绍',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'quickstart',
|
||||||
|
title: '快速上手',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基础组件',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
path: 'demo-button',
|
||||||
|
title: 'DemoButton 按钮',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
45
packages/create-vant-cli-app/package.json
Normal file
45
packages/create-vant-cli-app/package.json
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"name": "create-vant-cli-app",
|
||||||
|
"version": "0.1.1",
|
||||||
|
"description": "Create Vant Cli App",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"bin": {
|
||||||
|
"create-vant-cli-app": "./lib/index.js"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "tsc --watch",
|
||||||
|
"release": "tsc & release-it"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/youzan/vant/tree/dev/packages/create-vant-cli-app"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"generators"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"vant"
|
||||||
|
],
|
||||||
|
"author": "chenjiahan",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/fs-extra": "^8.0.1",
|
||||||
|
"@types/yeoman-generator": "^3.1.4",
|
||||||
|
"release-it": "^12.4.3",
|
||||||
|
"typescript": "^3.7.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"chalk": "^3.0.0",
|
||||||
|
"consola": "^2.11.3",
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
|
"inquirer": "^7.0.3",
|
||||||
|
"yeoman-generator": "^4.4.0"
|
||||||
|
},
|
||||||
|
"release-it": {
|
||||||
|
"git": {
|
||||||
|
"tag": false,
|
||||||
|
"commitMessage": "chore: release create-vant-cli-app@${version}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
packages/create-vant-cli-app/src/constant.ts
Normal file
4
packages/create-vant-cli-app/src/constant.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
export const CWD = process.cwd();
|
||||||
|
export const GENERATOR_DIR = join(__dirname, '../generators');
|
92
packages/create-vant-cli-app/src/generator.ts
Normal file
92
packages/create-vant-cli-app/src/generator.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import chalk from 'chalk';
|
||||||
|
import consola from 'consola';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { CWD, GENERATOR_DIR } from './constant';
|
||||||
|
import Generator from 'yeoman-generator';
|
||||||
|
|
||||||
|
const TEMPLATES = join(GENERATOR_DIR, 'templates');
|
||||||
|
const PROMPTS = [
|
||||||
|
{
|
||||||
|
name: 'preprocessor',
|
||||||
|
message: 'Select css preprocessor',
|
||||||
|
type: 'list',
|
||||||
|
choices: ['Less', 'Sass'],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export class VanGenerator extends Generator {
|
||||||
|
inputs = {
|
||||||
|
name: '',
|
||||||
|
cssLang: '',
|
||||||
|
preprocessor: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(name: string) {
|
||||||
|
super([], {
|
||||||
|
env: {
|
||||||
|
cwd: join(CWD, name),
|
||||||
|
},
|
||||||
|
resolved: GENERATOR_DIR,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.inputs.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
async prompting() {
|
||||||
|
return this.prompt<Record<string, string>>(PROMPTS).then(inputs => {
|
||||||
|
const preprocessor = inputs.preprocessor.toLowerCase();
|
||||||
|
const cssLang = preprocessor === 'sass' ? 'scss' : preprocessor;
|
||||||
|
|
||||||
|
this.inputs.cssLang = cssLang;
|
||||||
|
this.inputs.preprocessor = preprocessor;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
writing() {
|
||||||
|
consola.info(`Creating project in ${join(CWD, this.inputs.name)}\n`);
|
||||||
|
|
||||||
|
const copy = (from: string, to?: string) => {
|
||||||
|
this.fs.copy(join(TEMPLATES, from), this.destinationPath(to || from));
|
||||||
|
};
|
||||||
|
|
||||||
|
const copyTpl = (from: string, to?: string) => {
|
||||||
|
this.fs.copyTpl(
|
||||||
|
join(TEMPLATES, from),
|
||||||
|
this.destinationPath(to || from),
|
||||||
|
this.inputs
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
copyTpl('package.json.tpl', 'package.json');
|
||||||
|
copyTpl('vant.config.js');
|
||||||
|
copyTpl('src/**/*', 'src');
|
||||||
|
copyTpl('docs/**/*', 'docs');
|
||||||
|
copy('babel.config.js');
|
||||||
|
copy('gitignore.tpl', '.gitignore');
|
||||||
|
copy('eslintignore.tpl', '.eslintignore');
|
||||||
|
}
|
||||||
|
|
||||||
|
install() {
|
||||||
|
console.log();
|
||||||
|
consola.info('Install dependencies...\n');
|
||||||
|
|
||||||
|
process.chdir(this.inputs.name);
|
||||||
|
|
||||||
|
this.installDependencies({
|
||||||
|
npm: false,
|
||||||
|
bower: false,
|
||||||
|
yarn: true,
|
||||||
|
skipMessage: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
end() {
|
||||||
|
const { name } = this.inputs;
|
||||||
|
|
||||||
|
console.log();
|
||||||
|
consola.success(`Successfully created ${chalk.yellow(name)}.`);
|
||||||
|
consola.success(
|
||||||
|
`Run ${chalk.yellow(`cd ${name} && yarn dev`)} to start development!`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
24
packages/create-vant-cli-app/src/index.ts
Normal file
24
packages/create-vant-cli-app/src/index.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import inquirer from 'inquirer';
|
||||||
|
import { ensureDir } from 'fs-extra';
|
||||||
|
import { VanGenerator } from './generator';
|
||||||
|
|
||||||
|
const PROMPTS = [
|
||||||
|
{
|
||||||
|
type: 'input',
|
||||||
|
name: 'name',
|
||||||
|
message: 'Your package name',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default async function run() {
|
||||||
|
const { name } = await inquirer.prompt(PROMPTS);
|
||||||
|
|
||||||
|
ensureDir(name);
|
||||||
|
|
||||||
|
const generator = new VanGenerator(name);
|
||||||
|
generator.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
13
packages/create-vant-cli-app/tsconfig.json
Normal file
13
packages/create-vant-cli-app/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"outDir": "./lib",
|
||||||
|
"module": "commonjs",
|
||||||
|
"strict": true,
|
||||||
|
"declaration": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"lib": ["esnext"]
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
3379
packages/create-vant-cli-app/yarn.lock
Normal file
3379
packages/create-vant-cli-app/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,15 @@ Vant Cli 是一个 Vue 组件库构建工具,通过 Vant Cli 可以快速搭
|
|||||||
- 内置 ESlint、Stylelint 校验规则,提交代码时自动执行校验
|
- 内置 ESlint、Stylelint 校验规则,提交代码时自动执行校验
|
||||||
- 构建后的组件库默认支持按需引入、主题定制、Tree Shaking
|
- 构建后的组件库默认支持按需引入、主题定制、Tree Shaking
|
||||||
|
|
||||||
### 安装
|
### 快速上手
|
||||||
|
|
||||||
|
执行以下命令可以快速创建一个基于 Vant Cli 的项目:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx create-vant-cli-app
|
||||||
|
```
|
||||||
|
|
||||||
|
### 手动安装
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# 通过 npm 安装
|
# 通过 npm 安装
|
||||||
|
@ -1,5 +1,40 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
### [v2.2.2]
|
||||||
|
`2020-02-05`
|
||||||
|
|
||||||
|
- 修复在 windows 上获取 markdown 路径错误的问题 ([#5626](https://github.com/youzan/vant/pull/5626))
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.2.1]
|
||||||
|
`2020-02-04`
|
||||||
|
|
||||||
|
- 升级 babel@7.8
|
||||||
|
- 修复切换版本时跳转 undefined 的问题 ([#5620](https://github.com/youzan/vant/pull/5620))
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.2.0]
|
||||||
|
`2020-01-19`
|
||||||
|
|
||||||
|
- 升级 @vant/eslint-config@2.0.0
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.1.8]
|
||||||
|
`2020-01-18`
|
||||||
|
|
||||||
|
- 新增 create-vant-cli-app 初始化命令
|
||||||
|
- 新增 --version 选项
|
||||||
|
- 优化站点导航栏颜色
|
||||||
|
- 优化站点代码块颜色
|
||||||
|
|
||||||
|
|
||||||
|
### [v2.1.7]
|
||||||
|
`2020-01-15`
|
||||||
|
|
||||||
|
- 优化 help 命令
|
||||||
|
- 优化控制台输出信息
|
||||||
|
|
||||||
|
|
||||||
### [v2.1.6]
|
### [v2.1.6]
|
||||||
`2020-01-12`
|
`2020-01-12`
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vant/cli",
|
"name": "@vant/cli",
|
||||||
"version": "2.1.6",
|
"version": "2.2.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"typings": "lib/index.d.ts",
|
"typings": "lib/index.d.ts",
|
||||||
@ -23,6 +23,9 @@
|
|||||||
"template",
|
"template",
|
||||||
"preset.js"
|
"preset.js"
|
||||||
],
|
],
|
||||||
|
"keywords": [
|
||||||
|
"vant"
|
||||||
|
],
|
||||||
"author": "chenjiahan",
|
"author": "chenjiahan",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@ -30,78 +33,75 @@
|
|||||||
"vue-template-compiler": "^2.5.22"
|
"vue-template-compiler": "^2.5.22"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/eslint": "^6.1.3",
|
|
||||||
"@types/fs-extra": "^8.0.1",
|
"@types/fs-extra": "^8.0.1",
|
||||||
"@types/html-webpack-plugin": "^3.2.1",
|
"@types/html-webpack-plugin": "^3.2.2",
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.149",
|
||||||
"@types/postcss-load-config": "^2.0.1",
|
"@types/postcss-load-config": "^2.0.1",
|
||||||
"@types/sass": "^1.16.0",
|
"@types/sass": "^1.16.0",
|
||||||
"@types/shelljs": "^0.8.6",
|
"@types/shelljs": "^0.8.6",
|
||||||
"@types/signale": "^1.2.1",
|
"@types/webpack": "^4.41.4",
|
||||||
"@types/source-map": "^0.5.7",
|
"@types/webpack-dev-server": "^3.10.0",
|
||||||
"@types/stylelint": "^9.10.1",
|
|
||||||
"@types/webpack": "^4.41.2",
|
|
||||||
"@types/webpack-dev-server": "^3.9.0",
|
|
||||||
"@types/webpack-merge": "^4.1.5"
|
"@types/webpack-merge": "^4.1.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.7.7",
|
"@babel/core": "^7.8.4",
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4",
|
"@babel/plugin-syntax-jsx": "^7.8.3",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
|
"@babel/plugin-transform-object-assign": "^7.8.3",
|
||||||
"@babel/plugin-syntax-jsx": "^7.7.4",
|
"@babel/plugin-transform-runtime": "^7.8.3",
|
||||||
"@babel/plugin-transform-object-assign": "^7.7.4",
|
"@babel/preset-env": "^7.8.4",
|
||||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
"@babel/preset-typescript": "^7.8.3",
|
||||||
"@babel/preset-env": "^7.7.7",
|
|
||||||
"@babel/preset-typescript": "^7.7.7",
|
|
||||||
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
|
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
|
||||||
"@types/jest": "^24.0.25",
|
"@types/jest": "^25.1.1",
|
||||||
"@vant/eslint-config": "^1.5.1",
|
"@vant/eslint-config": "^2.0.0",
|
||||||
"@vant/markdown-loader": "^2.3.0",
|
"@vant/markdown-loader": "^2.3.0",
|
||||||
"@vant/markdown-vetur": "^1.0.0",
|
"@vant/markdown-vetur": "^1.1.0",
|
||||||
"@vant/stylelint-config": "^1.1.0",
|
"@vant/stylelint-config": "^1.1.0",
|
||||||
"@vant/touch-emulator": "^1.2.0",
|
"@vant/touch-emulator": "^1.2.0",
|
||||||
"@vue/babel-preset-jsx": "^1.1.2",
|
"@vue/babel-preset-jsx": "^1.1.2",
|
||||||
"@vue/component-compiler-utils": "^3.1.1",
|
"@vue/component-compiler-utils": "^3.1.1",
|
||||||
"@vue/test-utils": "1.0.0-beta.29",
|
"@vue/test-utils": "1.0.0-beta.29",
|
||||||
"autoprefixer": "^9.7.3",
|
"address": "^1.1.2",
|
||||||
"babel-jest": "^24.9.0",
|
"autoprefixer": "^9.7.4",
|
||||||
|
"babel-jest": "^25.1.0",
|
||||||
"babel-loader": "^8.0.6",
|
"babel-loader": "^8.0.6",
|
||||||
"babel-plugin-import": "^1.13.0",
|
"babel-plugin-import": "^1.13.0",
|
||||||
"cache-loader": "^4.1.0",
|
"cache-loader": "^4.1.0",
|
||||||
"chokidar": "^3.3.1",
|
"chokidar": "^3.3.1",
|
||||||
"clean-css": "^4.2.1",
|
"clean-css": "^4.2.3",
|
||||||
"codecov": "^3.6.1",
|
"codecov": "^3.6.4",
|
||||||
"commander": "^4.1.0",
|
"commander": "^4.1.1",
|
||||||
|
"consola": "^2.11.3",
|
||||||
"conventional-changelog": "^3.1.18",
|
"conventional-changelog": "^3.1.18",
|
||||||
"cross-env": "^6.0.3",
|
"cross-env": "^7.0.0",
|
||||||
"css-loader": "^3.4.1",
|
"css-loader": "^3.4.2",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
|
"fast-glob": "^3.1.1",
|
||||||
"gh-pages": "2.0.1",
|
"gh-pages": "2.0.1",
|
||||||
"html-webpack-plugin": "3.2.0",
|
"html-webpack-plugin": "3.2.0",
|
||||||
"husky": "^4.0.4",
|
"husky": "^4.2.1",
|
||||||
"jest": "^24.9.0",
|
"jest": "^25.1.0",
|
||||||
"jest-canvas-mock": "^2.2.0",
|
"jest-canvas-mock": "^2.2.0",
|
||||||
"jest-serializer-vue": "^2.0.2",
|
"jest-serializer-vue": "^2.0.2",
|
||||||
"less": "^3.10.3",
|
"less": "^3.10.3",
|
||||||
"less-loader": "^5.0.0",
|
"less-loader": "^5.0.0",
|
||||||
"lint-staged": "^9.5.0",
|
"lint-staged": "^10.0.7",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
|
"ora": "^4.0.3",
|
||||||
"portfinder": "^1.0.25",
|
"portfinder": "^1.0.25",
|
||||||
"postcss": "^7.0.26",
|
"postcss": "^7.0.26",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"release-it": "^12.4.3",
|
"release-it": "^12.4.3",
|
||||||
"sass": "^1.24.4",
|
"sass": "^1.25.0",
|
||||||
"sass-loader": "^8.0.0",
|
"sass-loader": "^8.0.2",
|
||||||
"shelljs": "^0.8.3",
|
"shelljs": "^0.8.3",
|
||||||
"signale": "^1.4.0",
|
"style-loader": "^1.1.3",
|
||||||
"style-loader": "^1.1.2",
|
"stylelint": "^13.0.0",
|
||||||
"stylelint": "^12.0.1",
|
"typescript": "^3.7.5",
|
||||||
"typescript": "^3.7.4",
|
|
||||||
"vue-jest": "4.0.0-beta.2",
|
"vue-jest": "4.0.0-beta.2",
|
||||||
"vue-loader": "^15.8.3",
|
"vue-loader": "^15.8.3",
|
||||||
"vue-router": "^3.1.3",
|
"vue-router": "^3.1.5",
|
||||||
"webpack": "^4.41.5",
|
"webpack": "^4.41.5",
|
||||||
"webpack-dev-server": "3.10.1",
|
"webpack-dev-server": "3.10.2",
|
||||||
"webpack-merge": "^4.2.2",
|
"webpack-merge": "^4.2.2",
|
||||||
"webpackbar": "^4.0.0"
|
"webpackbar": "^4.0.0"
|
||||||
},
|
},
|
||||||
@ -120,13 +120,5 @@
|
|||||||
"global-require": 0,
|
"global-require": 0,
|
||||||
"import/no-dynamic-require": 0
|
"import/no-dynamic-require": 0
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"stylelint": {
|
|
||||||
"extends": [
|
|
||||||
"@vant/stylelint-config"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"prettier": {
|
|
||||||
"singleQuote": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { iframeReady, isMobile } from '.';
|
import { iframeReady, isMobile } from '.';
|
||||||
|
|
||||||
window.syncPath = function () {
|
window.syncPath = function() {
|
||||||
const router = window.vueRouter;
|
const router = window.vueRouter;
|
||||||
const isInIframe = window !== window.top;
|
const isInIframe = window !== window.top;
|
||||||
const currentDir = router.history.current.path;
|
const currentDir = router.history.current.path;
|
||||||
@ -21,7 +21,7 @@ window.syncPath = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.replacePath = function (path = '') {
|
window.replacePath = function(path = '') {
|
||||||
// should preserve hash for anchor
|
// should preserve hash for anchor
|
||||||
if (window.vueRouter.currentRoute.path !== path) {
|
if (window.vueRouter.currentRoute.path !== path) {
|
||||||
window.vueRouter.replace(path).catch(() => {});
|
window.vueRouter.replace(path).catch(() => {});
|
||||||
|
@ -27,7 +27,4 @@ export function decamelize(str, sep = '-') {
|
|||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { isMobile, iframeReady };
|
||||||
isMobile,
|
|
||||||
iframeReady
|
|
||||||
};
|
|
||||||
|
@ -7,11 +7,12 @@ code {
|
|||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
color: @van-doc-code-color;
|
color: @van-doc-code-color;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 13px;
|
font-size: 13.4px;
|
||||||
font-family: @van-doc-code-font-family;
|
font-family: @van-doc-code-font-family;
|
||||||
line-height: 26px;
|
line-height: 26px;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
-webkit-font-smoothing: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
@ -35,7 +36,7 @@ pre {
|
|||||||
.hljs-template-tag,
|
.hljs-template-tag,
|
||||||
.hljs-template-variable,
|
.hljs-template-variable,
|
||||||
.hljs-addition {
|
.hljs-addition {
|
||||||
color: @van-doc-purple;
|
color: @van-doc-green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-comment,
|
.hljs-comment,
|
||||||
@ -43,21 +44,23 @@ pre {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hljs-params,
|
||||||
|
.hljs-keyword,
|
||||||
|
.hljs-attribute {
|
||||||
|
color: @van-doc-purple;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-deletion,
|
||||||
|
.hljs-variable,
|
||||||
.hljs-number,
|
.hljs-number,
|
||||||
.hljs-regexp,
|
.hljs-regexp,
|
||||||
.hljs-literal,
|
.hljs-literal,
|
||||||
.hljs-bullet,
|
.hljs-bullet,
|
||||||
.hljs-link {
|
.hljs-link {
|
||||||
color: #07c160;
|
color: #eb6f6f;
|
||||||
}
|
|
||||||
|
|
||||||
.hljs-deletion,
|
|
||||||
.hljs-variable {
|
|
||||||
color: #88f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-attr,
|
.hljs-attr,
|
||||||
.hljs-keyword,
|
|
||||||
.hljs-selector-tag,
|
.hljs-selector-tag,
|
||||||
.hljs-title,
|
.hljs-title,
|
||||||
.hljs-section,
|
.hljs-section,
|
||||||
@ -68,13 +71,9 @@ pre {
|
|||||||
.hljs-selector-id,
|
.hljs-selector-id,
|
||||||
.hljs-selector-class,
|
.hljs-selector-class,
|
||||||
.hljs-strong {
|
.hljs-strong {
|
||||||
color: @van-doc-blue;
|
color: #4994df;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-emphasis {
|
.hljs-emphasis {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-attribute {
|
|
||||||
color: #e6550d;
|
|
||||||
}
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
@van-doc-black: #323233;
|
@van-doc-black: #323233;
|
||||||
@van-doc-blue: #1989fa;
|
@van-doc-blue: #1989fa;
|
||||||
@van-doc-purple: #5758bb;
|
@van-doc-purple: #8080ff;
|
||||||
@van-doc-fuchsia: #a7419e;
|
@van-doc-fuchsia: #a7419e;
|
||||||
|
@van-doc-green: #4fc08d;
|
||||||
@van-doc-text-color: #34495e;
|
@van-doc-text-color: #34495e;
|
||||||
@van-doc-text-light-blue: rgba(69, 90, 100, .6);
|
@van-doc-text-light-blue: rgba(69, 90, 100, 0.6);
|
||||||
@van-doc-background-color: #f7f8fa;
|
@van-doc-background-color: #f7f8fa;
|
||||||
@van-doc-grey: #999;
|
@van-doc-grey: #999;
|
||||||
@van-doc-dark-grey: #666;
|
@van-doc-dark-grey: #666;
|
||||||
@van-doc-light-grey: #ccc;
|
@van-doc-light-grey: #ccc;
|
||||||
@van-doc-border-color: #f1f4f8;
|
@van-doc-border-color: #f1f4f8;
|
||||||
@van-doc-code-color: #455a64;
|
@van-doc-code-color: #58727e;
|
||||||
@van-doc-code-background-color: #f1f4f8;
|
@van-doc-code-background-color: #f1f4f8;
|
||||||
@van-doc-code-font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
|
@van-doc-code-font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
|
||||||
@van-doc-padding: 30px;
|
@van-doc-padding: 30px;
|
||||||
|
@ -19,7 +19,7 @@ import { setLang } from '../common/locales';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
VanDoc
|
VanDoc,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -27,7 +27,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
packageVersion,
|
packageVersion,
|
||||||
simulator: `${path}mobile.html${location.hash}`
|
simulator: `${path}mobile.html${location.hash}`,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export default {
|
|||||||
const { locales = {} } = config.site;
|
const { locales = {} } = config.site;
|
||||||
return Object.keys(locales).map(key => ({
|
return Object.keys(locales).map(key => ({
|
||||||
lang: key,
|
lang: key,
|
||||||
label: locales[key].langLabel || ''
|
label: locales[key].langLabel || '',
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -61,14 +61,14 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
lang(val) {
|
lang(val) {
|
||||||
setLang(val);
|
setLang(val);
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
@ -84,8 +84,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.title = title;
|
document.title = title;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ export default {
|
|||||||
name: 'van-doc-container',
|
name: 'van-doc-container',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
hasSimulator: Boolean
|
hasSimulator: Boolean,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ export default {
|
|||||||
return path.split('/').slice(-1)[0];
|
return path.split('/').slice(-1)[0];
|
||||||
}
|
}
|
||||||
return this.$route.name;
|
return this.$route.name;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -37,7 +37,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: @van-doc-blue;
|
color: @van-doc-green;
|
||||||
|
-webkit-font-smoothing: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
@ -67,9 +68,9 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 17px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
@ -119,6 +120,7 @@ export default {
|
|||||||
&:first-child {
|
&:first-child {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
|
||||||
|
// version tag
|
||||||
code {
|
code {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
@ -135,18 +137,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
|
||||||
padding: 0 8px;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: inherit;
|
|
||||||
word-break: keep-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
em {
|
em {
|
||||||
color: @van-doc-fuchsia;
|
color: @van-doc-green;
|
||||||
font-size: 12px;
|
font-size: 12.5px;
|
||||||
font-family: @van-doc-code-font-family;
|
font-family: @van-doc-code-font-family;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
|
-webkit-font-smoothing: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,8 +181,16 @@ export default {
|
|||||||
display: inline;
|
display: inline;
|
||||||
margin: 2px 3px;
|
margin: 2px 3px;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: inherit;
|
||||||
|
word-break: keep-all;
|
||||||
background-color: #f0f2f5;
|
background-color: #f0f2f5;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
p > code {
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
section {
|
section {
|
||||||
|
@ -3,21 +3,36 @@
|
|||||||
<div class="van-doc-row">
|
<div class="van-doc-row">
|
||||||
<div class="van-doc-header__top">
|
<div class="van-doc-header__top">
|
||||||
<a class="van-doc-header__logo">
|
<a class="van-doc-header__logo">
|
||||||
<img :src="config.logo">
|
<img :src="config.logo" />
|
||||||
<span>{{ config.title }}</span>
|
<span>{{ config.title }}</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<search-input v-if="searchConfig" :lang="lang" :search-config="searchConfig" />
|
<search-input
|
||||||
|
v-if="searchConfig"
|
||||||
|
:lang="lang"
|
||||||
|
:search-config="searchConfig"
|
||||||
|
/>
|
||||||
|
|
||||||
<ul class="van-doc-header__top-nav">
|
<ul class="van-doc-header__top-nav">
|
||||||
<li v-for="item in config.links" class="van-doc-header__top-nav-item">
|
<li v-for="item in config.links" class="van-doc-header__top-nav-item">
|
||||||
<a class="van-doc-header__logo-link" target="_blank" :href="item.url">
|
<a
|
||||||
<img :src="item.logo">
|
class="van-doc-header__logo-link"
|
||||||
|
target="_blank"
|
||||||
|
:href="item.url"
|
||||||
|
>
|
||||||
|
<img :src="item.logo" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li ref="version" v-if="versions" class="van-doc-header__top-nav-item">
|
<li
|
||||||
<span class="van-doc-header__cube van-doc-header__version" @click="toggleVersionPop">
|
ref="version"
|
||||||
|
v-if="versions"
|
||||||
|
class="van-doc-header__top-nav-item"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="van-doc-header__cube van-doc-header__version"
|
||||||
|
@click="toggleVersionPop"
|
||||||
|
>
|
||||||
{{ versions[0].label }}
|
{{ versions[0].label }}
|
||||||
<transition name="van-doc-dropdown">
|
<transition name="van-doc-dropdown">
|
||||||
<div v-if="showVersionPop" class="van-doc-header__version-pop">
|
<div v-if="showVersionPop" class="van-doc-header__version-pop">
|
||||||
@ -49,19 +64,19 @@ export default {
|
|||||||
name: 'van-doc-header',
|
name: 'van-doc-header',
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
SearchInput
|
SearchInput,
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
lang: String,
|
lang: String,
|
||||||
config: Object,
|
config: Object,
|
||||||
versions: Array,
|
versions: Array,
|
||||||
langConfigs: Array
|
langConfigs: Array,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showVersionPop: false
|
showVersionPop: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -85,7 +100,7 @@ export default {
|
|||||||
|
|
||||||
searchConfig() {
|
searchConfig() {
|
||||||
return this.config.searchConfig;
|
return this.config.searchConfig;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@ -93,7 +108,10 @@ export default {
|
|||||||
const val = !this.showVersionPop;
|
const val = !this.showVersionPop;
|
||||||
|
|
||||||
const action = val ? 'add' : 'remove';
|
const action = val ? 'add' : 'remove';
|
||||||
document.body[`${action}EventListener`]('click', this.checkHideVersionPop);
|
document.body[`${action}EventListener`](
|
||||||
|
'click',
|
||||||
|
this.checkHideVersionPop
|
||||||
|
);
|
||||||
|
|
||||||
this.showVersionPop = val;
|
this.showVersionPop = val;
|
||||||
},
|
},
|
||||||
@ -109,9 +127,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onSwitchVersion(version) {
|
onSwitchVersion(version) {
|
||||||
location.href = version.link;
|
if (version.link) {
|
||||||
}
|
location.href = version.link;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -120,7 +140,6 @@ export default {
|
|||||||
|
|
||||||
.van-doc-header {
|
.van-doc-header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-shadow: 0 4px 12px #ebedf0;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
&__top {
|
&__top {
|
||||||
|
@ -28,18 +28,18 @@ export default {
|
|||||||
name: 'van-doc-nav',
|
name: 'van-doc-nav',
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
[NavLink.name]: NavLink
|
[NavLink.name]: NavLink,
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
lang: String,
|
lang: String,
|
||||||
navConfig: Array
|
navConfig: Array,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
top: 60,
|
top: 60,
|
||||||
bottom: 0
|
bottom: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ export default {
|
|||||||
style() {
|
style() {
|
||||||
return {
|
return {
|
||||||
top: this.top + 'px',
|
top: this.top + 'px',
|
||||||
bottom: this.bottom + 'px'
|
bottom: this.bottom + 'px',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
base() {
|
base() {
|
||||||
return this.lang ? `/${this.lang}/` : '/';
|
return this.lang ? `/${this.lang}/` : '/';
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
@ -65,8 +65,8 @@ export default {
|
|||||||
onScroll() {
|
onScroll() {
|
||||||
const { pageYOffset: offset } = window;
|
const { pageYOffset: offset } = window;
|
||||||
this.top = Math.max(0, 60 - offset);
|
this.top = Math.max(0, 60 - offset);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -126,16 +126,15 @@ export default {
|
|||||||
color: #455a64;
|
color: #455a64;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
transition: all 0.3s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover,
|
||||||
color: #000;
|
&.active {
|
||||||
|
color: @van-doc-green;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: #000;
|
-webkit-font-smoothing: auto;
|
||||||
font-weight: 500;
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<router-link v-if="item.path" :class="{ active }" :to="path" v-html="itemName" />
|
<router-link
|
||||||
|
v-if="item.path"
|
||||||
|
:class="{ active }"
|
||||||
|
:to="path"
|
||||||
|
v-html="itemName"
|
||||||
|
/>
|
||||||
<a v-else-if="item.link" :href="item.link" v-html="itemName" />
|
<a v-else-if="item.link" :href="item.link" v-html="itemName" />
|
||||||
<a v-else v-html="itemName " />
|
<a v-else v-html="itemName" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -10,7 +15,7 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
base: String,
|
base: String,
|
||||||
item: Object
|
item: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@ -33,13 +38,13 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
active() {
|
active() {
|
||||||
this.scrollIntoView();
|
this.scrollIntoView();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -51,7 +56,7 @@ export default {
|
|||||||
if (this.active && this.$el && this.$el.scrollIntoViewIfNeeded) {
|
if (this.active && this.$el && this.$el.scrollIntoViewIfNeeded) {
|
||||||
this.$el.scrollIntoViewIfNeeded();
|
this.$el.scrollIntoViewIfNeeded();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<input class="van-doc-search" :placeholder="placeholder">
|
<input class="van-doc-search" :placeholder="placeholder" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -8,13 +8,13 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
lang: String,
|
lang: String,
|
||||||
searchConfig: Object
|
searchConfig: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
placeholder() {
|
placeholder() {
|
||||||
return this.searchConfig.placeholder || 'Search...';
|
return this.searchConfig.placeholder || 'Search...';
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@ -22,7 +22,7 @@ export default {
|
|||||||
if (this.docsearchInstance) {
|
if (this.docsearchInstance) {
|
||||||
this.docsearchInstance.algoliaOptions.facetFilters = [`lang:${lang}`];
|
this.docsearchInstance.algoliaOptions.facetFilters = [`lang:${lang}`];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -31,11 +31,11 @@ export default {
|
|||||||
...this.searchConfig,
|
...this.searchConfig,
|
||||||
inputSelector: '.van-doc-search',
|
inputSelector: '.van-doc-search',
|
||||||
algoliaOptions: {
|
algoliaOptions: {
|
||||||
facetFilters: [`lang:${this.lang}`]
|
facetFilters: [`lang:${this.lang}`],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@ export default {
|
|||||||
name: 'van-doc-simulator',
|
name: 'van-doc-simulator',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
src: String
|
src: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
scrollTop: window.scrollY,
|
scrollTop: window.scrollY,
|
||||||
windowHeight: window.innerHeight
|
windowHeight: window.innerHeight,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -27,9 +27,9 @@ export default {
|
|||||||
simulatorStyle() {
|
simulatorStyle() {
|
||||||
const height = Math.min(640, this.windowHeight - 90);
|
const height = Math.min(640, this.windowHeight - 90);
|
||||||
return {
|
return {
|
||||||
height: height + 'px'
|
height: height + 'px',
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -39,7 +39,7 @@ export default {
|
|||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
this.windowHeight = window.innerHeight;
|
this.windowHeight = window.innerHeight;
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
@switch-version="$emit('switch-version', $event)"
|
@switch-version="$emit('switch-version', $event)"
|
||||||
/>
|
/>
|
||||||
<doc-nav :lang="lang" :nav-config="config.nav" />
|
<doc-nav :lang="lang" :nav-config="config.nav" />
|
||||||
<doc-container :has-simulator="!!simulator ">
|
<doc-container :has-simulator="!!simulator">
|
||||||
<doc-content>
|
<doc-content>
|
||||||
<slot />
|
<slot />
|
||||||
</doc-content>
|
</doc-content>
|
||||||
@ -32,7 +32,7 @@ export default {
|
|||||||
DocHeader,
|
DocHeader,
|
||||||
DocContent,
|
DocContent,
|
||||||
DocContainer,
|
DocContainer,
|
||||||
DocSimulator
|
DocSimulator,
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@ -42,19 +42,19 @@ export default {
|
|||||||
langConfigs: Array,
|
langConfigs: Array,
|
||||||
config: {
|
config: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
base: {
|
base: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
'$route.path'() {
|
'$route.path'() {
|
||||||
this.setNav();
|
this.setNav();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
@ -98,8 +98,8 @@ export default {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,29 +1,43 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||||
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" />
|
<meta
|
||||||
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.logo %>" />
|
name="description"
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover">
|
content="<%= htmlWebpackPlugin.options.description %>"
|
||||||
<meta http-Equiv="Cache-Control" Content="no-cache" />
|
/>
|
||||||
<meta http-Equiv="Pragma" Content="no-cache" />
|
<link
|
||||||
<meta http-Equiv="Expires" Content="0" />
|
rel="icon"
|
||||||
<link href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" rel="stylesheet" />
|
type="image/png"
|
||||||
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
href="<%= htmlWebpackPlugin.options.logo %>"
|
||||||
<script>
|
/>
|
||||||
var _hmt = _hmt || [];
|
<meta
|
||||||
(function() {
|
name="viewport"
|
||||||
var hm = document.createElement("script");
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
|
||||||
hm.src = "https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>";
|
/>
|
||||||
var s = document.getElementsByTagName("script")[0];
|
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||||
s.parentNode.insertBefore(hm, s);
|
<meta http-equiv="Pragma" content="no-cache" />
|
||||||
})();
|
<meta http-equiv="Expires" content="0" />
|
||||||
</script>
|
<link
|
||||||
<% } %>
|
href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"
|
||||||
</head>
|
rel="stylesheet"
|
||||||
<body ontouchstart>
|
/>
|
||||||
<div id="app"></div>
|
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
||||||
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
|
<script>
|
||||||
</body>
|
var _hmt = _hmt || [];
|
||||||
|
(function() {
|
||||||
|
var hm = document.createElement('script');
|
||||||
|
hm.src =
|
||||||
|
'https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>';
|
||||||
|
var s = document.getElementsByTagName('script')[0];
|
||||||
|
s.parentNode.insertBefore(hm, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<% } %>
|
||||||
|
</head>
|
||||||
|
<body ontouchstart>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -15,5 +15,5 @@ new Vue({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: h => h(App),
|
render: h => h(App),
|
||||||
router
|
router,
|
||||||
});
|
});
|
||||||
|
@ -20,13 +20,13 @@ function parseName(name) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
component: `${decamelize(component)}`,
|
component: `${decamelize(component)}`,
|
||||||
lang: pairs.join('-')
|
lang: pairs.join('-'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
component: `${decamelize(name)}`,
|
component: `${decamelize(name)}`,
|
||||||
lang: ''
|
lang: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,12 +48,12 @@ function getRoutes() {
|
|||||||
if (locales) {
|
if (locales) {
|
||||||
routes.push({
|
routes.push({
|
||||||
path: '*',
|
path: '*',
|
||||||
redirect: route => `/${getLangFromRoute(route)}/`
|
redirect: route => `/${getLangFromRoute(route)}/`,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
routes.push({
|
routes.push({
|
||||||
path: '*',
|
path: '*',
|
||||||
redirect: '/'
|
redirect: '/',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ function getRoutes() {
|
|||||||
name: lang,
|
name: lang,
|
||||||
path: `/${lang || ''}`,
|
path: `/${lang || ''}`,
|
||||||
component: Home,
|
component: Home,
|
||||||
meta: { lang }
|
meta: { lang },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +80,8 @@ function getRoutes() {
|
|||||||
component: documents[name],
|
component: documents[name],
|
||||||
meta: {
|
meta: {
|
||||||
lang,
|
lang,
|
||||||
name: component
|
name: component,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
routes.push({
|
routes.push({
|
||||||
@ -89,8 +89,8 @@ function getRoutes() {
|
|||||||
path: `/${component}`,
|
path: `/${component}`,
|
||||||
component: documents[name],
|
component: documents[name],
|
||||||
meta: {
|
meta: {
|
||||||
name: component
|
name: component,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -109,7 +109,7 @@ export const router = new VueRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { x: 0, y: 0 };
|
return { x: 0, y: 0 };
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
@ -5,7 +5,7 @@ export function scrollToAnchor(selector) {
|
|||||||
const el = document.querySelector(selector);
|
const el = document.querySelector(selector);
|
||||||
if (el) {
|
if (el) {
|
||||||
el.scrollIntoView({
|
el.scrollIntoView({
|
||||||
behavior: 'smooth'
|
behavior: 'smooth',
|
||||||
});
|
});
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
import DemoNav from './components/DemoNav';
|
import DemoNav from './components/DemoNav';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { DemoNav }
|
components: { DemoNav },
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ export default {
|
|||||||
name: 'demo-block',
|
name: 'demo-block',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: String
|
title: String,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -4,16 +4,14 @@
|
|||||||
class="demo-home__title"
|
class="demo-home__title"
|
||||||
:class="{ 'demo-home__title--small': smallTitle }"
|
:class="{ 'demo-home__title--small': smallTitle }"
|
||||||
>
|
>
|
||||||
<img :src="config.logo">
|
<img :src="config.logo" />
|
||||||
<span>{{ config.title }}</span>
|
<span>{{ config.title }}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<h2 v-if="config.description" class="demo-home__desc">{{ config.description }}</h2>
|
<h2 v-if="config.description" class="demo-home__desc">
|
||||||
|
{{ config.description }}
|
||||||
|
</h2>
|
||||||
<template v-for="(group, index) in config.nav">
|
<template v-for="(group, index) in config.nav">
|
||||||
<demo-home-nav
|
<demo-home-nav :group="group" :lang="lang" :key="index" />
|
||||||
:group="group"
|
|
||||||
:lang="lang"
|
|
||||||
:key="index"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -24,7 +22,7 @@ import DemoHomeNav from './DemoHomeNav';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
DemoHomeNav
|
DemoHomeNav,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@ -45,8 +43,8 @@ export default {
|
|||||||
|
|
||||||
smallTitle() {
|
smallTitle() {
|
||||||
return this.config.title.length >= 8;
|
return this.config.title.length >= 8;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -20,25 +20,25 @@ import ArrowRight from './ArrowRight';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ArrowRight
|
ArrowRight,
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
lang: String,
|
lang: String,
|
||||||
group: Object
|
group: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
active: []
|
active: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
base() {
|
base() {
|
||||||
return this.lang ? `/${this.lang}` : '';
|
return this.lang ? `/${this.lang}` : '';
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
path:
|
path:
|
||||||
'M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z'
|
'M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -21,14 +21,14 @@ export default {
|
|||||||
title() {
|
title() {
|
||||||
const { name } = this.$route.meta || {};
|
const { name } = this.$route.meta || {};
|
||||||
return name ? name.replace(/-/g, '') : '';
|
return name ? name.replace(/-/g, '') : '';
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onBack() {
|
onBack() {
|
||||||
history.back();
|
history.back();
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,30 +1,41 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||||
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" />
|
<meta
|
||||||
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.logo %>" />
|
name="description"
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover">
|
content="<%= htmlWebpackPlugin.options.description %>"
|
||||||
<meta http-Equiv="Cache-Control" Content="no-cache" />
|
/>
|
||||||
<meta http-Equiv="Pragma" Content="no-cache" />
|
<link
|
||||||
<meta http-Equiv="Expires" Content="0" />
|
rel="icon"
|
||||||
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
type="image/png"
|
||||||
<script>
|
href="<%= htmlWebpackPlugin.options.logo %>"
|
||||||
// avoid to load analytics in iframe
|
/>
|
||||||
if (window.top === window) {
|
<meta
|
||||||
var _hmt = _hmt || [];
|
name="viewport"
|
||||||
(function() {
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
|
||||||
var hm = document.createElement("script");
|
/>
|
||||||
hm.src = "https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>";
|
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||||
var s = document.getElementsByTagName("script")[0];
|
<meta http-equiv="Pragma" content="no-cache" />
|
||||||
s.parentNode.insertBefore(hm, s);
|
<meta http-equiv="Expires" content="0" />
|
||||||
})();
|
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
||||||
}
|
<script>
|
||||||
</script>
|
// avoid to load analytics in iframe
|
||||||
<% } %>
|
if (window.top === window) {
|
||||||
</head>
|
var _hmt = _hmt || [];
|
||||||
<body ontouchstart>
|
(function() {
|
||||||
<div id="app"></div>
|
var hm = document.createElement('script');
|
||||||
</body>
|
hm.src =
|
||||||
|
'https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>';
|
||||||
|
var s = document.getElementsByTagName('script')[0];
|
||||||
|
s.parentNode.insertBefore(hm, s);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<% } %>
|
||||||
|
</head>
|
||||||
|
<body ontouchstart>
|
||||||
|
<div id="app"></div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -16,6 +16,6 @@ setTimeout(() => {
|
|||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
render: h => h(App),
|
render: h => h(App),
|
||||||
router
|
router,
|
||||||
});
|
});
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -29,25 +29,25 @@ function getRoutes() {
|
|||||||
if (langs.length) {
|
if (langs.length) {
|
||||||
routes.push({
|
routes.push({
|
||||||
path: '*',
|
path: '*',
|
||||||
redirect: route => `/${getLangFromRoute(route)}/`
|
redirect: route => `/${getLangFromRoute(route)}/`,
|
||||||
});
|
});
|
||||||
|
|
||||||
langs.forEach(lang => {
|
langs.forEach(lang => {
|
||||||
routes.push({
|
routes.push({
|
||||||
path: `/${lang}`,
|
path: `/${lang}`,
|
||||||
component: DemoHome,
|
component: DemoHome,
|
||||||
meta: { lang }
|
meta: { lang },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
routes.push({
|
routes.push({
|
||||||
path: '*',
|
path: '*',
|
||||||
redirect: () => '/'
|
redirect: () => '/',
|
||||||
});
|
});
|
||||||
|
|
||||||
routes.push({
|
routes.push({
|
||||||
path: '/',
|
path: '/',
|
||||||
component: DemoHome
|
component: DemoHome,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ function getRoutes() {
|
|||||||
component: demos[name],
|
component: demos[name],
|
||||||
meta: {
|
meta: {
|
||||||
name,
|
name,
|
||||||
lang
|
lang,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -72,8 +72,8 @@ function getRoutes() {
|
|||||||
path: `/${component}`,
|
path: `/${component}`,
|
||||||
component: demos[name],
|
component: demos[name],
|
||||||
meta: {
|
meta: {
|
||||||
name
|
name,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -86,7 +86,7 @@ Vue.use(VueRouter);
|
|||||||
export const router = new VueRouter({
|
export const router = new VueRouter({
|
||||||
mode: 'hash',
|
mode: 'hash',
|
||||||
routes: getRoutes(),
|
routes: getRoutes(),
|
||||||
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 }
|
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 },
|
||||||
});
|
});
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
// @ts-ignore
|
|
||||||
import execa from 'execa';
|
|
||||||
import chokidar from 'chokidar';
|
import chokidar from 'chokidar';
|
||||||
import { join, relative } from 'path';
|
import { join, relative } from 'path';
|
||||||
import { remove, copy, readdirSync } from 'fs-extra';
|
import { remove, copy, readdirSync } from 'fs-extra';
|
||||||
import { clean } from './clean';
|
import { clean } from './clean';
|
||||||
import { CSS_LANG } from '../common/css';
|
import { CSS_LANG } from '../common/css';
|
||||||
import { getStepper, getInteractiveLogger, logger } from '../common/logger';
|
import { ora, consola, slimPath } from '../common/logger';
|
||||||
|
import { installDependencies } from '../common/manager';
|
||||||
import { compileJs } from '../compiler/compile-js';
|
import { compileJs } from '../compiler/compile-js';
|
||||||
import { compileSfc } from '../compiler/compile-sfc';
|
import { compileSfc } from '../compiler/compile-sfc';
|
||||||
import { compileStyle } from '../compiler/compile-style';
|
import { compileStyle } from '../compiler/compile-style';
|
||||||
@ -23,13 +22,10 @@ import {
|
|||||||
isScript,
|
isScript,
|
||||||
isDemoDir,
|
isDemoDir,
|
||||||
isTestDir,
|
isTestDir,
|
||||||
hasYarn,
|
|
||||||
setNodeEnv,
|
setNodeEnv,
|
||||||
setModuleEnv
|
setModuleEnv,
|
||||||
} from '../common';
|
} from '../common';
|
||||||
|
|
||||||
const stepper = getStepper(12);
|
|
||||||
|
|
||||||
async function compileFile(filePath: string) {
|
async function compileFile(filePath: string) {
|
||||||
if (isSfc(filePath)) {
|
if (isSfc(filePath)) {
|
||||||
return compileSfc(filePath);
|
return compileSfc(filePath);
|
||||||
@ -66,126 +62,108 @@ async function compileDir(dir: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installDependencies() {
|
async function buildEs() {
|
||||||
stepper.start('Install Dependencies');
|
setModuleEnv('esmodule');
|
||||||
|
await copy(SRC_DIR, ES_DIR);
|
||||||
try {
|
await compileDir(ES_DIR);
|
||||||
const manager = hasYarn() ? 'yarn' : 'npm';
|
|
||||||
|
|
||||||
await execa(manager, ['install', '--prod=false'], {
|
|
||||||
stdio: 'inherit'
|
|
||||||
});
|
|
||||||
|
|
||||||
stepper.success('Install Dependencies');
|
|
||||||
} catch (err) {
|
|
||||||
stepper.error('Install Dependencies', err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildESModuleOutputs() {
|
async function buildLib() {
|
||||||
stepper.start('Build ESModule Outputs');
|
setModuleEnv('commonjs');
|
||||||
|
await copy(SRC_DIR, LIB_DIR);
|
||||||
try {
|
await compileDir(LIB_DIR);
|
||||||
setModuleEnv('esmodule');
|
|
||||||
await copy(SRC_DIR, ES_DIR);
|
|
||||||
await compileDir(ES_DIR);
|
|
||||||
stepper.success('Build ESModule Outputs');
|
|
||||||
} catch (err) {
|
|
||||||
stepper.error('Build ESModule Outputs', err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function buildCommonjsOutputs() {
|
|
||||||
stepper.start('Build Commonjs Outputs');
|
|
||||||
|
|
||||||
try {
|
|
||||||
setModuleEnv('commonjs');
|
|
||||||
await copy(SRC_DIR, LIB_DIR);
|
|
||||||
await compileDir(LIB_DIR);
|
|
||||||
stepper.success('Build Commonjs Outputs');
|
|
||||||
} catch (err) {
|
|
||||||
stepper.error('Build Commonjs Outputs', err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildStyleEntry() {
|
async function buildStyleEntry() {
|
||||||
stepper.start('Build Style Entry');
|
await genStyleDepsMap();
|
||||||
|
genComponentStyle();
|
||||||
try {
|
|
||||||
await genStyleDepsMap();
|
|
||||||
genComponentStyle();
|
|
||||||
stepper.success('Build Style Entry');
|
|
||||||
} catch (err) {
|
|
||||||
stepper.error('Build Style Entry', err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildPackedOutputs() {
|
async function buildPacakgeEntry() {
|
||||||
stepper.start('Build Packed Outputs');
|
const esEntryFile = join(ES_DIR, 'index.js');
|
||||||
|
const libEntryFile = join(LIB_DIR, 'index.js');
|
||||||
|
const styleEntryFile = join(LIB_DIR, `index.${CSS_LANG}`);
|
||||||
|
|
||||||
try {
|
genPackageEntry({
|
||||||
setModuleEnv('esmodule');
|
outputPath: esEntryFile,
|
||||||
await compilePackage(false);
|
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`,
|
||||||
await compilePackage(true);
|
});
|
||||||
genVeturConfig();
|
|
||||||
stepper.success('Build Packed Outputs');
|
setModuleEnv('esmodule');
|
||||||
} catch (err) {
|
await compileJs(esEntryFile);
|
||||||
stepper.error('Build Packed Outputs', err);
|
|
||||||
throw err;
|
genPacakgeStyle({
|
||||||
}
|
outputPath: styleEntryFile,
|
||||||
|
pathResolver: (path: string) => path.replace(SRC_DIR, '.'),
|
||||||
|
});
|
||||||
|
|
||||||
|
setModuleEnv('commonjs');
|
||||||
|
await copy(esEntryFile, libEntryFile);
|
||||||
|
await compileJs(libEntryFile);
|
||||||
|
await compileStyle(styleEntryFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildPackageEntry() {
|
async function buildPackages() {
|
||||||
stepper.start('Build Package Entry');
|
setModuleEnv('esmodule');
|
||||||
|
await compilePackage(false);
|
||||||
|
await compilePackage(true);
|
||||||
|
genVeturConfig();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
const tasks = [
|
||||||
const esEntryFile = join(ES_DIR, 'index.js');
|
{
|
||||||
const libEntryFile = join(LIB_DIR, 'index.js');
|
text: 'Build ESModule Outputs',
|
||||||
const styleEntryFile = join(LIB_DIR, `index.${CSS_LANG}`);
|
task: buildEs,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Build Commonjs Outputs',
|
||||||
|
task: buildLib,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Build Style Entry',
|
||||||
|
task: buildStyleEntry,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Build Package Entry',
|
||||||
|
task: buildPacakgeEntry,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Build Packed Outputs',
|
||||||
|
task: buildPackages,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
genPackageEntry({
|
async function runBuildTasks() {
|
||||||
outputPath: esEntryFile,
|
for (let i = 0; i < tasks.length; i++) {
|
||||||
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`
|
const { task, text } = tasks[i];
|
||||||
});
|
const spinner = ora(text).start();
|
||||||
|
|
||||||
setModuleEnv('esmodule');
|
try {
|
||||||
await compileJs(esEntryFile);
|
/* eslint-disable no-await-in-loop */
|
||||||
|
await task();
|
||||||
genPacakgeStyle({
|
spinner.succeed(text);
|
||||||
outputPath: styleEntryFile,
|
} catch (err) {
|
||||||
pathResolver: (path: string) => path.replace(SRC_DIR, '.')
|
spinner.fail(text);
|
||||||
});
|
console.log(err);
|
||||||
|
throw err;
|
||||||
setModuleEnv('commonjs');
|
}
|
||||||
await copy(esEntryFile, libEntryFile);
|
|
||||||
await compileJs(libEntryFile);
|
|
||||||
await compileStyle(styleEntryFile);
|
|
||||||
|
|
||||||
stepper.success('Build Package Entry');
|
|
||||||
} catch (err) {
|
|
||||||
stepper.error('Build Package Entry', err);
|
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consola.success('Compile successfully');
|
||||||
}
|
}
|
||||||
|
|
||||||
function watchFileChange() {
|
function watchFileChange() {
|
||||||
logger.watch('Compiled successfully, watching file changes...');
|
consola.info('\nWatching file changes...');
|
||||||
|
|
||||||
chokidar.watch(SRC_DIR).on('change', async path => {
|
chokidar.watch(SRC_DIR).on('change', async path => {
|
||||||
if (isDemoDir(path) || isTestDir(path)) {
|
if (isDemoDir(path) || isTestDir(path)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const logger = getInteractiveLogger();
|
const spinner = ora('File changed, start compilation...').start();
|
||||||
const esPath = path.replace(SRC_DIR, ES_DIR);
|
const esPath = path.replace(SRC_DIR, ES_DIR);
|
||||||
const libPath = path.replace(SRC_DIR, LIB_DIR);
|
const libPath = path.replace(SRC_DIR, LIB_DIR);
|
||||||
|
|
||||||
logger.pending('File change detected, start compilation...');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await copy(path, esPath);
|
await copy(path, esPath);
|
||||||
await copy(path, libPath);
|
await copy(path, libPath);
|
||||||
@ -193,9 +171,9 @@ function watchFileChange() {
|
|||||||
await compileFile(libPath);
|
await compileFile(libPath);
|
||||||
await genStyleDepsMap();
|
await genStyleDepsMap();
|
||||||
genComponentStyle({ cache: false });
|
genComponentStyle({ cache: false });
|
||||||
logger.success('Compiled: ' + path);
|
spinner.succeed('Compiled: ' + slimPath(path));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Compile failed: ' + path);
|
spinner.fail('Compile failed: ' + path);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -207,17 +185,13 @@ export async function build(cmd: { watch?: boolean } = {}) {
|
|||||||
try {
|
try {
|
||||||
await clean();
|
await clean();
|
||||||
await installDependencies();
|
await installDependencies();
|
||||||
await buildESModuleOutputs();
|
await runBuildTasks();
|
||||||
await buildCommonjsOutputs();
|
|
||||||
await buildStyleEntry();
|
|
||||||
await buildPackageEntry();
|
|
||||||
await buildPackedOutputs();
|
|
||||||
|
|
||||||
if (cmd.watch) {
|
if (cmd.watch) {
|
||||||
watchFileChange();
|
watchFileChange();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Build failed');
|
consola.error('Build failed');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { ROOT } from '../common/constant';
|
import { ROOT } from '../common/constant';
|
||||||
import { logger } from '../common/logger';
|
import { ora, slimPath } from '../common/logger';
|
||||||
import { createWriteStream, readFileSync } from 'fs-extra';
|
import { createWriteStream, readFileSync } from 'fs-extra';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import conventionalChangelog from 'conventional-changelog';
|
import conventionalChangelog from 'conventional-changelog';
|
||||||
@ -19,7 +19,7 @@ function formatType(type: string) {
|
|||||||
fix: 'Bug Fixes',
|
fix: 'Bug Fixes',
|
||||||
feat: 'Feature',
|
feat: 'Feature',
|
||||||
docs: 'Document',
|
docs: 'Document',
|
||||||
types: 'Types'
|
types: 'Types',
|
||||||
};
|
};
|
||||||
|
|
||||||
return MAP[type] || type;
|
return MAP[type] || type;
|
||||||
@ -46,13 +46,13 @@ function transform(item: any) {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function changelog() {
|
export async function changelog(): Promise<void> {
|
||||||
logger.start('Generating changelog...');
|
const spinner = ora('Generating changelog...').start();
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
conventionalChangelog(
|
conventionalChangelog(
|
||||||
{
|
{
|
||||||
preset: 'angular'
|
preset: 'angular',
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@ -61,12 +61,12 @@ export async function changelog() {
|
|||||||
mainTemplate,
|
mainTemplate,
|
||||||
headerPartial,
|
headerPartial,
|
||||||
commitPartial,
|
commitPartial,
|
||||||
transform
|
transform,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.pipe(createWriteStream(DIST_FILE))
|
.pipe(createWriteStream(DIST_FILE))
|
||||||
.on('close', () => {
|
.on('close', () => {
|
||||||
logger.success(`Generated changelog at ${DIST_FILE}`);
|
spinner.succeed(`Changelog generated at ${slimPath(DIST_FILE)}`);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,6 @@ export async function clean() {
|
|||||||
emptyDir(ES_DIR),
|
emptyDir(ES_DIR),
|
||||||
emptyDir(LIB_DIR),
|
emptyDir(LIB_DIR),
|
||||||
emptyDir(DIST_DIR),
|
emptyDir(DIST_DIR),
|
||||||
emptyDir(SITE_DIST_DIR)
|
emptyDir(SITE_DIST_DIR),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { readFileSync } from 'fs-extra';
|
import { readFileSync } from 'fs-extra';
|
||||||
import { logger } from '../common/logger';
|
import { consola } from '../common/logger';
|
||||||
|
|
||||||
const commitRE = /^(revert: )?(fix|feat|docs|perf|test|types|build|chore|refactor|breaking change)(\(.+\))?: .{1,50}/;
|
const commitRE = /^(revert: )?(fix|feat|docs|perf|test|types|build|chore|refactor|breaking change)(\(.+\))?: .{1,50}/;
|
||||||
const mergeRE = /Merge branch /;
|
const mergeRE = /Merge branch /;
|
||||||
@ -9,7 +9,7 @@ export function commitLint() {
|
|||||||
const commitMsg = readFileSync(gitParams, 'utf-8').trim();
|
const commitMsg = readFileSync(gitParams, 'utf-8').trim();
|
||||||
|
|
||||||
if (!commitRE.test(commitMsg) && !mergeRE.test(commitMsg)) {
|
if (!commitRE.test(commitMsg) && !mergeRE.test(commitMsg)) {
|
||||||
logger.error(`Error: invalid commit message: "${commitMsg}".
|
consola.error(`invalid commit message: "${commitMsg}".
|
||||||
|
|
||||||
Proper commit message format is required for automated changelog generation.
|
Proper commit message format is required for automated changelog generation.
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import { emptyDir } from 'fs-extra';
|
|
||||||
import { setNodeEnv } from '../common';
|
import { setNodeEnv } from '../common';
|
||||||
import { compileSite } from '../compiler/compile-site';
|
import { compileSite } from '../compiler/compile-site';
|
||||||
import { DIST_DIR } from '../common/constant';
|
|
||||||
|
|
||||||
export async function dev() {
|
export async function dev() {
|
||||||
setNodeEnv('development');
|
setNodeEnv('development');
|
||||||
await emptyDir(DIST_DIR);
|
|
||||||
await compileSite();
|
await compileSite();
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,14 @@ export function test(command: any) {
|
|||||||
setNodeEnv('test');
|
setNodeEnv('test');
|
||||||
|
|
||||||
genPackageEntry({
|
genPackageEntry({
|
||||||
outputPath: PACKAGE_ENTRY_FILE
|
outputPath: PACKAGE_ENTRY_FILE,
|
||||||
});
|
});
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
rootDir: ROOT,
|
rootDir: ROOT,
|
||||||
watch: command.watch,
|
watch: command.watch,
|
||||||
config: JEST_CONFIG_FILE,
|
config: JEST_CONFIG_FILE,
|
||||||
clearCache: command.clearCache
|
clearCache: command.clearCache,
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
runCLI(config, [ROOT])
|
runCLI(config, [ROOT])
|
||||||
|
@ -1,57 +1,66 @@
|
|||||||
import { lint as stylelint } from 'stylelint';
|
// @ts-ignore
|
||||||
import { CLIEngine } from 'eslint';
|
import execa from 'execa';
|
||||||
import { getStepper } from '../common/logger';
|
import { ora } from '../common/logger';
|
||||||
import { SCRIPT_EXTS } from '../common/constant';
|
import { SCRIPT_EXTS } from '../common/constant';
|
||||||
|
|
||||||
const stepper = getStepper(4);
|
type RunCommandMessages = {
|
||||||
|
start: string;
|
||||||
|
succeed: string;
|
||||||
|
failed: string;
|
||||||
|
};
|
||||||
|
|
||||||
function lintScript() {
|
function runCommand(
|
||||||
stepper.start('ESLint Start');
|
cmd: string,
|
||||||
|
options: string[],
|
||||||
|
messages: RunCommandMessages
|
||||||
|
) {
|
||||||
|
const spinner = ora(messages.start).start();
|
||||||
|
|
||||||
const cli = new CLIEngine({
|
return new Promise(resolve => {
|
||||||
fix: true,
|
execa(cmd, options, {
|
||||||
extensions: SCRIPT_EXTS
|
env: { FORCE_COLOR: true },
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
spinner.succeed(messages.succeed);
|
||||||
|
resolve(true);
|
||||||
|
})
|
||||||
|
.catch((err: any) => {
|
||||||
|
spinner.fail(messages.failed);
|
||||||
|
console.log(err.stdout);
|
||||||
|
resolve(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const report = cli.executeOnFiles(['src/']);
|
|
||||||
const formatter = cli.getFormatter();
|
|
||||||
|
|
||||||
CLIEngine.outputFixes(report);
|
|
||||||
|
|
||||||
// output lint errors
|
|
||||||
const formatted = formatter(report.results);
|
|
||||||
if (formatted) {
|
|
||||||
stepper.error('ESLint Failed', '\n' + formatter(report.results));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
stepper.success('ESLint Passed');
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function lintStyle(): Promise<boolean> {
|
function eslint() {
|
||||||
stepper.start('Stylelint Start');
|
return runCommand(
|
||||||
|
'eslint',
|
||||||
return stylelint({
|
['./src', '--fix', '--ext', SCRIPT_EXTS.join(',')],
|
||||||
fix: true,
|
{
|
||||||
formatter: 'string',
|
start: 'Running eslint...',
|
||||||
files: ['src/**/*.css', 'src/**/*.less', 'src/**/*.scss', 'src/**/*.vue']
|
succeed: 'ESLint Passed.',
|
||||||
}).then(result => {
|
failed: 'ESLint failed!',
|
||||||
if (result.errored) {
|
|
||||||
stepper.error('Stylelint Failed', '\n' + result.output);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
stepper.success('Stylelint Passed');
|
function stylelint() {
|
||||||
return true;
|
return runCommand(
|
||||||
});
|
'stylelint',
|
||||||
|
['src/**/*.css', 'src/**/*.vue', 'src/**/*.less', 'src/**/*.sass', '--fix'],
|
||||||
|
{
|
||||||
|
start: 'Running stylelint...',
|
||||||
|
succeed: 'Stylelint Passed.',
|
||||||
|
failed: 'Stylelint failed!',
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function lint() {
|
export async function lint() {
|
||||||
const scriptPassed = lintScript();
|
const eslintPassed = await eslint();
|
||||||
const stylePassed = await lintStyle();
|
const stylelintPassed = await stylelint();
|
||||||
|
|
||||||
if (!scriptPassed || !stylePassed) {
|
if (!eslintPassed || !stylelintPassed) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
|
|||||||
export async function release() {
|
export async function release() {
|
||||||
await releaseIt({
|
await releaseIt({
|
||||||
plugins: {
|
plugins: {
|
||||||
[PLUGIN_PATH]: {}
|
[PLUGIN_PATH]: {},
|
||||||
},
|
},
|
||||||
git: {
|
git: {
|
||||||
tagName: 'v${version}',
|
tagName: 'v${version}',
|
||||||
commitMessage: 'chore: release ${version}'
|
commitMessage: 'chore: release ${version}',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,10 @@ function findRootDir(dir: string): string {
|
|||||||
return findRootDir(dirname(dir));
|
return findRootDir(dirname(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Colors
|
||||||
|
export const GREEN = '#07c160';
|
||||||
|
|
||||||
|
// Root paths
|
||||||
export const CWD = process.cwd();
|
export const CWD = process.cwd();
|
||||||
export const ROOT = findRootDir(CWD);
|
export const ROOT = findRootDir(CWD);
|
||||||
export const ES_DIR = join(ROOT, 'es');
|
export const ES_DIR = join(ROOT, 'es');
|
||||||
@ -24,17 +28,23 @@ export const VANT_CONFIG_FILE = join(ROOT, 'vant.config.js');
|
|||||||
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
|
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
|
||||||
export const ROOT_WEBPACK_CONFIG_FILE = join(ROOT, 'webpack.config.js');
|
export const ROOT_WEBPACK_CONFIG_FILE = join(ROOT, 'webpack.config.js');
|
||||||
export const ROOT_POSTCSS_CONFIG_FILE = join(ROOT, 'postcss.config.js');
|
export const ROOT_POSTCSS_CONFIG_FILE = join(ROOT, 'postcss.config.js');
|
||||||
|
|
||||||
export const DIST_DIR = join(__dirname, '../../dist');
|
|
||||||
export const CONFIG_DIR = join(__dirname, '../config');
|
|
||||||
export const CACHE_DIR = join(ROOT, 'node_modules/.cache');
|
export const CACHE_DIR = join(ROOT, 'node_modules/.cache');
|
||||||
|
|
||||||
|
// Relative paths
|
||||||
|
export const DIST_DIR = join(__dirname, '../../dist');
|
||||||
|
export const CONFIG_DIR = join(__dirname, '../config');
|
||||||
|
|
||||||
|
// Dist files
|
||||||
export const PACKAGE_ENTRY_FILE = join(DIST_DIR, 'package-entry.js');
|
export const PACKAGE_ENTRY_FILE = join(DIST_DIR, 'package-entry.js');
|
||||||
export const PACKAGE_STYLE_FILE = join(DIST_DIR, 'package-style.css');
|
export const PACKAGE_STYLE_FILE = join(DIST_DIR, 'package-style.css');
|
||||||
export const SITE_MODILE_SHARED_FILE = join(DIST_DIR, 'site-mobile-shared.js');
|
export const SITE_MODILE_SHARED_FILE = join(DIST_DIR, 'site-mobile-shared.js');
|
||||||
export const SITE_DESKTOP_SHARED_FILE = join(DIST_DIR, 'site-desktop-shared.js');
|
export const SITE_DESKTOP_SHARED_FILE = join(
|
||||||
|
DIST_DIR,
|
||||||
|
'site-desktop-shared.js'
|
||||||
|
);
|
||||||
export const STYPE_DEPS_JSON_FILE = join(DIST_DIR, 'style-deps.json');
|
export const STYPE_DEPS_JSON_FILE = join(DIST_DIR, 'style-deps.json');
|
||||||
|
|
||||||
|
// Config files
|
||||||
export const BABEL_CONFIG_FILE = join(CONFIG_DIR, 'babel.config.js');
|
export const BABEL_CONFIG_FILE = join(CONFIG_DIR, 'babel.config.js');
|
||||||
export const POSTCSS_CONFIG_FILE = join(CONFIG_DIR, 'postcss.config.js');
|
export const POSTCSS_CONFIG_FILE = join(CONFIG_DIR, 'postcss.config.js');
|
||||||
export const JEST_SETUP_FILE = join(CONFIG_DIR, 'jest.setup.js');
|
export const JEST_SETUP_FILE = join(CONFIG_DIR, 'jest.setup.js');
|
||||||
@ -55,7 +65,11 @@ export function getPackageJson() {
|
|||||||
export function getVantConfig() {
|
export function getVantConfig() {
|
||||||
delete require.cache[VANT_CONFIG_FILE];
|
delete require.cache[VANT_CONFIG_FILE];
|
||||||
|
|
||||||
return require(VANT_CONFIG_FILE);
|
try {
|
||||||
|
return require(VANT_CONFIG_FILE);
|
||||||
|
} catch (err) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSrcDir() {
|
function getSrcDir() {
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { execSync } from 'child_process';
|
|
||||||
import {
|
import {
|
||||||
lstatSync,
|
lstatSync,
|
||||||
existsSync,
|
existsSync,
|
||||||
readdirSync,
|
readdirSync,
|
||||||
readFileSync,
|
readFileSync,
|
||||||
outputFileSync
|
outputFileSync,
|
||||||
} from 'fs-extra';
|
} from 'fs-extra';
|
||||||
import {
|
import {
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
getVantConfig,
|
getVantConfig,
|
||||||
ROOT_WEBPACK_CONFIG_FILE,
|
ROOT_WEBPACK_CONFIG_FILE,
|
||||||
ROOT_POSTCSS_CONFIG_FILE
|
ROOT_POSTCSS_CONFIG_FILE,
|
||||||
} from './constant';
|
} from './constant';
|
||||||
|
|
||||||
export const EXT_REGEXP = /\.\w+$/;
|
export const EXT_REGEXP = /\.\w+$/;
|
||||||
@ -156,19 +155,4 @@ export function smartOutputFile(filePath: string, content: string) {
|
|||||||
outputFileSync(filePath, content);
|
outputFileSync(filePath, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasYarnCache: boolean;
|
|
||||||
|
|
||||||
export function hasYarn() {
|
|
||||||
if (hasYarnCache === undefined) {
|
|
||||||
try {
|
|
||||||
execSync('yarn --version', { stdio: 'ignore' });
|
|
||||||
hasYarnCache = true;
|
|
||||||
} catch (e) {
|
|
||||||
hasYarnCache = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasYarnCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { getVantConfig };
|
export { getVantConfig };
|
||||||
|
@ -1,36 +1,10 @@
|
|||||||
import logger from 'signale';
|
import ora from 'ora';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
import consola from 'consola';
|
||||||
|
import { ROOT } from '../common/constant';
|
||||||
|
|
||||||
logger.config({
|
export function slimPath(path: string) {
|
||||||
displayTimestamp: true
|
return chalk.yellow(path.replace(ROOT, ''));
|
||||||
});
|
|
||||||
|
|
||||||
const methods = ['success', 'start', 'error'] as const;
|
|
||||||
|
|
||||||
type Stepper = Pick<typeof logger, typeof methods[number]>;
|
|
||||||
|
|
||||||
export function getStepper(totalStep: number) {
|
|
||||||
const stepper = {} as Stepper;
|
|
||||||
let currentStep = 0;
|
|
||||||
|
|
||||||
methods.forEach(key => {
|
|
||||||
stepper[key] = (message, ...args) => {
|
|
||||||
const prefix = `[${++currentStep}/${totalStep}] `;
|
|
||||||
return logger[key](prefix + message, ...args);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return stepper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInteractiveLogger() {
|
export { ora, consola };
|
||||||
const interactive = new logger.Signale({
|
|
||||||
interactive: true,
|
|
||||||
config: {
|
|
||||||
displayTimestamp: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return interactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { logger };
|
|
||||||
|
36
packages/vant-cli/src/common/manager.ts
Normal file
36
packages/vant-cli/src/common/manager.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
import execa from 'execa';
|
||||||
|
import { consola } from './logger';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
|
let hasYarnCache: boolean;
|
||||||
|
|
||||||
|
export function hasYarn() {
|
||||||
|
if (hasYarnCache === undefined) {
|
||||||
|
try {
|
||||||
|
execSync('yarn --version', { stdio: 'ignore' });
|
||||||
|
hasYarnCache = true;
|
||||||
|
} catch (e) {
|
||||||
|
hasYarnCache = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasYarnCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function installDependencies() {
|
||||||
|
consola.info('Install Dependencies\n');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const manager = hasYarn() ? 'yarn' : 'npm';
|
||||||
|
|
||||||
|
await execa(manager, ['install', '--prod=false'], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('');
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ const cleanCss = new CleanCss();
|
|||||||
export async function compileCss(source: string | Buffer) {
|
export async function compileCss(source: string | Buffer) {
|
||||||
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
||||||
const { css } = await postcss(config.plugins as any).process(source, {
|
const { css } = await postcss(config.plugins as any).process(source, {
|
||||||
from: undefined
|
from: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return cleanCss.minify(css).styles;
|
return cleanCss.minify(css).styles;
|
||||||
|
@ -13,14 +13,14 @@ class TildeResolver extends FileManager {
|
|||||||
const TildeResolverPlugin = {
|
const TildeResolverPlugin = {
|
||||||
install(lessInstance: unknown, pluginManager: any) {
|
install(lessInstance: unknown, pluginManager: any) {
|
||||||
pluginManager.addFileManager(new TildeResolver());
|
pluginManager.addFileManager(new TildeResolver());
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function compileLess(filePath: string) {
|
export async function compileLess(filePath: string) {
|
||||||
const source = readFileSync(filePath, 'utf-8');
|
const source = readFileSync(filePath, 'utf-8');
|
||||||
const { css } = await render(source, {
|
const { css } = await render(source, {
|
||||||
filename: filePath,
|
filename: filePath,
|
||||||
plugins: [TildeResolverPlugin]
|
plugins: [TildeResolverPlugin],
|
||||||
});
|
});
|
||||||
|
|
||||||
return css;
|
return css;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
import { packageConfig } from '../config/webpack.package';
|
import { getPackageConfig } from '../config/webpack.package';
|
||||||
|
|
||||||
export async function compilePackage(isMinify: boolean) {
|
export async function compilePackage(isMinify: boolean) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
webpack(packageConfig(isMinify), (err, stats) => {
|
const config = getPackageConfig(isMinify);
|
||||||
|
|
||||||
|
webpack(config, (err, stats) => {
|
||||||
if (err || stats.hasErrors()) {
|
if (err || stats.hasErrors()) {
|
||||||
reject();
|
reject();
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,7 +57,7 @@ function compileTemplate(template: string) {
|
|||||||
const result = compileUtils.compileTemplate({
|
const result = compileUtils.compileTemplate({
|
||||||
compiler,
|
compiler,
|
||||||
source: template,
|
source: template,
|
||||||
isProduction: true
|
isProduction: true,
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
return result.code;
|
return result.code;
|
||||||
@ -73,7 +73,7 @@ export function parseSfc(filePath: string) {
|
|||||||
const descriptor = compileUtils.parse({
|
const descriptor = compileUtils.parse({
|
||||||
source,
|
source,
|
||||||
compiler,
|
compiler,
|
||||||
needMap: false
|
needMap: false,
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
@ -1,19 +1,45 @@
|
|||||||
|
import chalk from 'chalk';
|
||||||
|
import address from 'address';
|
||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
import WebpackDevServer from 'webpack-dev-server';
|
import WebpackDevServer from 'webpack-dev-server';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { getPort } from 'portfinder';
|
import { getPort } from 'portfinder';
|
||||||
import { siteDevConfig } from '../config/webpack.site.dev';
|
import { GREEN } from '../common/constant';
|
||||||
import { sitePrdConfig } from '../config/webpack.site.prd';
|
import { getSiteDevConfig } from '../config/webpack.site.dev';
|
||||||
|
import { getSitePrdConfig } from '../config/webpack.site.prd';
|
||||||
|
|
||||||
|
function logServerInfo(port: number) {
|
||||||
|
const local = `http://localhost:${port}/`;
|
||||||
|
const network = `http://${address.ip()}:${port}/`;
|
||||||
|
|
||||||
|
console.log('\n Site running at:\n');
|
||||||
|
console.log(` ${chalk.bold('Local')}: ${chalk.hex(GREEN)(local)} `);
|
||||||
|
console.log(` ${chalk.bold('Network')}: ${chalk.hex(GREEN)(network)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runDevServer(
|
||||||
|
port: number,
|
||||||
|
config: ReturnType<typeof getSiteDevConfig>
|
||||||
|
) {
|
||||||
|
const server = new WebpackDevServer(webpack(config), config.devServer);
|
||||||
|
|
||||||
|
// this is a hack to disable wds status log
|
||||||
|
(server as any).showStatus = function() {};
|
||||||
|
|
||||||
|
const host = get(config.devServer, 'host', 'localhost');
|
||||||
|
server.listen(port, host, (err?: Error) => {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function watch() {
|
function watch() {
|
||||||
const server = new WebpackDevServer(
|
const config = getSiteDevConfig();
|
||||||
webpack(siteDevConfig),
|
|
||||||
siteDevConfig.devServer
|
|
||||||
);
|
|
||||||
|
|
||||||
getPort(
|
getPort(
|
||||||
{
|
{
|
||||||
port: siteDevConfig.devServer!.port
|
port: config.devServer!.port,
|
||||||
},
|
},
|
||||||
(err, port) => {
|
(err, port) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -21,19 +47,17 @@ function watch() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const host = get(siteDevConfig.devServer, 'host', 'localhost');
|
logServerInfo(port);
|
||||||
server.listen(port, host, (err?: Error) => {
|
runDevServer(port, config);
|
||||||
if (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function build() {
|
function build() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
webpack(sitePrdConfig, (err, stats) => {
|
const config = getSitePrdConfig();
|
||||||
|
|
||||||
|
webpack(config, (err, stats) => {
|
||||||
if (err || stats.hasErrors()) {
|
if (err || stats.hasErrors()) {
|
||||||
reject();
|
reject();
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@ import { replaceExt } from '../common';
|
|||||||
import { compileCss } from './compile-css';
|
import { compileCss } from './compile-css';
|
||||||
import { compileLess } from './compile-less';
|
import { compileLess } from './compile-less';
|
||||||
import { compileSass } from './compile-sass';
|
import { compileSass } from './compile-sass';
|
||||||
import { logger } from '../common/logger';
|
import { consola } from '../common/logger';
|
||||||
|
|
||||||
async function compileFile(filePath: string) {
|
async function compileFile(filePath: string) {
|
||||||
const parsedPath = parse(filePath);
|
const parsedPath = parse(filePath);
|
||||||
@ -23,7 +23,7 @@ async function compileFile(filePath: string) {
|
|||||||
const source = readFileSync(filePath, 'utf-8');
|
const source = readFileSync(filePath, 'utf-8');
|
||||||
return await compileCss(source);
|
return await compileCss(source);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Compile style failed: ' + filePath);
|
consola.error('Compile style failed: ' + filePath);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
ES_DIR,
|
ES_DIR,
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
LIB_DIR,
|
LIB_DIR,
|
||||||
STYPE_DEPS_JSON_FILE
|
STYPE_DEPS_JSON_FILE,
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
function getDeps(component: string): string[] {
|
function getDeps(component: string): string[] {
|
||||||
@ -41,12 +41,12 @@ function getRelativePath(component: string, style: string, ext: string) {
|
|||||||
const OUTPUT_CONFIG = [
|
const OUTPUT_CONFIG = [
|
||||||
{
|
{
|
||||||
dir: ES_DIR,
|
dir: ES_DIR,
|
||||||
template: (dep: string) => `import '${dep}';`
|
template: (dep: string) => `import '${dep}';`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dir: LIB_DIR,
|
dir: LIB_DIR,
|
||||||
template: (dep: string) => `require('${dep}');`
|
template: (dep: string) => `require('${dep}');`,
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function genEntry(params: {
|
function genEntry(params: {
|
||||||
@ -92,7 +92,7 @@ export function genComponentStyle(
|
|||||||
baseFile,
|
baseFile,
|
||||||
component,
|
component,
|
||||||
filename: 'index.js',
|
filename: 'index.js',
|
||||||
ext: '.css'
|
ext: '.css',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (CSS_LANG !== 'css') {
|
if (CSS_LANG !== 'css') {
|
||||||
@ -100,7 +100,7 @@ export function genComponentStyle(
|
|||||||
baseFile,
|
baseFile,
|
||||||
component,
|
component,
|
||||||
filename: CSS_LANG + '.js',
|
filename: CSS_LANG + '.js',
|
||||||
ext: '.' + CSS_LANG
|
ext: '.' + CSS_LANG,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { pascalize, getComponents, smartOutputFile, normalizePath } from '../common';
|
import {
|
||||||
|
pascalize,
|
||||||
|
getComponents,
|
||||||
|
smartOutputFile,
|
||||||
|
normalizePath,
|
||||||
|
} from '../common';
|
||||||
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
|
@ -6,14 +6,14 @@ import {
|
|||||||
removeExt,
|
removeExt,
|
||||||
getVantConfig,
|
getVantConfig,
|
||||||
smartOutputFile,
|
smartOutputFile,
|
||||||
normalizePath
|
normalizePath,
|
||||||
} from '../common';
|
} from '../common';
|
||||||
import {
|
import {
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
DOCS_DIR,
|
DOCS_DIR,
|
||||||
getPackageJson,
|
getPackageJson,
|
||||||
VANT_CONFIG_FILE,
|
VANT_CONFIG_FILE,
|
||||||
SITE_DESKTOP_SHARED_FILE
|
SITE_DESKTOP_SHARED_FILE,
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
type DocumentItem = {
|
type DocumentItem = {
|
||||||
@ -52,7 +52,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
|||||||
components.forEach(component => {
|
components.forEach(component => {
|
||||||
docs.push({
|
docs.push({
|
||||||
name: formatName(component, lang),
|
name: formatName(component, lang),
|
||||||
path: join(SRC_DIR, component, fileName)
|
path: join(SRC_DIR, component, fileName),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -60,16 +60,16 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
|||||||
components.forEach(component => {
|
components.forEach(component => {
|
||||||
docs.push({
|
docs.push({
|
||||||
name: formatName(component),
|
name: formatName(component),
|
||||||
path: join(SRC_DIR, component, 'README.md')
|
path: join(SRC_DIR, component, 'README.md'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const staticDocs = glob.sync(join(DOCS_DIR, '**/*.md')).map(path => {
|
const staticDocs = glob.sync(normalizePath(join(DOCS_DIR, '**/*.md'))).map(path => {
|
||||||
const pairs = parse(path).name.split('.');
|
const pairs = parse(path).name.split('.');
|
||||||
return {
|
return {
|
||||||
name: formatName(pairs[0], pairs[1] || defaultLang),
|
name: formatName(pairs[0], pairs[1] || defaultLang),
|
||||||
path
|
path,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
decamelize,
|
decamelize,
|
||||||
getVantConfig,
|
getVantConfig,
|
||||||
smartOutputFile,
|
smartOutputFile,
|
||||||
normalizePath
|
normalizePath,
|
||||||
} from '../common';
|
} from '../common';
|
||||||
|
|
||||||
type DemoItem = {
|
type DemoItem = {
|
||||||
@ -25,7 +25,10 @@ import './package-style';
|
|||||||
|
|
||||||
function genImports(demos: DemoItem[]) {
|
function genImports(demos: DemoItem[]) {
|
||||||
return demos
|
return demos
|
||||||
.map(item => `import ${item.name} from '${removeExt(normalizePath(item.path))}';`)
|
.map(
|
||||||
|
item =>
|
||||||
|
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
||||||
|
)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +76,7 @@ function genCode(components: string[]) {
|
|||||||
.map(component => ({
|
.map(component => ({
|
||||||
component,
|
component,
|
||||||
name: pascalize(component),
|
name: pascalize(component),
|
||||||
path: join(SRC_DIR, component, 'demo/index.vue')
|
path: join(SRC_DIR, component, 'demo/index.vue'),
|
||||||
}))
|
}))
|
||||||
.filter(item => existsSync(item.path));
|
.filter(item => existsSync(item.path));
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import { getDeps, clearDepsCache, fillExt } from './get-deps';
|
|||||||
import { getComponents, smartOutputFile } from '../common';
|
import { getComponents, smartOutputFile } from '../common';
|
||||||
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
|
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
|
||||||
|
|
||||||
const components = getComponents();
|
|
||||||
|
|
||||||
function matchPath(path: string, component: string): boolean {
|
function matchPath(path: string, component: string): boolean {
|
||||||
return path
|
return path
|
||||||
.replace(SRC_DIR, '')
|
.replace(SRC_DIR, '')
|
||||||
@ -23,7 +21,7 @@ export function checkStyleExists(component: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// analyze component dependencies
|
// analyze component dependencies
|
||||||
function analyzeComponentDeps(component: string) {
|
function analyzeComponentDeps(components: string[], component: string) {
|
||||||
const checkList: string[] = [];
|
const checkList: string[] = [];
|
||||||
const componentEntry = fillExt(join(SRC_DIR, component, 'index'));
|
const componentEntry = fillExt(join(SRC_DIR, component, 'index'));
|
||||||
const record = new Set();
|
const record = new Set();
|
||||||
@ -54,7 +52,7 @@ function analyzeComponentDeps(component: string) {
|
|||||||
|
|
||||||
type DepsMap = Record<string, string[]>;
|
type DepsMap = Record<string, string[]>;
|
||||||
|
|
||||||
function getSequence(depsMap: DepsMap) {
|
function getSequence(components: string[], depsMap: DepsMap) {
|
||||||
const sequence: string[] = [];
|
const sequence: string[] = [];
|
||||||
const record = new Set();
|
const record = new Set();
|
||||||
|
|
||||||
@ -94,16 +92,18 @@ function getSequence(depsMap: DepsMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function genStyleDepsMap() {
|
export async function genStyleDepsMap() {
|
||||||
|
const components = getComponents();
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
clearDepsCache();
|
clearDepsCache();
|
||||||
|
|
||||||
const map = {} as DepsMap;
|
const map = {} as DepsMap;
|
||||||
|
|
||||||
components.forEach(component => {
|
components.forEach(component => {
|
||||||
map[component] = analyzeComponentDeps(component);
|
map[component] = analyzeComponentDeps(components, component);
|
||||||
});
|
});
|
||||||
|
|
||||||
const sequence = getSequence(map);
|
const sequence = getSequence(components, map);
|
||||||
|
|
||||||
Object.keys(map).forEach(key => {
|
Object.keys(map).forEach(key => {
|
||||||
map[key] = map[key].sort(
|
map[key] = map[key].sort(
|
||||||
|
@ -14,7 +14,7 @@ export function genVeturConfig() {
|
|||||||
path: SRC_DIR,
|
path: SRC_DIR,
|
||||||
test: /zh-CN\.md/,
|
test: /zh-CN\.md/,
|
||||||
outputDir: join(ROOT, 'vetur'),
|
outputDir: join(ROOT, 'vetur'),
|
||||||
...options
|
...options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,33 +10,33 @@ import { PACKAGE_ENTRY_FILE, PACKAGE_STYLE_FILE } from '../common/constant';
|
|||||||
|
|
||||||
const PLUGIN_NAME = 'VantCliSitePlugin';
|
const PLUGIN_NAME = 'VantCliSitePlugin';
|
||||||
|
|
||||||
|
export async function genSiteEntry() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
genStyleDepsMap()
|
||||||
|
.then(() => {
|
||||||
|
genPackageEntry({
|
||||||
|
outputPath: PACKAGE_ENTRY_FILE,
|
||||||
|
});
|
||||||
|
genPacakgeStyle({
|
||||||
|
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`),
|
||||||
|
});
|
||||||
|
genSiteMobileShared();
|
||||||
|
genSiteDesktopShared();
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export class VantCliSitePlugin {
|
export class VantCliSitePlugin {
|
||||||
apply(compiler: Compiler) {
|
apply(compiler: Compiler) {
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, this.genSiteEntry);
|
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, genSiteEntry);
|
||||||
} else {
|
} else {
|
||||||
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, this.genSiteEntry);
|
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, genSiteEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
genSiteEntry() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
genStyleDepsMap()
|
|
||||||
.then(() => {
|
|
||||||
genPackageEntry({
|
|
||||||
outputPath: PACKAGE_ENTRY_FILE
|
|
||||||
});
|
|
||||||
genPacakgeStyle({
|
|
||||||
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`)
|
|
||||||
});
|
|
||||||
genSiteMobileShared();
|
|
||||||
genSiteDesktopShared();
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,38 +15,36 @@ module.exports = function(api?: ConfigAPI) {
|
|||||||
'@babel/preset-env',
|
'@babel/preset-env',
|
||||||
{
|
{
|
||||||
loose: true,
|
loose: true,
|
||||||
modules: useESModules ? false : 'commonjs'
|
modules: useESModules ? false : 'commonjs',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'@vue/babel-preset-jsx',
|
'@vue/babel-preset-jsx',
|
||||||
{
|
{
|
||||||
functional: false
|
functional: false,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'@babel/preset-typescript'
|
'@babel/preset-typescript',
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
[
|
[
|
||||||
'@babel/plugin-transform-runtime',
|
'@babel/plugin-transform-runtime',
|
||||||
{
|
{
|
||||||
corejs: false,
|
corejs: false,
|
||||||
useESModules
|
useESModules,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'import',
|
'import',
|
||||||
{
|
{
|
||||||
libraryName: 'vant',
|
libraryName: 'vant',
|
||||||
libraryDirectory: useESModules ? 'es' : 'lib',
|
libraryDirectory: useESModules ? 'es' : 'lib',
|
||||||
style: true
|
style: true,
|
||||||
},
|
},
|
||||||
'vant'
|
'vant',
|
||||||
],
|
],
|
||||||
'@babel/plugin-transform-object-assign',
|
'@babel/plugin-transform-object-assign',
|
||||||
'@babel/plugin-proposal-optional-chaining',
|
],
|
||||||
'@babel/plugin-proposal-nullish-coalescing-operator'
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,26 +4,26 @@ import {
|
|||||||
ROOT,
|
ROOT,
|
||||||
JEST_SETUP_FILE,
|
JEST_SETUP_FILE,
|
||||||
JEST_FILE_MOCK_FILE,
|
JEST_FILE_MOCK_FILE,
|
||||||
JEST_STYLE_MOCK_FILE
|
JEST_STYLE_MOCK_FILE,
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
const DEFAULT_CONFIG = {
|
const DEFAULT_CONFIG = {
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
|
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
|
||||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE,
|
||||||
},
|
},
|
||||||
setupFilesAfterEnv: [JEST_SETUP_FILE],
|
setupFilesAfterEnv: [JEST_SETUP_FILE],
|
||||||
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
||||||
transform: {
|
transform: {
|
||||||
'\\.(vue)$': 'vue-jest',
|
'\\.(vue)$': 'vue-jest',
|
||||||
'\\.(js|jsx|ts|tsx)$': 'babel-jest'
|
'\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
||||||
},
|
},
|
||||||
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
|
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
|
||||||
snapshotSerializers: ['jest-serializer-vue'],
|
snapshotSerializers: ['jest-serializer-vue'],
|
||||||
collectCoverage: true,
|
collectCoverage: true,
|
||||||
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', '!**/demo/**'],
|
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', '!**/demo/**'],
|
||||||
coverageReporters: ['html', 'lcov', 'text-summary'],
|
coverageReporters: ['html', 'lcov', 'text-summary'],
|
||||||
coverageDirectory: './test/coverage'
|
coverageDirectory: './test/coverage',
|
||||||
};
|
};
|
||||||
|
|
||||||
function readRootConfig() {
|
function readRootConfig() {
|
||||||
@ -38,5 +38,5 @@ function readRootConfig() {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...DEFAULT_CONFIG,
|
...DEFAULT_CONFIG,
|
||||||
...readRootConfig()
|
...readRootConfig(),
|
||||||
};
|
};
|
||||||
|
@ -7,20 +7,20 @@ type PostcssConfig = object & {
|
|||||||
function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) {
|
function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) {
|
||||||
const plugins = {
|
const plugins = {
|
||||||
...config1.plugins,
|
...config1.plugins,
|
||||||
...config2.plugins
|
...config2.plugins,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...config1,
|
...config1,
|
||||||
...config2,
|
...config2,
|
||||||
plugins
|
plugins,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_CONFIG = {
|
const DEFAULT_CONFIG = {
|
||||||
plugins: {
|
plugins: {
|
||||||
autoprefixer: {}
|
autoprefixer: {},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig());
|
module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig());
|
||||||
|
@ -6,14 +6,14 @@ import {
|
|||||||
CACHE_DIR,
|
CACHE_DIR,
|
||||||
STYLE_EXTS,
|
STYLE_EXTS,
|
||||||
SCRIPT_EXTS,
|
SCRIPT_EXTS,
|
||||||
POSTCSS_CONFIG_FILE
|
POSTCSS_CONFIG_FILE,
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
const CACHE_LOADER = {
|
const CACHE_LOADER = {
|
||||||
loader: 'cache-loader',
|
loader: 'cache-loader',
|
||||||
options: {
|
options: {
|
||||||
cacheDirectory: CACHE_DIR
|
cacheDirectory: CACHE_DIR,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CSS_LOADERS = [
|
const CSS_LOADERS = [
|
||||||
@ -23,16 +23,16 @@ const CSS_LOADERS = [
|
|||||||
loader: 'postcss-loader',
|
loader: 'postcss-loader',
|
||||||
options: {
|
options: {
|
||||||
config: {
|
config: {
|
||||||
path: POSTCSS_CONFIG_FILE
|
path: POSTCSS_CONFIG_FILE,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const baseConfig = {
|
export const baseConfig = {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS]
|
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS],
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
@ -44,26 +44,26 @@ export const baseConfig = {
|
|||||||
loader: 'vue-loader',
|
loader: 'vue-loader',
|
||||||
options: {
|
options: {
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
preserveWhitespace: false
|
preserveWhitespace: false,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(js|ts|jsx|tsx)$/,
|
test: /\.(js|ts|jsx|tsx)$/,
|
||||||
exclude: /node_modules\/(?!(@vant\/cli))/,
|
exclude: /node_modules\/(?!(@vant\/cli))/,
|
||||||
use: [CACHE_LOADER, 'babel-loader']
|
use: [CACHE_LOADER, 'babel-loader'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
sideEffects: true,
|
sideEffects: true,
|
||||||
use: CSS_LOADERS
|
use: CSS_LOADERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.less$/,
|
test: /\.less$/,
|
||||||
sideEffects: true,
|
sideEffects: true,
|
||||||
use: [...CSS_LOADERS, 'less-loader']
|
use: [...CSS_LOADERS, 'less-loader'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
@ -73,22 +73,22 @@ export const baseConfig = {
|
|||||||
{
|
{
|
||||||
loader: 'sass-loader',
|
loader: 'sass-loader',
|
||||||
options: {
|
options: {
|
||||||
implementation: sass
|
implementation: sass,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.md$/,
|
test: /\.md$/,
|
||||||
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader']
|
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader'],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new VueLoaderPlugin(),
|
new VueLoaderPlugin(),
|
||||||
new FriendlyErrorsPlugin({
|
new FriendlyErrorsPlugin({
|
||||||
clearConsole: false,
|
clearConsole: false,
|
||||||
logLevel: 'WARNING'
|
logLevel: 'WARNING',
|
||||||
})
|
}),
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ import { baseConfig } from './webpack.base';
|
|||||||
import { getVantConfig, getWebpackConfig, setBuildTarget } from '../common';
|
import { getVantConfig, getWebpackConfig, setBuildTarget } from '../common';
|
||||||
import { LIB_DIR, ES_DIR } from '../common/constant';
|
import { LIB_DIR, ES_DIR } from '../common/constant';
|
||||||
|
|
||||||
export function packageConfig(isMinify: boolean) {
|
export function getPackageConfig(isMinify: boolean) {
|
||||||
const { name } = getVantConfig();
|
const { name } = getVantConfig();
|
||||||
|
|
||||||
setBuildTarget('package');
|
setBuildTarget('package');
|
||||||
@ -14,7 +14,7 @@ export function packageConfig(isMinify: boolean) {
|
|||||||
{
|
{
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
entry: {
|
entry: {
|
||||||
[name]: join(ES_DIR, 'index.js')
|
[name]: join(ES_DIR, 'index.js'),
|
||||||
},
|
},
|
||||||
stats: 'none',
|
stats: 'none',
|
||||||
output: {
|
output: {
|
||||||
@ -24,20 +24,20 @@ export function packageConfig(isMinify: boolean) {
|
|||||||
filename: isMinify ? '[name].min.js' : '[name].js',
|
filename: isMinify ? '[name].min.js' : '[name].js',
|
||||||
umdNamedDefine: true,
|
umdNamedDefine: true,
|
||||||
// https://github.com/webpack/webpack/issues/6522
|
// https://github.com/webpack/webpack/issues/6522
|
||||||
globalObject: "typeof self !== 'undefined' ? self : this"
|
globalObject: "typeof self !== 'undefined' ? self : this",
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
vue: {
|
vue: {
|
||||||
root: 'Vue',
|
root: 'Vue',
|
||||||
commonjs: 'vue',
|
commonjs: 'vue',
|
||||||
commonjs2: 'vue',
|
commonjs2: 'vue',
|
||||||
amd: 'vue'
|
amd: 'vue',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
performance: false,
|
performance: false,
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: isMinify
|
minimize: isMinify,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
getWebpackConfig()
|
getWebpackConfig()
|
||||||
);
|
);
|
||||||
|
@ -8,95 +8,100 @@ import { baseConfig } from './webpack.base';
|
|||||||
import { getVantConfig, getWebpackConfig } from '../common';
|
import { getVantConfig, getWebpackConfig } from '../common';
|
||||||
import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin';
|
import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin';
|
||||||
import {
|
import {
|
||||||
|
GREEN,
|
||||||
SITE_MODILE_SHARED_FILE,
|
SITE_MODILE_SHARED_FILE,
|
||||||
SITE_DESKTOP_SHARED_FILE
|
SITE_DESKTOP_SHARED_FILE,
|
||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
const vantConfig = getVantConfig();
|
export function getSiteDevBaseConfig() {
|
||||||
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
const vantConfig = getVantConfig();
|
||||||
|
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
||||||
|
|
||||||
function getSiteConfig() {
|
function getSiteConfig() {
|
||||||
const siteConfig = vantConfig.site;
|
const siteConfig = vantConfig.site;
|
||||||
|
|
||||||
if (siteConfig.locales) {
|
if (siteConfig.locales) {
|
||||||
return siteConfig.locales[siteConfig.defaultLang || 'en-US'];
|
return siteConfig.locales[siteConfig.defaultLang || 'en-US'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return siteConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
return siteConfig;
|
function getTitle(config: { title: string; description?: string }) {
|
||||||
}
|
let { title } = config;
|
||||||
|
|
||||||
function getTitle(config: { title: string, description?: string }) {
|
if (config.description) {
|
||||||
let { title } = config;
|
title += ` - ${config.description}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.description) {
|
return title;
|
||||||
title += ` - ${config.description}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return title;
|
const siteConfig = getSiteConfig();
|
||||||
|
const title = getTitle(siteConfig);
|
||||||
|
|
||||||
|
return merge(baseConfig as any, {
|
||||||
|
entry: {
|
||||||
|
'site-desktop': [join(__dirname, '../../site/desktop/main.js')],
|
||||||
|
'site-mobile': [join(__dirname, '../../site/mobile/main.js')],
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
port: 8080,
|
||||||
|
quiet: true,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
stats: 'errors-only',
|
||||||
|
publicPath: '/',
|
||||||
|
disableHostCheck: true,
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'site-mobile-shared': SITE_MODILE_SHARED_FILE,
|
||||||
|
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
chunkFilename: '[name].js',
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
cacheGroups: {
|
||||||
|
chunks: {
|
||||||
|
chunks: 'all',
|
||||||
|
minChunks: 2,
|
||||||
|
minSize: 0,
|
||||||
|
name: 'chunks',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new WebpackBar({
|
||||||
|
name: 'Vant Cli',
|
||||||
|
color: GREEN,
|
||||||
|
}),
|
||||||
|
new VantCliSitePlugin(),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
title,
|
||||||
|
logo: siteConfig.logo,
|
||||||
|
description: siteConfig.description,
|
||||||
|
chunks: ['chunks', 'site-desktop'],
|
||||||
|
template: join(__dirname, '../../site/desktop/index.html'),
|
||||||
|
filename: 'index.html',
|
||||||
|
baiduAnalytics,
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
title,
|
||||||
|
logo: siteConfig.logo,
|
||||||
|
description: siteConfig.description,
|
||||||
|
chunks: ['chunks', 'site-mobile'],
|
||||||
|
template: join(__dirname, '../../site/mobile/index.html'),
|
||||||
|
filename: 'mobile.html',
|
||||||
|
baiduAnalytics,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const siteConfig = getSiteConfig();
|
export function getSiteDevConfig() {
|
||||||
const title = getTitle(siteConfig);
|
return merge(getSiteDevBaseConfig(), getWebpackConfig());
|
||||||
|
}
|
||||||
export const siteDevBaseConfig = merge(baseConfig as any, {
|
|
||||||
entry: {
|
|
||||||
'site-desktop': [join(__dirname, '../../site/desktop/main.js')],
|
|
||||||
'site-mobile': [join(__dirname, '../../site/mobile/main.js')]
|
|
||||||
},
|
|
||||||
devServer: {
|
|
||||||
port: 8080,
|
|
||||||
quiet: true,
|
|
||||||
host: '0.0.0.0',
|
|
||||||
stats: 'errors-only',
|
|
||||||
publicPath: '/',
|
|
||||||
disableHostCheck: true
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'site-mobile-shared': SITE_MODILE_SHARED_FILE,
|
|
||||||
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE
|
|
||||||
}
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
chunkFilename: '[name].js'
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
splitChunks: {
|
|
||||||
cacheGroups: {
|
|
||||||
chunks: {
|
|
||||||
chunks: 'all',
|
|
||||||
minChunks: 2,
|
|
||||||
minSize: 0,
|
|
||||||
name: 'chunks'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new WebpackBar({
|
|
||||||
name: 'Vant Cli',
|
|
||||||
color: '#07c160'
|
|
||||||
}),
|
|
||||||
new VantCliSitePlugin(),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
title,
|
|
||||||
logo: siteConfig.logo,
|
|
||||||
description: siteConfig.description,
|
|
||||||
chunks: ['chunks', 'site-desktop'],
|
|
||||||
template: join(__dirname, '../../site/desktop/index.html'),
|
|
||||||
filename: 'index.html',
|
|
||||||
baiduAnalytics
|
|
||||||
}),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
title,
|
|
||||||
logo: siteConfig.logo,
|
|
||||||
description: siteConfig.description,
|
|
||||||
chunks: ['chunks', 'site-mobile'],
|
|
||||||
template: join(__dirname, '../../site/mobile/index.html'),
|
|
||||||
filename: 'mobile.html',
|
|
||||||
baiduAnalytics
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
export const siteDevConfig = merge(siteDevBaseConfig, getWebpackConfig());
|
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { getVantConfig, getWebpackConfig } from '../common';
|
import { getVantConfig, getWebpackConfig } from '../common';
|
||||||
import { siteDevBaseConfig } from './webpack.site.dev';
|
import { getSiteDevBaseConfig } from './webpack.site.dev';
|
||||||
import { SITE_DIST_DIR } from '../common/constant';
|
import { SITE_DIST_DIR } from '../common/constant';
|
||||||
|
|
||||||
const vantConfig = getVantConfig();
|
const vantConfig = getVantConfig();
|
||||||
const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR);
|
const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR);
|
||||||
const publicPath = get(vantConfig, 'build.site.publicPath', '/');
|
const publicPath = get(vantConfig, 'build.site.publicPath', '/');
|
||||||
|
|
||||||
export const sitePrdConfig = merge(
|
export function getSitePrdConfig() {
|
||||||
siteDevBaseConfig,
|
return merge(
|
||||||
{
|
getSiteDevBaseConfig(),
|
||||||
mode: 'production',
|
{
|
||||||
stats: 'none',
|
mode: 'production',
|
||||||
output: {
|
stats: 'none',
|
||||||
publicPath,
|
output: {
|
||||||
path: outputDir,
|
publicPath,
|
||||||
filename: '[name].[hash:8].js',
|
path: outputDir,
|
||||||
chunkFilename: 'async_[name].[chunkhash:8].js'
|
filename: '[name].[hash:8].js',
|
||||||
}
|
chunkFilename: 'async_[name].[chunkhash:8].js',
|
||||||
},
|
},
|
||||||
getWebpackConfig()
|
},
|
||||||
);
|
getWebpackConfig()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
import { command, parse, version } from 'commander';
|
||||||
|
|
||||||
import { command, parse } from 'commander';
|
// @ts-ignore
|
||||||
|
import packageJson from '../package.json';
|
||||||
|
|
||||||
|
// commands
|
||||||
import { dev } from './commands/dev';
|
import { dev } from './commands/dev';
|
||||||
import { lint } from './commands/lint';
|
import { lint } from './commands/lint';
|
||||||
import { test } from './commands/jest';
|
import { test } from './commands/jest';
|
||||||
@ -11,6 +15,8 @@ import { changelog } from './commands/changelog';
|
|||||||
import { buildSite } from './commands/build-site';
|
import { buildSite } from './commands/build-site';
|
||||||
import { commitLint } from './commands/commit-lint';
|
import { commitLint } from './commands/commit-lint';
|
||||||
|
|
||||||
|
version(`@vant/cli ${packageJson.version}`);
|
||||||
|
|
||||||
command('dev')
|
command('dev')
|
||||||
.description('Run webpack dev server')
|
.description('Run webpack dev server')
|
||||||
.action(dev);
|
.action(dev);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "ES2017",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
ecmaVersion: 2018,
|
ecmaVersion: 2018,
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
extraFileExtensions: ['.vue']
|
extraFileExtensions: ['.vue'],
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: ['@typescript-eslint'],
|
plugins: ['@typescript-eslint'],
|
||||||
@ -14,13 +14,13 @@ module.exports = {
|
|||||||
es6: true,
|
es6: true,
|
||||||
node: true,
|
node: true,
|
||||||
jest: true,
|
jest: true,
|
||||||
browser: true
|
browser: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
globals: {
|
globals: {
|
||||||
window: false,
|
window: false,
|
||||||
document: false,
|
document: false,
|
||||||
navigator: false
|
navigator: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
@ -32,8 +32,17 @@ module.exports = {
|
|||||||
'no-console': 0,
|
'no-console': 0,
|
||||||
'no-plusplus': 0,
|
'no-plusplus': 0,
|
||||||
'arrow-parens': 0,
|
'arrow-parens': 0,
|
||||||
'comma-dangle': 0,
|
|
||||||
'default-case': 0,
|
'default-case': 0,
|
||||||
|
'comma-dangle': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
arrays: 'always-multiline',
|
||||||
|
objects: 'always-multiline',
|
||||||
|
imports: 'always-multiline',
|
||||||
|
exports: 'always-multiline',
|
||||||
|
functions: 'never',
|
||||||
|
},
|
||||||
|
],
|
||||||
'prefer-template': 0,
|
'prefer-template': 0,
|
||||||
'consistent-return': 0,
|
'consistent-return': 0,
|
||||||
'no-param-reassign': 0,
|
'no-param-reassign': 0,
|
||||||
@ -64,6 +73,14 @@ module.exports = {
|
|||||||
'vue/name-property-casing': ['error', 'kebab-case'],
|
'vue/name-property-casing': ['error', 'kebab-case'],
|
||||||
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
|
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
|
||||||
'vue/html-closing-bracket-newline': 2,
|
'vue/html-closing-bracket-newline': 2,
|
||||||
'@typescript-eslint/no-unused-vars': ['error']
|
'vue/html-self-closing': [
|
||||||
}
|
'error',
|
||||||
|
{
|
||||||
|
html: {
|
||||||
|
void: 'always',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'@typescript-eslint/no-unused-vars': ['error'],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@vant/eslint-config",
|
"name": "@vant/eslint-config",
|
||||||
"version": "1.5.1",
|
"version": "2.0.0",
|
||||||
"description": "eslint config of vant.",
|
"description": "eslint config of vant",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
@ -9,16 +9,16 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-eslint-config",
|
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-eslint-config",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^6.7.2"
|
"eslint": "^6.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^2.12.0",
|
"@typescript-eslint/eslint-plugin": "^2.16.0",
|
||||||
"@typescript-eslint/parser": "^2.12.0",
|
"@typescript-eslint/parser": "^2.16.0",
|
||||||
"eslint-config-airbnb-base": "^14.0.0",
|
"eslint-config-airbnb-base": "^14.0.0",
|
||||||
"eslint-plugin-import": "^2.19.1",
|
"eslint-plugin-import": "^2.20.0",
|
||||||
"eslint-plugin-vue": "^6.0.1"
|
"eslint-plugin-vue": "^6.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^6.7.2"
|
"eslint": "^6.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
## 1.2.1
|
||||||
|
|
||||||
|
- update share icon
|
||||||
|
|
||||||
|
## 1.2.0
|
||||||
|
|
||||||
|
- fix medal、medal-o typo
|
||||||
|
|
||||||
## 1.1.14
|
## 1.1.14
|
||||||
|
|
||||||
- add down、wap-home-o icon
|
- add down、wap-home-o icon
|
||||||
|
Binary file not shown.
@ -36,13 +36,13 @@ function font() {
|
|||||||
targetPath: '../src/index.less',
|
targetPath: '../src/index.less',
|
||||||
normalize: true,
|
normalize: true,
|
||||||
firstGlyph: 0xf000,
|
firstGlyph: 0xf000,
|
||||||
cssClass: fontName // this is a trick to pass fontName to template
|
cssClass: fontName, // this is a trick to pass fontName to template
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
iconfont({
|
iconfont({
|
||||||
fontName,
|
fontName,
|
||||||
formats
|
formats,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.pipe(dest(srcDir));
|
.pipe(dest(srcDir));
|
||||||
|
@ -4,7 +4,8 @@ const shell = require('shelljs');
|
|||||||
|
|
||||||
const svgDir = path.join(__dirname, '../assets/svg');
|
const svgDir = path.join(__dirname, '../assets/svg');
|
||||||
const sketch = path.join(__dirname, '../assets/icons.sketch');
|
const sketch = path.join(__dirname, '../assets/icons.sketch');
|
||||||
const SKETCH_TOOL_DIR = '/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool';
|
const SKETCH_TOOL_DIR =
|
||||||
|
'/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool';
|
||||||
|
|
||||||
fs.removeSync(svgDir);
|
fs.removeSync(svgDir);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<% _.each(glyphs, function(glyph) { %>.van-icon-<%= glyph.fileName %>:before {
|
<% _.each(glyphs, function(glyph) { %>.van-icon-<%= glyph.fileName %>::before {
|
||||||
content: "\<%= glyph.codePoint %>";
|
content: "\<%= glyph.codePoint %>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vant/icons",
|
"name": "@vant/icons",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"description": "vant icons",
|
"description": "vant icons",
|
||||||
"main": "./src/config.js",
|
"main": "./src/config.js",
|
||||||
"files": [
|
"files": [
|
||||||
@ -23,6 +23,7 @@
|
|||||||
"gulp-iconfont": "^10.0.3",
|
"gulp-iconfont": "^10.0.3",
|
||||||
"gulp-iconfont-css": "^3.0.0",
|
"gulp-iconfont-css": "^3.0.0",
|
||||||
"md5-file": "^4.0.0",
|
"md5-file": "^4.0.0",
|
||||||
|
"release-it": "^12.4.3",
|
||||||
"shelljs": "^0.8.3",
|
"shelljs": "^0.8.3",
|
||||||
"svgo": "1.2.2"
|
"svgo": "1.2.2"
|
||||||
},
|
},
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user