mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-27 11:56:35 +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+.
|
||||
|
||||
## 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
|
||||
|
||||
* [Documentation](https://youzan.github.io/vant)
|
||||
* [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
|
||||
|
||||
|
@ -16,8 +16,6 @@
|
||||
<p align="center">
|
||||
🔥 <a href="https://youzan.github.io/vant">文档网站</a>
|
||||
|
||||
🇬🇧 <a href="./README.md">英文版介绍</a>
|
||||
|
||||
🚀 <a href="https://github.com/youzan/vant-weapp" target="_blank">小程序版</a>
|
||||
</p>
|
||||
|
||||
@ -80,13 +78,21 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手
|
||||
- <a target="_blank" href="https://tech.youzan.com/tag/front-end/">团队博客</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#/zh-CN/changelog)
|
||||
* [码云镜像](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 = {
|
||||
presets: ['@vant/cli/preset']
|
||||
presets: ['@vant/cli/preset'],
|
||||
};
|
||||
|
@ -1,52 +1,126 @@
|
||||
# Changelog
|
||||
|
||||
### [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**
|
||||
|
||||
* 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)
|
||||
### [v2.4.6](https://github.com/youzan/vant/compare/v2.4.5...v2.4.6)
|
||||
`2020-02-01`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
* Calendar: missing info when selected [#5536](https://github.com/youzan/vant/issues/5536)
|
||||
* PullRefresh: should set height when using head-height [028747](https://github.com/youzan/vant/commit/028747c35471f33e8c2b0baa6fb8915510daac22)
|
||||
* Picker: should watch columns change [#5614](https://github.com/youzan/vant/issues/5614)
|
||||
|
||||
|
||||
### [v2.4.2-beta.1](https://github.com/youzan/vant/compare/v2.4.2-beta.0...v2.4.2-beta.1)
|
||||
`2020-01-09`
|
||||
### [v2.4.5](https://github.com/youzan/vant/compare/v2.4.4...v2.4.5)
|
||||
`2020-02-01`
|
||||
|
||||
**Feature**
|
||||
|
||||
* Field: add digit type [#5524](https://github.com/youzan/vant/issues/5524)
|
||||
* Sku: add properties support [#5525](https://github.com/youzan/vant/issues/5525)
|
||||
* Calendar: scroll to current month when show [#5526](https://github.com/youzan/vant/issues/5526)
|
||||
* Picker: support cascade columns [#4247](https://github.com/youzan/vant/issues/4247)
|
||||
* Slider: add button-size prop [1e9b8c](https://github.com/youzan/vant/commit/1e9b8c846674562d56ab638a0982baab4bb6870e)
|
||||
* 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**
|
||||
|
||||
* 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)
|
||||
* Tabs: can not render line when wrapper is fixed [#5496](https://github.com/youzan/vant/issues/5496)
|
||||
* ImagePreview: limit max-zoom when double clicking [1baa60](https://github.com/youzan/vant/commit/1baa60f2244b4605dc82f6dcf564671f5c623023)
|
||||
* Popup: duration prop not work when position is center [44072e](https://github.com/youzan/vant/commit/44072e8c3f548cff78401780213ab7ef213372c3)
|
||||
* 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**
|
||||
|
||||
* CouponList: update style [#5501](https://github.com/youzan/vant/issues/5501)
|
||||
* AddressList: update style [#5507](https://github.com/youzan/vant/issues/5507)
|
||||
|
||||
|
||||
### [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)
|
||||
* Icon: update share icon [2f77ac](https://github.com/youzan/vant/commit/2f77acfc6cef23ea664defc38c4cd806ceca1ee4)
|
||||
* 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)
|
||||
|
||||
**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)
|
||||
* 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)
|
||||
|
@ -10,54 +10,126 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
|
||||
- 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。
|
||||
- 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 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**
|
||||
|
||||
* Field: 新增 formatter 属性 [#5534](https://github.com/youzan/vant/issues/5534)
|
||||
* Swipe: 新增 prev、next 方法 [#5548](https://github.com/youzan/vant/issues/5548)
|
||||
### [v2.4.6](https://github.com/youzan/vant/compare/v2.4.5...v2.4.6)
|
||||
`2020-02-01`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
* Calendar: 修复选中的日期无法展示提示信息的问题 [#5536](https://github.com/youzan/vant/issues/5536)
|
||||
* PullRefresh:修复 head-height 属性未正确设置高度的问题 [028747](https://github.com/youzan/vant/commit/028747c35471f33e8c2b0baa6fb8915510daac22)
|
||||
* Picker: 修复更新 columns 数据不生效的问题 [#5614](https://github.com/youzan/vant/issues/5614)
|
||||
|
||||
|
||||
|
||||
### [v2.4.2-beta.1](https://github.com/youzan/vant/compare/v2.4.2-beta.0...v2.4.2-beta.1)
|
||||
`2020-01-09`
|
||||
### [v2.4.5](https://github.com/youzan/vant/compare/v2.4.4...v2.4.5)
|
||||
`2020-02-01`
|
||||
|
||||
**Feature**
|
||||
|
||||
* Field: 新增 digit 类型 [#5524](https://github.com/youzan/vant/issues/5524)
|
||||
* Sku: 支持 properties 数据结构 [#5525](https://github.com/youzan/vant/issues/5525)
|
||||
* Calendar: 弹出时自动滚动到当前选中的日期 [#5526](https://github.com/youzan/vant/issues/5526)
|
||||
* Picker: 支持级联选择 [#4247](https://github.com/youzan/vant/issues/4247)
|
||||
* Slider: 新增 button-size 属性 [1e9b8c](https://github.com/youzan/vant/commit/1e9b8c846674562d56ab638a0982baab4bb6870e)
|
||||
* 优化 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**
|
||||
|
||||
* CouponList: 优化样式细节 [#5501](https://github.com/youzan/vant/issues/5501)
|
||||
* AddressList: 优化样式细节 [#5507](https://github.com/youzan/vant/issues/5507)
|
||||
* Icon: 更新 share 图标 [2f77ac](https://github.com/youzan/vant/commit/2f77acfc6cef23ea664defc38c4cd806ceca1ee4)
|
||||
* Field: 优化 readonly 状态下的光标类型 [60173d](https://github.com/youzan/vant/commit/60173dd6bc004339333c50218d7c6b2f6c1bc07b)
|
||||
* Stepper: 优化 disable-input 状态下的输入框颜色 [959eca](https://github.com/youzan/vant/commit/959eca136c4ca6a39e22d36512db74b93ad100c6)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
* CouponList: 修复点击反馈区域错误的问题 [#5521](https://github.com/youzan/vant/issues/5521)
|
||||
* Tabs: 修复容器设置 fixed 布局时无法渲染底部条的问题 [#5496](https://github.com/youzan/vant/issues/5496)
|
||||
* Field: 修复 type 为 number 时在 iOS 上仍然能输入非数字字符的问题 [#5520](https://github.com/youzan/vant/issues/5520)
|
||||
* GoodsAction: 修复未设置容器高度的问题 [#5593](https://github.com/youzan/vant/issues/5593)
|
||||
|
||||
**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)
|
||||
`2020-01-06`
|
||||
### [v2.4.2](https://github.com/youzan/vant/compare/v2.4.2-beta.1...v2.4.2)
|
||||
`2020-01-14`
|
||||
|
||||
**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: 新增 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)
|
||||
* 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**
|
||||
|
||||
* Button: 修复加载状态下仍会有点击反馈的问题 [0a70d3](https://github.com/youzan/vant/commit/0a70d344124ef756a73ea9edfee07303f394d880)
|
||||
* 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)
|
||||
|
@ -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+.
|
||||
|
||||
### 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
|
||||
|
||||
* [Feedback](https://github.com/youzan/vant/issues)
|
||||
* [Changelog](#/en-US/changelog)
|
||||
* [Vant Demo](https://github.com/youzan/vant-demo)
|
||||
* [Vant Weapp](https://github.com/youzan/vant-weapp)
|
||||
|
||||
### LICENSE
|
||||
|
||||
|
@ -45,13 +45,21 @@
|
||||
- <a target="_blank" href="https://tech.youzan.com/tag/front-end/">团队博客</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)
|
||||
* [更新日志](#/zh-CN/changelog)
|
||||
* [码云镜像](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
|
||||
# 安装 Vue Cli
|
||||
@ -19,7 +19,9 @@ vue ui
|
||||
|
||||
在图形化界面中,点击`依赖` -> `安装依赖`,然后将 `vant` 添加到依赖中即可。
|
||||
|
||||
### 安装
|
||||
### 通过 npm 安装
|
||||
|
||||
在现有项目中使用 Vant 时,可以通过`npm`或`yarn`安装
|
||||
|
||||
```bash
|
||||
# 通过 npm 安装
|
||||
@ -189,3 +191,28 @@ iPhone X 等机型底部存在底部指示条,指示条的操作区域与页
|
||||
```
|
||||
|
||||
<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';
|
||||
|
||||
Vue.use(Lazyload, {
|
||||
lazyComponent: true
|
||||
lazyComponent: true,
|
||||
});
|
||||
|
||||
Locale.add({
|
||||
'en-US': enUS
|
||||
'en-US': enUS,
|
||||
});
|
||||
|
||||
// flag for vant-weapp demos
|
||||
const isWeapp = location.search.indexOf('weapp=1') !== -1;
|
||||
|
||||
let demoUid = 0;
|
||||
|
||||
// helper for demo locales
|
||||
Vue.mixin({
|
||||
computed: {
|
||||
@ -33,10 +35,14 @@ Vue.mixin({
|
||||
|
||||
isWeapp() {
|
||||
return isWeapp;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
beforeCreate() {
|
||||
if (!this.$options.name) {
|
||||
this.$options.name = `demo-${demoUid++}`;
|
||||
}
|
||||
|
||||
const { i18n, name } = this.$options;
|
||||
|
||||
if (i18n && name) {
|
||||
@ -49,7 +55,7 @@ Vue.mixin({
|
||||
|
||||
Locale.add(locales);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// switch lang after routing
|
||||
@ -91,7 +97,7 @@ Locale.add({
|
||||
advancedUsage: '高级用法',
|
||||
loadingStatus: '加载状态',
|
||||
usernamePlaceholder: '请输入用户名',
|
||||
passwordPlaceholder: '请输入密码'
|
||||
passwordPlaceholder: '请输入密码',
|
||||
},
|
||||
'en-US': {
|
||||
add: 'Add',
|
||||
@ -119,6 +125,6 @@ Locale.add({
|
||||
basicUsage: 'Basic Usage',
|
||||
advancedUsage: 'Advanced Usage',
|
||||
usernamePlaceholder: 'Username',
|
||||
passwordPlaceholder: 'Password'
|
||||
}
|
||||
passwordPlaceholder: 'Password',
|
||||
},
|
||||
});
|
||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vant",
|
||||
"version": "2.4.2-beta.2",
|
||||
"version": "2.4.7-beta.0",
|
||||
"description": "Mobile UI Components built on Vue",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -19,7 +19,6 @@
|
||||
"test": "vant-cli test",
|
||||
"build": "vant-cli build",
|
||||
"release": "vant-cli release",
|
||||
"changelog": "vant-cli changelog",
|
||||
"test:watch": "vant-cli test --watch",
|
||||
"release:site": "sh docs/site/release.sh",
|
||||
"test:coverage": "open test/coverage/index.html"
|
||||
@ -31,6 +30,10 @@
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js,vue,less}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
],
|
||||
"*.{ts,tsx,js,vue}": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
@ -52,7 +55,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@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-lazyload": "1.2.3"
|
||||
},
|
||||
@ -60,7 +63,7 @@
|
||||
"vue": ">= 2.5.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vant/cli": "^2.1.6",
|
||||
"@vant/cli": "^2.2.2",
|
||||
"vue": "^2.6.11",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
@ -86,7 +89,8 @@
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
},
|
||||
"browserslist": [
|
||||
"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 校验规则,提交代码时自动执行校验
|
||||
- 构建后的组件库默认支持按需引入、主题定制、Tree Shaking
|
||||
|
||||
### 安装
|
||||
### 快速上手
|
||||
|
||||
执行以下命令可以快速创建一个基于 Vant Cli 的项目:
|
||||
|
||||
```bash
|
||||
npx create-vant-cli-app
|
||||
```
|
||||
|
||||
### 手动安装
|
||||
|
||||
```shell
|
||||
# 通过 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]
|
||||
`2020-01-12`
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/cli",
|
||||
"version": "2.1.6",
|
||||
"version": "2.2.2",
|
||||
"description": "",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@ -23,6 +23,9 @@
|
||||
"template",
|
||||
"preset.js"
|
||||
],
|
||||
"keywords": [
|
||||
"vant"
|
||||
],
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
@ -30,78 +33,75 @@
|
||||
"vue-template-compiler": "^2.5.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/eslint": "^6.1.3",
|
||||
"@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/postcss-load-config": "^2.0.1",
|
||||
"@types/sass": "^1.16.0",
|
||||
"@types/shelljs": "^0.8.6",
|
||||
"@types/signale": "^1.2.1",
|
||||
"@types/source-map": "^0.5.7",
|
||||
"@types/stylelint": "^9.10.1",
|
||||
"@types/webpack": "^4.41.2",
|
||||
"@types/webpack-dev-server": "^3.9.0",
|
||||
"@types/webpack": "^4.41.4",
|
||||
"@types/webpack-dev-server": "^3.10.0",
|
||||
"@types/webpack-merge": "^4.1.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.7.7",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
|
||||
"@babel/plugin-syntax-jsx": "^7.7.4",
|
||||
"@babel/plugin-transform-object-assign": "^7.7.4",
|
||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||
"@babel/preset-env": "^7.7.7",
|
||||
"@babel/preset-typescript": "^7.7.7",
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/plugin-syntax-jsx": "^7.8.3",
|
||||
"@babel/plugin-transform-object-assign": "^7.8.3",
|
||||
"@babel/plugin-transform-runtime": "^7.8.3",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"@babel/preset-typescript": "^7.8.3",
|
||||
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
|
||||
"@types/jest": "^24.0.25",
|
||||
"@vant/eslint-config": "^1.5.1",
|
||||
"@types/jest": "^25.1.1",
|
||||
"@vant/eslint-config": "^2.0.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/touch-emulator": "^1.2.0",
|
||||
"@vue/babel-preset-jsx": "^1.1.2",
|
||||
"@vue/component-compiler-utils": "^3.1.1",
|
||||
"@vue/test-utils": "1.0.0-beta.29",
|
||||
"autoprefixer": "^9.7.3",
|
||||
"babel-jest": "^24.9.0",
|
||||
"address": "^1.1.2",
|
||||
"autoprefixer": "^9.7.4",
|
||||
"babel-jest": "^25.1.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-import": "^1.13.0",
|
||||
"cache-loader": "^4.1.0",
|
||||
"chokidar": "^3.3.1",
|
||||
"clean-css": "^4.2.1",
|
||||
"codecov": "^3.6.1",
|
||||
"commander": "^4.1.0",
|
||||
"clean-css": "^4.2.3",
|
||||
"codecov": "^3.6.4",
|
||||
"commander": "^4.1.1",
|
||||
"consola": "^2.11.3",
|
||||
"conventional-changelog": "^3.1.18",
|
||||
"cross-env": "^6.0.3",
|
||||
"css-loader": "^3.4.1",
|
||||
"cross-env": "^7.0.0",
|
||||
"css-loader": "^3.4.2",
|
||||
"eslint": "^6.8.0",
|
||||
"fast-glob": "^3.1.1",
|
||||
"gh-pages": "2.0.1",
|
||||
"html-webpack-plugin": "3.2.0",
|
||||
"husky": "^4.0.4",
|
||||
"jest": "^24.9.0",
|
||||
"husky": "^4.2.1",
|
||||
"jest": "^25.1.0",
|
||||
"jest-canvas-mock": "^2.2.0",
|
||||
"jest-serializer-vue": "^2.0.2",
|
||||
"less": "^3.10.3",
|
||||
"less-loader": "^5.0.0",
|
||||
"lint-staged": "^9.5.0",
|
||||
"lint-staged": "^10.0.7",
|
||||
"lodash": "^4.17.15",
|
||||
"ora": "^4.0.3",
|
||||
"portfinder": "^1.0.25",
|
||||
"postcss": "^7.0.26",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"release-it": "^12.4.3",
|
||||
"sass": "^1.24.4",
|
||||
"sass-loader": "^8.0.0",
|
||||
"sass": "^1.25.0",
|
||||
"sass-loader": "^8.0.2",
|
||||
"shelljs": "^0.8.3",
|
||||
"signale": "^1.4.0",
|
||||
"style-loader": "^1.1.2",
|
||||
"stylelint": "^12.0.1",
|
||||
"typescript": "^3.7.4",
|
||||
"style-loader": "^1.1.3",
|
||||
"stylelint": "^13.0.0",
|
||||
"typescript": "^3.7.5",
|
||||
"vue-jest": "4.0.0-beta.2",
|
||||
"vue-loader": "^15.8.3",
|
||||
"vue-router": "^3.1.3",
|
||||
"vue-router": "^3.1.5",
|
||||
"webpack": "^4.41.5",
|
||||
"webpack-dev-server": "3.10.1",
|
||||
"webpack-dev-server": "3.10.2",
|
||||
"webpack-merge": "^4.2.2",
|
||||
"webpackbar": "^4.0.0"
|
||||
},
|
||||
@ -120,13 +120,5 @@
|
||||
"global-require": 0,
|
||||
"import/no-dynamic-require": 0
|
||||
}
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": [
|
||||
"@vant/stylelint-config"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import { iframeReady, isMobile } from '.';
|
||||
|
||||
window.syncPath = function () {
|
||||
window.syncPath = function() {
|
||||
const router = window.vueRouter;
|
||||
const isInIframe = window !== window.top;
|
||||
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
|
||||
if (window.vueRouter.currentRoute.path !== path) {
|
||||
window.vueRouter.replace(path).catch(() => {});
|
||||
|
@ -27,7 +27,4 @@ export function decamelize(str, sep = '-') {
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
export {
|
||||
isMobile,
|
||||
iframeReady
|
||||
};
|
||||
export { isMobile, iframeReady };
|
||||
|
@ -7,11 +7,12 @@ code {
|
||||
overflow-x: auto;
|
||||
color: @van-doc-code-color;
|
||||
font-weight: 400;
|
||||
font-size: 13px;
|
||||
font-size: 13.4px;
|
||||
font-family: @van-doc-code-font-family;
|
||||
line-height: 26px;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
-webkit-font-smoothing: auto;
|
||||
}
|
||||
|
||||
pre {
|
||||
@ -35,7 +36,7 @@ pre {
|
||||
.hljs-template-tag,
|
||||
.hljs-template-variable,
|
||||
.hljs-addition {
|
||||
color: @van-doc-purple;
|
||||
color: @van-doc-green;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
@ -43,21 +44,23 @@ pre {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.hljs-params,
|
||||
.hljs-keyword,
|
||||
.hljs-attribute {
|
||||
color: @van-doc-purple;
|
||||
}
|
||||
|
||||
.hljs-deletion,
|
||||
.hljs-variable,
|
||||
.hljs-number,
|
||||
.hljs-regexp,
|
||||
.hljs-literal,
|
||||
.hljs-bullet,
|
||||
.hljs-link {
|
||||
color: #07c160;
|
||||
}
|
||||
|
||||
.hljs-deletion,
|
||||
.hljs-variable {
|
||||
color: #88f;
|
||||
color: #eb6f6f;
|
||||
}
|
||||
|
||||
.hljs-attr,
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
@ -68,13 +71,9 @@ pre {
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-class,
|
||||
.hljs-strong {
|
||||
color: @van-doc-blue;
|
||||
color: #4994df;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-attribute {
|
||||
color: #e6550d;
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
@van-doc-black: #323233;
|
||||
@van-doc-blue: #1989fa;
|
||||
@van-doc-purple: #5758bb;
|
||||
@van-doc-purple: #8080ff;
|
||||
@van-doc-fuchsia: #a7419e;
|
||||
@van-doc-green: #4fc08d;
|
||||
@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-grey: #999;
|
||||
@van-doc-dark-grey: #666;
|
||||
@van-doc-light-grey: #ccc;
|
||||
@van-doc-border-color: #f1f4f8;
|
||||
@van-doc-code-color: #455a64;
|
||||
@van-doc-code-color: #58727e;
|
||||
@van-doc-code-background-color: #f1f4f8;
|
||||
@van-doc-code-font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
|
||||
@van-doc-padding: 30px;
|
||||
|
@ -19,7 +19,7 @@ import { setLang } from '../common/locales';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
VanDoc
|
||||
VanDoc,
|
||||
},
|
||||
|
||||
data() {
|
||||
@ -27,7 +27,7 @@ export default {
|
||||
|
||||
return {
|
||||
packageVersion,
|
||||
simulator: `${path}mobile.html${location.hash}`
|
||||
simulator: `${path}mobile.html${location.hash}`,
|
||||
};
|
||||
},
|
||||
|
||||
@ -41,7 +41,7 @@ export default {
|
||||
const { locales = {} } = config.site;
|
||||
return Object.keys(locales).map(key => ({
|
||||
lang: key,
|
||||
label: locales[key].langLabel || ''
|
||||
label: locales[key].langLabel || '',
|
||||
}));
|
||||
},
|
||||
|
||||
@ -61,14 +61,14 @@ export default {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
lang(val) {
|
||||
setLang(val);
|
||||
this.setTitle();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
@ -84,8 +84,8 @@ export default {
|
||||
}
|
||||
|
||||
document.title = title;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -12,8 +12,8 @@ export default {
|
||||
name: 'van-doc-container',
|
||||
|
||||
props: {
|
||||
hasSimulator: Boolean
|
||||
}
|
||||
hasSimulator: Boolean,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -15,8 +15,8 @@ export default {
|
||||
return path.split('/').slice(-1)[0];
|
||||
}
|
||||
return this.$route.name;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -37,7 +37,8 @@ export default {
|
||||
}
|
||||
|
||||
a {
|
||||
color: @van-doc-blue;
|
||||
color: @van-doc-green;
|
||||
-webkit-font-smoothing: auto;
|
||||
}
|
||||
|
||||
h1,
|
||||
@ -67,9 +68,9 @@ export default {
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 16px;
|
||||
font-weight: 500;
|
||||
font-size: 17px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
@ -119,6 +120,7 @@ export default {
|
||||
&:first-child {
|
||||
padding-left: 0;
|
||||
|
||||
// version tag
|
||||
code {
|
||||
margin: 0;
|
||||
padding: 2px 6px;
|
||||
@ -135,18 +137,12 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 0 8px;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
word-break: keep-all;
|
||||
}
|
||||
|
||||
em {
|
||||
color: @van-doc-fuchsia;
|
||||
font-size: 12px;
|
||||
color: @van-doc-green;
|
||||
font-size: 12.5px;
|
||||
font-family: @van-doc-code-font-family;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,8 +181,16 @@ export default {
|
||||
display: inline;
|
||||
margin: 2px 3px;
|
||||
padding: 2px 5px;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
word-break: keep-all;
|
||||
background-color: #f0f2f5;
|
||||
border-radius: 4px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
p > code {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
section {
|
||||
|
@ -3,21 +3,36 @@
|
||||
<div class="van-doc-row">
|
||||
<div class="van-doc-header__top">
|
||||
<a class="van-doc-header__logo">
|
||||
<img :src="config.logo">
|
||||
<img :src="config.logo" />
|
||||
<span>{{ config.title }}</span>
|
||||
</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">
|
||||
<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">
|
||||
<img :src="item.logo">
|
||||
<a
|
||||
class="van-doc-header__logo-link"
|
||||
target="_blank"
|
||||
:href="item.url"
|
||||
>
|
||||
<img :src="item.logo" />
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li ref="version" v-if="versions" class="van-doc-header__top-nav-item">
|
||||
<span class="van-doc-header__cube van-doc-header__version" @click="toggleVersionPop">
|
||||
<li
|
||||
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 }}
|
||||
<transition name="van-doc-dropdown">
|
||||
<div v-if="showVersionPop" class="van-doc-header__version-pop">
|
||||
@ -49,19 +64,19 @@ export default {
|
||||
name: 'van-doc-header',
|
||||
|
||||
components: {
|
||||
SearchInput
|
||||
SearchInput,
|
||||
},
|
||||
|
||||
props: {
|
||||
lang: String,
|
||||
config: Object,
|
||||
versions: Array,
|
||||
langConfigs: Array
|
||||
langConfigs: Array,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
showVersionPop: false
|
||||
showVersionPop: false,
|
||||
};
|
||||
},
|
||||
|
||||
@ -85,7 +100,7 @@ export default {
|
||||
|
||||
searchConfig() {
|
||||
return this.config.searchConfig;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
@ -93,7 +108,10 @@ export default {
|
||||
const val = !this.showVersionPop;
|
||||
|
||||
const action = val ? 'add' : 'remove';
|
||||
document.body[`${action}EventListener`]('click', this.checkHideVersionPop);
|
||||
document.body[`${action}EventListener`](
|
||||
'click',
|
||||
this.checkHideVersionPop
|
||||
);
|
||||
|
||||
this.showVersionPop = val;
|
||||
},
|
||||
@ -109,9 +127,11 @@ export default {
|
||||
},
|
||||
|
||||
onSwitchVersion(version) {
|
||||
location.href = version.link;
|
||||
}
|
||||
}
|
||||
if (version.link) {
|
||||
location.href = version.link;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -120,7 +140,6 @@ export default {
|
||||
|
||||
.van-doc-header {
|
||||
width: 100%;
|
||||
box-shadow: 0 4px 12px #ebedf0;
|
||||
user-select: none;
|
||||
|
||||
&__top {
|
||||
|
@ -28,18 +28,18 @@ export default {
|
||||
name: 'van-doc-nav',
|
||||
|
||||
components: {
|
||||
[NavLink.name]: NavLink
|
||||
[NavLink.name]: NavLink,
|
||||
},
|
||||
|
||||
props: {
|
||||
lang: String,
|
||||
navConfig: Array
|
||||
navConfig: Array,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
top: 60,
|
||||
bottom: 0
|
||||
bottom: 0,
|
||||
};
|
||||
},
|
||||
|
||||
@ -47,13 +47,13 @@ export default {
|
||||
style() {
|
||||
return {
|
||||
top: this.top + 'px',
|
||||
bottom: this.bottom + 'px'
|
||||
bottom: this.bottom + 'px',
|
||||
};
|
||||
},
|
||||
|
||||
base() {
|
||||
return this.lang ? `/${this.lang}/` : '/';
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
@ -65,8 +65,8 @@ export default {
|
||||
onScroll() {
|
||||
const { pageYOffset: offset } = window;
|
||||
this.top = Math.max(0, 60 - offset);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -126,16 +126,15 @@ export default {
|
||||
color: #455a64;
|
||||
font-size: 14px;
|
||||
line-height: 28px;
|
||||
transition: all 0.3s;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #000;
|
||||
&:hover,
|
||||
&.active {
|
||||
color: @van-doc-green;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: #000;
|
||||
font-weight: 500;
|
||||
font-size: 15px;
|
||||
-webkit-font-smoothing: auto;
|
||||
}
|
||||
|
||||
span {
|
||||
|
@ -1,7 +1,12 @@
|
||||
<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 v-html="itemName " />
|
||||
<a v-else v-html="itemName" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -10,7 +15,7 @@ export default {
|
||||
|
||||
props: {
|
||||
base: String,
|
||||
item: Object
|
||||
item: Object,
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -33,13 +38,13 @@ export default {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
active() {
|
||||
this.scrollIntoView();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -51,7 +56,7 @@ export default {
|
||||
if (this.active && this.$el && this.$el.scrollIntoViewIfNeeded) {
|
||||
this.$el.scrollIntoViewIfNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<input class="van-doc-search" :placeholder="placeholder">
|
||||
<input class="van-doc-search" :placeholder="placeholder" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -8,13 +8,13 @@ export default {
|
||||
|
||||
props: {
|
||||
lang: String,
|
||||
searchConfig: Object
|
||||
searchConfig: Object,
|
||||
},
|
||||
|
||||
computed: {
|
||||
placeholder() {
|
||||
return this.searchConfig.placeholder || 'Search...';
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
@ -22,7 +22,7 @@ export default {
|
||||
if (this.docsearchInstance) {
|
||||
this.docsearchInstance.algoliaOptions.facetFilters = [`lang:${lang}`];
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -31,11 +31,11 @@ export default {
|
||||
...this.searchConfig,
|
||||
inputSelector: '.van-doc-search',
|
||||
algoliaOptions: {
|
||||
facetFilters: [`lang:${this.lang}`]
|
||||
}
|
||||
facetFilters: [`lang:${this.lang}`],
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -9,13 +9,13 @@ export default {
|
||||
name: 'van-doc-simulator',
|
||||
|
||||
props: {
|
||||
src: String
|
||||
src: String,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
scrollTop: window.scrollY,
|
||||
windowHeight: window.innerHeight
|
||||
windowHeight: window.innerHeight,
|
||||
};
|
||||
},
|
||||
|
||||
@ -27,9 +27,9 @@ export default {
|
||||
simulatorStyle() {
|
||||
const height = Math.min(640, this.windowHeight - 90);
|
||||
return {
|
||||
height: height + 'px'
|
||||
height: height + 'px',
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -39,7 +39,7 @@ export default {
|
||||
window.addEventListener('resize', () => {
|
||||
this.windowHeight = window.innerHeight;
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
@switch-version="$emit('switch-version', $event)"
|
||||
/>
|
||||
<doc-nav :lang="lang" :nav-config="config.nav" />
|
||||
<doc-container :has-simulator="!!simulator ">
|
||||
<doc-container :has-simulator="!!simulator">
|
||||
<doc-content>
|
||||
<slot />
|
||||
</doc-content>
|
||||
@ -32,7 +32,7 @@ export default {
|
||||
DocHeader,
|
||||
DocContent,
|
||||
DocContainer,
|
||||
DocSimulator
|
||||
DocSimulator,
|
||||
},
|
||||
|
||||
props: {
|
||||
@ -42,19 +42,19 @@ export default {
|
||||
langConfigs: Array,
|
||||
config: {
|
||||
type: Object,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
base: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
// eslint-disable-next-line
|
||||
'$route.path'() {
|
||||
this.setNav();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
@ -98,8 +98,8 @@ export default {
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -1,29 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" />
|
||||
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.logo %>" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover">
|
||||
<meta http-Equiv="Cache-Control" Content="no-cache" />
|
||||
<meta http-Equiv="Pragma" Content="no-cache" />
|
||||
<meta http-Equiv="Expires" Content="0" />
|
||||
<link href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" rel="stylesheet" />
|
||||
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
||||
<script>
|
||||
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>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<meta
|
||||
name="description"
|
||||
content="<%= htmlWebpackPlugin.options.description %>"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
href="<%= htmlWebpackPlugin.options.logo %>"
|
||||
/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
|
||||
/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
||||
<script>
|
||||
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>
|
||||
|
@ -15,5 +15,5 @@ new Vue({
|
||||
}
|
||||
},
|
||||
render: h => h(App),
|
||||
router
|
||||
router,
|
||||
});
|
||||
|
@ -20,13 +20,13 @@ function parseName(name) {
|
||||
|
||||
return {
|
||||
component: `${decamelize(component)}`,
|
||||
lang: pairs.join('-')
|
||||
lang: pairs.join('-'),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
component: `${decamelize(name)}`,
|
||||
lang: ''
|
||||
lang: '',
|
||||
};
|
||||
}
|
||||
|
||||
@ -48,12 +48,12 @@ function getRoutes() {
|
||||
if (locales) {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: route => `/${getLangFromRoute(route)}/`
|
||||
redirect: route => `/${getLangFromRoute(route)}/`,
|
||||
});
|
||||
} else {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: '/'
|
||||
redirect: '/',
|
||||
});
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ function getRoutes() {
|
||||
name: lang,
|
||||
path: `/${lang || ''}`,
|
||||
component: Home,
|
||||
meta: { lang }
|
||||
meta: { lang },
|
||||
});
|
||||
}
|
||||
|
||||
@ -80,8 +80,8 @@ function getRoutes() {
|
||||
component: documents[name],
|
||||
meta: {
|
||||
lang,
|
||||
name: component
|
||||
}
|
||||
name: component,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
routes.push({
|
||||
@ -89,8 +89,8 @@ function getRoutes() {
|
||||
path: `/${component}`,
|
||||
component: documents[name],
|
||||
meta: {
|
||||
name: component
|
||||
}
|
||||
name: component,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -109,7 +109,7 @@ export const router = new VueRouter({
|
||||
}
|
||||
|
||||
return { x: 0, y: 0 };
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
|
@ -5,7 +5,7 @@ export function scrollToAnchor(selector) {
|
||||
const el = document.querySelector(selector);
|
||||
if (el) {
|
||||
el.scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
behavior: 'smooth',
|
||||
});
|
||||
clearInterval(timer);
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@
|
||||
import DemoNav from './components/DemoNav';
|
||||
|
||||
export default {
|
||||
components: { DemoNav }
|
||||
components: { DemoNav },
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -10,8 +10,8 @@ export default {
|
||||
name: 'demo-block',
|
||||
|
||||
props: {
|
||||
title: String
|
||||
}
|
||||
title: String,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -4,16 +4,14 @@
|
||||
class="demo-home__title"
|
||||
:class="{ 'demo-home__title--small': smallTitle }"
|
||||
>
|
||||
<img :src="config.logo">
|
||||
<img :src="config.logo" />
|
||||
<span>{{ config.title }}</span>
|
||||
</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">
|
||||
<demo-home-nav
|
||||
:group="group"
|
||||
:lang="lang"
|
||||
:key="index"
|
||||
/>
|
||||
<demo-home-nav :group="group" :lang="lang" :key="index" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@ -24,7 +22,7 @@ import DemoHomeNav from './DemoHomeNav';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DemoHomeNav
|
||||
DemoHomeNav,
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -45,8 +43,8 @@ export default {
|
||||
|
||||
smallTitle() {
|
||||
return this.config.title.length >= 8;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -20,25 +20,25 @@ import ArrowRight from './ArrowRight';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ArrowRight
|
||||
ArrowRight,
|
||||
},
|
||||
|
||||
props: {
|
||||
lang: String,
|
||||
group: Object
|
||||
group: Object,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: []
|
||||
active: [],
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
base() {
|
||||
return this.lang ? `/${this.lang}` : '';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -13,7 +13,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
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() {
|
||||
const { name } = this.$route.meta || {};
|
||||
return name ? name.replace(/-/g, '') : '';
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
onBack() {
|
||||
history.back();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -18,8 +18,8 @@ export default {
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -1,30 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" />
|
||||
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.logo %>" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover">
|
||||
<meta http-Equiv="Cache-Control" Content="no-cache" />
|
||||
<meta http-Equiv="Pragma" Content="no-cache" />
|
||||
<meta http-Equiv="Expires" Content="0" />
|
||||
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
||||
<script>
|
||||
// avoid to load analytics in iframe
|
||||
if (window.top === window) {
|
||||
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>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<meta
|
||||
name="description"
|
||||
content="<%= htmlWebpackPlugin.options.description %>"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
href="<%= htmlWebpackPlugin.options.logo %>"
|
||||
/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
|
||||
/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
|
||||
<script>
|
||||
// avoid to load analytics in iframe
|
||||
if (window.top === window) {
|
||||
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>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -16,6 +16,6 @@ setTimeout(() => {
|
||||
new Vue({
|
||||
el: '#app',
|
||||
render: h => h(App),
|
||||
router
|
||||
router,
|
||||
});
|
||||
}, 0);
|
||||
|
@ -29,25 +29,25 @@ function getRoutes() {
|
||||
if (langs.length) {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: route => `/${getLangFromRoute(route)}/`
|
||||
redirect: route => `/${getLangFromRoute(route)}/`,
|
||||
});
|
||||
|
||||
langs.forEach(lang => {
|
||||
routes.push({
|
||||
path: `/${lang}`,
|
||||
component: DemoHome,
|
||||
meta: { lang }
|
||||
meta: { lang },
|
||||
});
|
||||
});
|
||||
} else {
|
||||
routes.push({
|
||||
path: '*',
|
||||
redirect: () => '/'
|
||||
redirect: () => '/',
|
||||
});
|
||||
|
||||
routes.push({
|
||||
path: '/',
|
||||
component: DemoHome
|
||||
component: DemoHome,
|
||||
});
|
||||
}
|
||||
|
||||
@ -62,8 +62,8 @@ function getRoutes() {
|
||||
component: demos[name],
|
||||
meta: {
|
||||
name,
|
||||
lang
|
||||
}
|
||||
lang,
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@ -72,8 +72,8 @@ function getRoutes() {
|
||||
path: `/${component}`,
|
||||
component: demos[name],
|
||||
meta: {
|
||||
name
|
||||
}
|
||||
name,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -86,7 +86,7 @@ Vue.use(VueRouter);
|
||||
export const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
routes: getRoutes(),
|
||||
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 }
|
||||
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 },
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
|
@ -1,11 +1,10 @@
|
||||
// @ts-ignore
|
||||
import execa from 'execa';
|
||||
import chokidar from 'chokidar';
|
||||
import { join, relative } from 'path';
|
||||
import { remove, copy, readdirSync } from 'fs-extra';
|
||||
import { clean } from './clean';
|
||||
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 { compileSfc } from '../compiler/compile-sfc';
|
||||
import { compileStyle } from '../compiler/compile-style';
|
||||
@ -23,13 +22,10 @@ import {
|
||||
isScript,
|
||||
isDemoDir,
|
||||
isTestDir,
|
||||
hasYarn,
|
||||
setNodeEnv,
|
||||
setModuleEnv
|
||||
setModuleEnv,
|
||||
} from '../common';
|
||||
|
||||
const stepper = getStepper(12);
|
||||
|
||||
async function compileFile(filePath: string) {
|
||||
if (isSfc(filePath)) {
|
||||
return compileSfc(filePath);
|
||||
@ -66,126 +62,108 @@ async function compileDir(dir: string) {
|
||||
);
|
||||
}
|
||||
|
||||
async function installDependencies() {
|
||||
stepper.start('Install Dependencies');
|
||||
|
||||
try {
|
||||
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 buildEs() {
|
||||
setModuleEnv('esmodule');
|
||||
await copy(SRC_DIR, ES_DIR);
|
||||
await compileDir(ES_DIR);
|
||||
}
|
||||
|
||||
async function buildESModuleOutputs() {
|
||||
stepper.start('Build ESModule Outputs');
|
||||
|
||||
try {
|
||||
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 buildLib() {
|
||||
setModuleEnv('commonjs');
|
||||
await copy(SRC_DIR, LIB_DIR);
|
||||
await compileDir(LIB_DIR);
|
||||
}
|
||||
|
||||
async function buildStyleEntry() {
|
||||
stepper.start('Build Style Entry');
|
||||
|
||||
try {
|
||||
await genStyleDepsMap();
|
||||
genComponentStyle();
|
||||
stepper.success('Build Style Entry');
|
||||
} catch (err) {
|
||||
stepper.error('Build Style Entry', err);
|
||||
throw err;
|
||||
}
|
||||
await genStyleDepsMap();
|
||||
genComponentStyle();
|
||||
}
|
||||
|
||||
async function buildPackedOutputs() {
|
||||
stepper.start('Build Packed Outputs');
|
||||
async function buildPacakgeEntry() {
|
||||
const esEntryFile = join(ES_DIR, 'index.js');
|
||||
const libEntryFile = join(LIB_DIR, 'index.js');
|
||||
const styleEntryFile = join(LIB_DIR, `index.${CSS_LANG}`);
|
||||
|
||||
try {
|
||||
setModuleEnv('esmodule');
|
||||
await compilePackage(false);
|
||||
await compilePackage(true);
|
||||
genVeturConfig();
|
||||
stepper.success('Build Packed Outputs');
|
||||
} catch (err) {
|
||||
stepper.error('Build Packed Outputs', err);
|
||||
throw err;
|
||||
}
|
||||
genPackageEntry({
|
||||
outputPath: esEntryFile,
|
||||
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`,
|
||||
});
|
||||
|
||||
setModuleEnv('esmodule');
|
||||
await compileJs(esEntryFile);
|
||||
|
||||
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() {
|
||||
stepper.start('Build Package Entry');
|
||||
async function buildPackages() {
|
||||
setModuleEnv('esmodule');
|
||||
await compilePackage(false);
|
||||
await compilePackage(true);
|
||||
genVeturConfig();
|
||||
}
|
||||
|
||||
try {
|
||||
const esEntryFile = join(ES_DIR, 'index.js');
|
||||
const libEntryFile = join(LIB_DIR, 'index.js');
|
||||
const styleEntryFile = join(LIB_DIR, `index.${CSS_LANG}`);
|
||||
const tasks = [
|
||||
{
|
||||
text: 'Build ESModule Outputs',
|
||||
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({
|
||||
outputPath: esEntryFile,
|
||||
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`
|
||||
});
|
||||
async function runBuildTasks() {
|
||||
for (let i = 0; i < tasks.length; i++) {
|
||||
const { task, text } = tasks[i];
|
||||
const spinner = ora(text).start();
|
||||
|
||||
setModuleEnv('esmodule');
|
||||
await compileJs(esEntryFile);
|
||||
|
||||
genPacakgeStyle({
|
||||
outputPath: styleEntryFile,
|
||||
pathResolver: (path: string) => path.replace(SRC_DIR, '.')
|
||||
});
|
||||
|
||||
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;
|
||||
try {
|
||||
/* eslint-disable no-await-in-loop */
|
||||
await task();
|
||||
spinner.succeed(text);
|
||||
} catch (err) {
|
||||
spinner.fail(text);
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
consola.success('Compile successfully');
|
||||
}
|
||||
|
||||
function watchFileChange() {
|
||||
logger.watch('Compiled successfully, watching file changes...');
|
||||
consola.info('\nWatching file changes...');
|
||||
|
||||
chokidar.watch(SRC_DIR).on('change', async path => {
|
||||
if (isDemoDir(path) || isTestDir(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const logger = getInteractiveLogger();
|
||||
const spinner = ora('File changed, start compilation...').start();
|
||||
const esPath = path.replace(SRC_DIR, ES_DIR);
|
||||
const libPath = path.replace(SRC_DIR, LIB_DIR);
|
||||
|
||||
logger.pending('File change detected, start compilation...');
|
||||
|
||||
try {
|
||||
await copy(path, esPath);
|
||||
await copy(path, libPath);
|
||||
@ -193,9 +171,9 @@ function watchFileChange() {
|
||||
await compileFile(libPath);
|
||||
await genStyleDepsMap();
|
||||
genComponentStyle({ cache: false });
|
||||
logger.success('Compiled: ' + path);
|
||||
spinner.succeed('Compiled: ' + slimPath(path));
|
||||
} catch (err) {
|
||||
logger.error('Compile failed: ' + path);
|
||||
spinner.fail('Compile failed: ' + path);
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
@ -207,17 +185,13 @@ export async function build(cmd: { watch?: boolean } = {}) {
|
||||
try {
|
||||
await clean();
|
||||
await installDependencies();
|
||||
await buildESModuleOutputs();
|
||||
await buildCommonjsOutputs();
|
||||
await buildStyleEntry();
|
||||
await buildPackageEntry();
|
||||
await buildPackedOutputs();
|
||||
await runBuildTasks();
|
||||
|
||||
if (cmd.watch) {
|
||||
watchFileChange();
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('Build failed');
|
||||
consola.error('Build failed');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { join } from 'path';
|
||||
import { ROOT } from '../common/constant';
|
||||
import { logger } from '../common/logger';
|
||||
import { ora, slimPath } from '../common/logger';
|
||||
import { createWriteStream, readFileSync } from 'fs-extra';
|
||||
// @ts-ignore
|
||||
import conventionalChangelog from 'conventional-changelog';
|
||||
@ -19,7 +19,7 @@ function formatType(type: string) {
|
||||
fix: 'Bug Fixes',
|
||||
feat: 'Feature',
|
||||
docs: 'Document',
|
||||
types: 'Types'
|
||||
types: 'Types',
|
||||
};
|
||||
|
||||
return MAP[type] || type;
|
||||
@ -46,13 +46,13 @@ function transform(item: any) {
|
||||
return item;
|
||||
}
|
||||
|
||||
export async function changelog() {
|
||||
logger.start('Generating changelog...');
|
||||
export async function changelog(): Promise<void> {
|
||||
const spinner = ora('Generating changelog...').start();
|
||||
|
||||
return new Promise(resolve => {
|
||||
conventionalChangelog(
|
||||
{
|
||||
preset: 'angular'
|
||||
preset: 'angular',
|
||||
},
|
||||
null,
|
||||
null,
|
||||
@ -61,12 +61,12 @@ export async function changelog() {
|
||||
mainTemplate,
|
||||
headerPartial,
|
||||
commitPartial,
|
||||
transform
|
||||
transform,
|
||||
}
|
||||
)
|
||||
.pipe(createWriteStream(DIST_FILE))
|
||||
.on('close', () => {
|
||||
logger.success(`Generated changelog at ${DIST_FILE}`);
|
||||
spinner.succeed(`Changelog generated at ${slimPath(DIST_FILE)}`);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -6,6 +6,6 @@ export async function clean() {
|
||||
emptyDir(ES_DIR),
|
||||
emptyDir(LIB_DIR),
|
||||
emptyDir(DIST_DIR),
|
||||
emptyDir(SITE_DIST_DIR)
|
||||
emptyDir(SITE_DIST_DIR),
|
||||
]);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 mergeRE = /Merge branch /;
|
||||
@ -9,7 +9,7 @@ export function commitLint() {
|
||||
const commitMsg = readFileSync(gitParams, 'utf-8').trim();
|
||||
|
||||
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.
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
import { emptyDir } from 'fs-extra';
|
||||
import { setNodeEnv } from '../common';
|
||||
import { compileSite } from '../compiler/compile-site';
|
||||
import { DIST_DIR } from '../common/constant';
|
||||
|
||||
export async function dev() {
|
||||
setNodeEnv('development');
|
||||
await emptyDir(DIST_DIR);
|
||||
await compileSite();
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ export function test(command: any) {
|
||||
setNodeEnv('test');
|
||||
|
||||
genPackageEntry({
|
||||
outputPath: PACKAGE_ENTRY_FILE
|
||||
outputPath: PACKAGE_ENTRY_FILE,
|
||||
});
|
||||
|
||||
const config = {
|
||||
rootDir: ROOT,
|
||||
watch: command.watch,
|
||||
config: JEST_CONFIG_FILE,
|
||||
clearCache: command.clearCache
|
||||
clearCache: command.clearCache,
|
||||
} as any;
|
||||
|
||||
runCLI(config, [ROOT])
|
||||
|
@ -1,57 +1,66 @@
|
||||
import { lint as stylelint } from 'stylelint';
|
||||
import { CLIEngine } from 'eslint';
|
||||
import { getStepper } from '../common/logger';
|
||||
// @ts-ignore
|
||||
import execa from 'execa';
|
||||
import { ora } from '../common/logger';
|
||||
import { SCRIPT_EXTS } from '../common/constant';
|
||||
|
||||
const stepper = getStepper(4);
|
||||
type RunCommandMessages = {
|
||||
start: string;
|
||||
succeed: string;
|
||||
failed: string;
|
||||
};
|
||||
|
||||
function lintScript() {
|
||||
stepper.start('ESLint Start');
|
||||
function runCommand(
|
||||
cmd: string,
|
||||
options: string[],
|
||||
messages: RunCommandMessages
|
||||
) {
|
||||
const spinner = ora(messages.start).start();
|
||||
|
||||
const cli = new CLIEngine({
|
||||
fix: true,
|
||||
extensions: SCRIPT_EXTS
|
||||
return new Promise(resolve => {
|
||||
execa(cmd, options, {
|
||||
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> {
|
||||
stepper.start('Stylelint Start');
|
||||
|
||||
return stylelint({
|
||||
fix: true,
|
||||
formatter: 'string',
|
||||
files: ['src/**/*.css', 'src/**/*.less', 'src/**/*.scss', 'src/**/*.vue']
|
||||
}).then(result => {
|
||||
if (result.errored) {
|
||||
stepper.error('Stylelint Failed', '\n' + result.output);
|
||||
return false;
|
||||
function eslint() {
|
||||
return runCommand(
|
||||
'eslint',
|
||||
['./src', '--fix', '--ext', SCRIPT_EXTS.join(',')],
|
||||
{
|
||||
start: 'Running eslint...',
|
||||
succeed: 'ESLint Passed.',
|
||||
failed: 'ESLint failed!',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
stepper.success('Stylelint Passed');
|
||||
return true;
|
||||
});
|
||||
function stylelint() {
|
||||
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() {
|
||||
const scriptPassed = lintScript();
|
||||
const stylePassed = await lintStyle();
|
||||
const eslintPassed = await eslint();
|
||||
const stylelintPassed = await stylelint();
|
||||
|
||||
if (!scriptPassed || !stylePassed) {
|
||||
if (!eslintPassed || !stylelintPassed) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
|
||||
export async function release() {
|
||||
await releaseIt({
|
||||
plugins: {
|
||||
[PLUGIN_PATH]: {}
|
||||
[PLUGIN_PATH]: {},
|
||||
},
|
||||
git: {
|
||||
tagName: 'v${version}',
|
||||
commitMessage: 'chore: release ${version}'
|
||||
}
|
||||
commitMessage: 'chore: release ${version}',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ function findRootDir(dir: string): string {
|
||||
return findRootDir(dirname(dir));
|
||||
}
|
||||
|
||||
// Colors
|
||||
export const GREEN = '#07c160';
|
||||
|
||||
// Root paths
|
||||
export const CWD = process.cwd();
|
||||
export const ROOT = findRootDir(CWD);
|
||||
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 ROOT_WEBPACK_CONFIG_FILE = join(ROOT, 'webpack.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');
|
||||
|
||||
// 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_STYLE_FILE = join(DIST_DIR, 'package-style.css');
|
||||
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');
|
||||
|
||||
// Config files
|
||||
export const BABEL_CONFIG_FILE = join(CONFIG_DIR, 'babel.config.js');
|
||||
export const POSTCSS_CONFIG_FILE = join(CONFIG_DIR, 'postcss.config.js');
|
||||
export const JEST_SETUP_FILE = join(CONFIG_DIR, 'jest.setup.js');
|
||||
@ -55,7 +65,11 @@ export function getPackageJson() {
|
||||
export function getVantConfig() {
|
||||
delete require.cache[VANT_CONFIG_FILE];
|
||||
|
||||
return require(VANT_CONFIG_FILE);
|
||||
try {
|
||||
return require(VANT_CONFIG_FILE);
|
||||
} catch (err) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function getSrcDir() {
|
||||
|
@ -1,17 +1,16 @@
|
||||
import { join } from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import {
|
||||
lstatSync,
|
||||
existsSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
outputFileSync
|
||||
outputFileSync,
|
||||
} from 'fs-extra';
|
||||
import {
|
||||
SRC_DIR,
|
||||
getVantConfig,
|
||||
ROOT_WEBPACK_CONFIG_FILE,
|
||||
ROOT_POSTCSS_CONFIG_FILE
|
||||
ROOT_POSTCSS_CONFIG_FILE,
|
||||
} from './constant';
|
||||
|
||||
export const EXT_REGEXP = /\.\w+$/;
|
||||
@ -156,19 +155,4 @@ export function smartOutputFile(filePath: string, content: string) {
|
||||
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 };
|
||||
|
@ -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({
|
||||
displayTimestamp: true
|
||||
});
|
||||
|
||||
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 slimPath(path: string) {
|
||||
return chalk.yellow(path.replace(ROOT, ''));
|
||||
}
|
||||
|
||||
export function getInteractiveLogger() {
|
||||
const interactive = new logger.Signale({
|
||||
interactive: true,
|
||||
config: {
|
||||
displayTimestamp: true
|
||||
}
|
||||
});
|
||||
|
||||
return interactive;
|
||||
}
|
||||
|
||||
export { logger };
|
||||
export { ora, consola };
|
||||
|
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) {
|
||||
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
||||
const { css } = await postcss(config.plugins as any).process(source, {
|
||||
from: undefined
|
||||
from: undefined,
|
||||
});
|
||||
|
||||
return cleanCss.minify(css).styles;
|
||||
|
@ -13,14 +13,14 @@ class TildeResolver extends FileManager {
|
||||
const TildeResolverPlugin = {
|
||||
install(lessInstance: unknown, pluginManager: any) {
|
||||
pluginManager.addFileManager(new TildeResolver());
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export async function compileLess(filePath: string) {
|
||||
const source = readFileSync(filePath, 'utf-8');
|
||||
const { css } = await render(source, {
|
||||
filename: filePath,
|
||||
plugins: [TildeResolverPlugin]
|
||||
plugins: [TildeResolverPlugin],
|
||||
});
|
||||
|
||||
return css;
|
||||
|
@ -1,9 +1,11 @@
|
||||
import webpack from 'webpack';
|
||||
import { packageConfig } from '../config/webpack.package';
|
||||
import { getPackageConfig } from '../config/webpack.package';
|
||||
|
||||
export async function compilePackage(isMinify: boolean) {
|
||||
return new Promise((resolve, reject) => {
|
||||
webpack(packageConfig(isMinify), (err, stats) => {
|
||||
const config = getPackageConfig(isMinify);
|
||||
|
||||
webpack(config, (err, stats) => {
|
||||
if (err || stats.hasErrors()) {
|
||||
reject();
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@ function compileTemplate(template: string) {
|
||||
const result = compileUtils.compileTemplate({
|
||||
compiler,
|
||||
source: template,
|
||||
isProduction: true
|
||||
isProduction: true,
|
||||
} as any);
|
||||
|
||||
return result.code;
|
||||
@ -73,7 +73,7 @@ export function parseSfc(filePath: string) {
|
||||
const descriptor = compileUtils.parse({
|
||||
source,
|
||||
compiler,
|
||||
needMap: false
|
||||
needMap: false,
|
||||
} as any);
|
||||
|
||||
return descriptor;
|
||||
|
@ -1,19 +1,45 @@
|
||||
import chalk from 'chalk';
|
||||
import address from 'address';
|
||||
import webpack from 'webpack';
|
||||
import WebpackDevServer from 'webpack-dev-server';
|
||||
import { get } from 'lodash';
|
||||
import { getPort } from 'portfinder';
|
||||
import { siteDevConfig } from '../config/webpack.site.dev';
|
||||
import { sitePrdConfig } from '../config/webpack.site.prd';
|
||||
import { GREEN } from '../common/constant';
|
||||
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() {
|
||||
const server = new WebpackDevServer(
|
||||
webpack(siteDevConfig),
|
||||
siteDevConfig.devServer
|
||||
);
|
||||
const config = getSiteDevConfig();
|
||||
|
||||
getPort(
|
||||
{
|
||||
port: siteDevConfig.devServer!.port
|
||||
port: config.devServer!.port,
|
||||
},
|
||||
(err, port) => {
|
||||
if (err) {
|
||||
@ -21,19 +47,17 @@ function watch() {
|
||||
return;
|
||||
}
|
||||
|
||||
const host = get(siteDevConfig.devServer, 'host', 'localhost');
|
||||
server.listen(port, host, (err?: Error) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
logServerInfo(port);
|
||||
runDevServer(port, config);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function build() {
|
||||
return new Promise((resolve, reject) => {
|
||||
webpack(sitePrdConfig, (err, stats) => {
|
||||
const config = getSitePrdConfig();
|
||||
|
||||
webpack(config, (err, stats) => {
|
||||
if (err || stats.hasErrors()) {
|
||||
reject();
|
||||
} else {
|
||||
|
@ -4,7 +4,7 @@ import { replaceExt } from '../common';
|
||||
import { compileCss } from './compile-css';
|
||||
import { compileLess } from './compile-less';
|
||||
import { compileSass } from './compile-sass';
|
||||
import { logger } from '../common/logger';
|
||||
import { consola } from '../common/logger';
|
||||
|
||||
async function compileFile(filePath: string) {
|
||||
const parsedPath = parse(filePath);
|
||||
@ -23,7 +23,7 @@ async function compileFile(filePath: string) {
|
||||
const source = readFileSync(filePath, 'utf-8');
|
||||
return await compileCss(source);
|
||||
} catch (err) {
|
||||
logger.error('Compile style failed: ' + filePath);
|
||||
consola.error('Compile style failed: ' + filePath);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
ES_DIR,
|
||||
SRC_DIR,
|
||||
LIB_DIR,
|
||||
STYPE_DEPS_JSON_FILE
|
||||
STYPE_DEPS_JSON_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
function getDeps(component: string): string[] {
|
||||
@ -41,12 +41,12 @@ function getRelativePath(component: string, style: string, ext: string) {
|
||||
const OUTPUT_CONFIG = [
|
||||
{
|
||||
dir: ES_DIR,
|
||||
template: (dep: string) => `import '${dep}';`
|
||||
template: (dep: string) => `import '${dep}';`,
|
||||
},
|
||||
{
|
||||
dir: LIB_DIR,
|
||||
template: (dep: string) => `require('${dep}');`
|
||||
}
|
||||
template: (dep: string) => `require('${dep}');`,
|
||||
},
|
||||
];
|
||||
|
||||
function genEntry(params: {
|
||||
@ -92,7 +92,7 @@ export function genComponentStyle(
|
||||
baseFile,
|
||||
component,
|
||||
filename: 'index.js',
|
||||
ext: '.css'
|
||||
ext: '.css',
|
||||
});
|
||||
|
||||
if (CSS_LANG !== 'css') {
|
||||
@ -100,7 +100,7 @@ export function genComponentStyle(
|
||||
baseFile,
|
||||
component,
|
||||
filename: CSS_LANG + '.js',
|
||||
ext: '.' + CSS_LANG
|
||||
ext: '.' + CSS_LANG,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { get } from 'lodash';
|
||||
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';
|
||||
|
||||
type Options = {
|
||||
|
@ -6,14 +6,14 @@ import {
|
||||
removeExt,
|
||||
getVantConfig,
|
||||
smartOutputFile,
|
||||
normalizePath
|
||||
normalizePath,
|
||||
} from '../common';
|
||||
import {
|
||||
SRC_DIR,
|
||||
DOCS_DIR,
|
||||
getPackageJson,
|
||||
VANT_CONFIG_FILE,
|
||||
SITE_DESKTOP_SHARED_FILE
|
||||
SITE_DESKTOP_SHARED_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
type DocumentItem = {
|
||||
@ -52,7 +52,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
||||
components.forEach(component => {
|
||||
docs.push({
|
||||
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 => {
|
||||
docs.push({
|
||||
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('.');
|
||||
return {
|
||||
name: formatName(pairs[0], pairs[1] || defaultLang),
|
||||
path
|
||||
path,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
decamelize,
|
||||
getVantConfig,
|
||||
smartOutputFile,
|
||||
normalizePath
|
||||
normalizePath,
|
||||
} from '../common';
|
||||
|
||||
type DemoItem = {
|
||||
@ -25,7 +25,10 @@ import './package-style';
|
||||
|
||||
function genImports(demos: DemoItem[]) {
|
||||
return demos
|
||||
.map(item => `import ${item.name} from '${removeExt(normalizePath(item.path))}';`)
|
||||
.map(
|
||||
item =>
|
||||
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
||||
)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
@ -73,7 +76,7 @@ function genCode(components: string[]) {
|
||||
.map(component => ({
|
||||
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));
|
||||
|
||||
|
@ -5,8 +5,6 @@ import { getDeps, clearDepsCache, fillExt } from './get-deps';
|
||||
import { getComponents, smartOutputFile } from '../common';
|
||||
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
|
||||
|
||||
const components = getComponents();
|
||||
|
||||
function matchPath(path: string, component: string): boolean {
|
||||
return path
|
||||
.replace(SRC_DIR, '')
|
||||
@ -23,7 +21,7 @@ export function checkStyleExists(component: string) {
|
||||
}
|
||||
|
||||
// analyze component dependencies
|
||||
function analyzeComponentDeps(component: string) {
|
||||
function analyzeComponentDeps(components: string[], component: string) {
|
||||
const checkList: string[] = [];
|
||||
const componentEntry = fillExt(join(SRC_DIR, component, 'index'));
|
||||
const record = new Set();
|
||||
@ -54,7 +52,7 @@ function analyzeComponentDeps(component: string) {
|
||||
|
||||
type DepsMap = Record<string, string[]>;
|
||||
|
||||
function getSequence(depsMap: DepsMap) {
|
||||
function getSequence(components: string[], depsMap: DepsMap) {
|
||||
const sequence: string[] = [];
|
||||
const record = new Set();
|
||||
|
||||
@ -94,16 +92,18 @@ function getSequence(depsMap: DepsMap) {
|
||||
}
|
||||
|
||||
export async function genStyleDepsMap() {
|
||||
const components = getComponents();
|
||||
|
||||
return new Promise(resolve => {
|
||||
clearDepsCache();
|
||||
|
||||
const map = {} as DepsMap;
|
||||
|
||||
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 => {
|
||||
map[key] = map[key].sort(
|
||||
|
@ -14,7 +14,7 @@ export function genVeturConfig() {
|
||||
path: SRC_DIR,
|
||||
test: /zh-CN\.md/,
|
||||
outputDir: join(ROOT, 'vetur'),
|
||||
...options
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -10,33 +10,33 @@ import { PACKAGE_ENTRY_FILE, PACKAGE_STYLE_FILE } from '../common/constant';
|
||||
|
||||
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 {
|
||||
apply(compiler: Compiler) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, this.genSiteEntry);
|
||||
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, genSiteEntry);
|
||||
} 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',
|
||||
{
|
||||
loose: true,
|
||||
modules: useESModules ? false : 'commonjs'
|
||||
}
|
||||
modules: useESModules ? false : 'commonjs',
|
||||
},
|
||||
],
|
||||
[
|
||||
'@vue/babel-preset-jsx',
|
||||
{
|
||||
functional: false
|
||||
}
|
||||
functional: false,
|
||||
},
|
||||
],
|
||||
'@babel/preset-typescript'
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
{
|
||||
corejs: false,
|
||||
useESModules
|
||||
}
|
||||
useESModules,
|
||||
},
|
||||
],
|
||||
[
|
||||
'import',
|
||||
{
|
||||
libraryName: 'vant',
|
||||
libraryDirectory: useESModules ? 'es' : 'lib',
|
||||
style: true
|
||||
style: true,
|
||||
},
|
||||
'vant'
|
||||
'vant',
|
||||
],
|
||||
'@babel/plugin-transform-object-assign',
|
||||
'@babel/plugin-proposal-optional-chaining',
|
||||
'@babel/plugin-proposal-nullish-coalescing-operator'
|
||||
]
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -4,26 +4,26 @@ import {
|
||||
ROOT,
|
||||
JEST_SETUP_FILE,
|
||||
JEST_FILE_MOCK_FILE,
|
||||
JEST_STYLE_MOCK_FILE
|
||||
JEST_STYLE_MOCK_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
moduleNameMapper: {
|
||||
'\\.(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],
|
||||
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
||||
transform: {
|
||||
'\\.(vue)$': 'vue-jest',
|
||||
'\\.(js|jsx|ts|tsx)$': 'babel-jest'
|
||||
'\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
||||
},
|
||||
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
|
||||
snapshotSerializers: ['jest-serializer-vue'],
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', '!**/demo/**'],
|
||||
coverageReporters: ['html', 'lcov', 'text-summary'],
|
||||
coverageDirectory: './test/coverage'
|
||||
coverageDirectory: './test/coverage',
|
||||
};
|
||||
|
||||
function readRootConfig() {
|
||||
@ -38,5 +38,5 @@ function readRootConfig() {
|
||||
|
||||
module.exports = {
|
||||
...DEFAULT_CONFIG,
|
||||
...readRootConfig()
|
||||
...readRootConfig(),
|
||||
};
|
||||
|
@ -7,20 +7,20 @@ type PostcssConfig = object & {
|
||||
function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) {
|
||||
const plugins = {
|
||||
...config1.plugins,
|
||||
...config2.plugins
|
||||
...config2.plugins,
|
||||
};
|
||||
|
||||
return {
|
||||
...config1,
|
||||
...config2,
|
||||
plugins
|
||||
plugins,
|
||||
};
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
plugins: {
|
||||
autoprefixer: {}
|
||||
}
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig());
|
||||
|
@ -6,14 +6,14 @@ import {
|
||||
CACHE_DIR,
|
||||
STYLE_EXTS,
|
||||
SCRIPT_EXTS,
|
||||
POSTCSS_CONFIG_FILE
|
||||
POSTCSS_CONFIG_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
const CACHE_LOADER = {
|
||||
loader: 'cache-loader',
|
||||
options: {
|
||||
cacheDirectory: CACHE_DIR
|
||||
}
|
||||
cacheDirectory: CACHE_DIR,
|
||||
},
|
||||
};
|
||||
|
||||
const CSS_LOADERS = [
|
||||
@ -23,16 +23,16 @@ const CSS_LOADERS = [
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
config: {
|
||||
path: POSTCSS_CONFIG_FILE
|
||||
}
|
||||
}
|
||||
}
|
||||
path: POSTCSS_CONFIG_FILE,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const baseConfig = {
|
||||
mode: 'development',
|
||||
resolve: {
|
||||
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS]
|
||||
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@ -44,26 +44,26 @@ export const baseConfig = {
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
compilerOptions: {
|
||||
preserveWhitespace: false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
preserveWhitespace: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(js|ts|jsx|tsx)$/,
|
||||
exclude: /node_modules\/(?!(@vant\/cli))/,
|
||||
use: [CACHE_LOADER, 'babel-loader']
|
||||
use: [CACHE_LOADER, 'babel-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
sideEffects: true,
|
||||
use: CSS_LOADERS
|
||||
use: CSS_LOADERS,
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
sideEffects: true,
|
||||
use: [...CSS_LOADERS, 'less-loader']
|
||||
use: [...CSS_LOADERS, 'less-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
@ -73,22 +73,22 @@ export const baseConfig = {
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
implementation: sass
|
||||
}
|
||||
}
|
||||
]
|
||||
implementation: sass,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.md$/,
|
||||
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader']
|
||||
}
|
||||
]
|
||||
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader'],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new VueLoaderPlugin(),
|
||||
new FriendlyErrorsPlugin({
|
||||
clearConsole: false,
|
||||
logLevel: 'WARNING'
|
||||
})
|
||||
]
|
||||
logLevel: 'WARNING',
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ import { baseConfig } from './webpack.base';
|
||||
import { getVantConfig, getWebpackConfig, setBuildTarget } from '../common';
|
||||
import { LIB_DIR, ES_DIR } from '../common/constant';
|
||||
|
||||
export function packageConfig(isMinify: boolean) {
|
||||
export function getPackageConfig(isMinify: boolean) {
|
||||
const { name } = getVantConfig();
|
||||
|
||||
setBuildTarget('package');
|
||||
@ -14,7 +14,7 @@ export function packageConfig(isMinify: boolean) {
|
||||
{
|
||||
mode: 'production',
|
||||
entry: {
|
||||
[name]: join(ES_DIR, 'index.js')
|
||||
[name]: join(ES_DIR, 'index.js'),
|
||||
},
|
||||
stats: 'none',
|
||||
output: {
|
||||
@ -24,20 +24,20 @@ export function packageConfig(isMinify: boolean) {
|
||||
filename: isMinify ? '[name].min.js' : '[name].js',
|
||||
umdNamedDefine: true,
|
||||
// https://github.com/webpack/webpack/issues/6522
|
||||
globalObject: "typeof self !== 'undefined' ? self : this"
|
||||
globalObject: "typeof self !== 'undefined' ? self : this",
|
||||
},
|
||||
externals: {
|
||||
vue: {
|
||||
root: 'Vue',
|
||||
commonjs: 'vue',
|
||||
commonjs2: 'vue',
|
||||
amd: 'vue'
|
||||
}
|
||||
amd: 'vue',
|
||||
},
|
||||
},
|
||||
performance: false,
|
||||
optimization: {
|
||||
minimize: isMinify
|
||||
}
|
||||
minimize: isMinify,
|
||||
},
|
||||
},
|
||||
getWebpackConfig()
|
||||
);
|
||||
|
@ -8,95 +8,100 @@ import { baseConfig } from './webpack.base';
|
||||
import { getVantConfig, getWebpackConfig } from '../common';
|
||||
import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin';
|
||||
import {
|
||||
GREEN,
|
||||
SITE_MODILE_SHARED_FILE,
|
||||
SITE_DESKTOP_SHARED_FILE
|
||||
SITE_DESKTOP_SHARED_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
const vantConfig = getVantConfig();
|
||||
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
||||
export function getSiteDevBaseConfig() {
|
||||
const vantConfig = getVantConfig();
|
||||
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
||||
|
||||
function getSiteConfig() {
|
||||
const siteConfig = vantConfig.site;
|
||||
function getSiteConfig() {
|
||||
const siteConfig = vantConfig.site;
|
||||
|
||||
if (siteConfig.locales) {
|
||||
return siteConfig.locales[siteConfig.defaultLang || 'en-US'];
|
||||
if (siteConfig.locales) {
|
||||
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 }) {
|
||||
let { title } = config;
|
||||
if (config.description) {
|
||||
title += ` - ${config.description}`;
|
||||
}
|
||||
|
||||
if (config.description) {
|
||||
title += ` - ${config.description}`;
|
||||
return title;
|
||||
}
|
||||
|
||||
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();
|
||||
const title = getTitle(siteConfig);
|
||||
|
||||
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());
|
||||
export function getSiteDevConfig() {
|
||||
return merge(getSiteDevBaseConfig(), getWebpackConfig());
|
||||
}
|
||||
|
@ -1,24 +1,26 @@
|
||||
import merge from 'webpack-merge';
|
||||
import { get } from 'lodash';
|
||||
import { getVantConfig, getWebpackConfig } from '../common';
|
||||
import { siteDevBaseConfig } from './webpack.site.dev';
|
||||
import { getSiteDevBaseConfig } from './webpack.site.dev';
|
||||
import { SITE_DIST_DIR } from '../common/constant';
|
||||
|
||||
const vantConfig = getVantConfig();
|
||||
const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR);
|
||||
const publicPath = get(vantConfig, 'build.site.publicPath', '/');
|
||||
|
||||
export const sitePrdConfig = merge(
|
||||
siteDevBaseConfig,
|
||||
{
|
||||
mode: 'production',
|
||||
stats: 'none',
|
||||
output: {
|
||||
publicPath,
|
||||
path: outputDir,
|
||||
filename: '[name].[hash:8].js',
|
||||
chunkFilename: 'async_[name].[chunkhash:8].js'
|
||||
}
|
||||
},
|
||||
getWebpackConfig()
|
||||
);
|
||||
export function getSitePrdConfig() {
|
||||
return merge(
|
||||
getSiteDevBaseConfig(),
|
||||
{
|
||||
mode: 'production',
|
||||
stats: 'none',
|
||||
output: {
|
||||
publicPath,
|
||||
path: outputDir,
|
||||
filename: '[name].[hash:8].js',
|
||||
chunkFilename: 'async_[name].[chunkhash:8].js',
|
||||
},
|
||||
},
|
||||
getWebpackConfig()
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
#!/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 { lint } from './commands/lint';
|
||||
import { test } from './commands/jest';
|
||||
@ -11,6 +15,8 @@ import { changelog } from './commands/changelog';
|
||||
import { buildSite } from './commands/build-site';
|
||||
import { commitLint } from './commands/commit-lint';
|
||||
|
||||
version(`@vant/cli ${packageJson.version}`);
|
||||
|
||||
command('dev')
|
||||
.description('Run webpack dev server')
|
||||
.action(dev);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"target": "ES2017",
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
extraFileExtensions: ['.vue']
|
||||
extraFileExtensions: ['.vue'],
|
||||
},
|
||||
|
||||
plugins: ['@typescript-eslint'],
|
||||
@ -14,13 +14,13 @@ module.exports = {
|
||||
es6: true,
|
||||
node: true,
|
||||
jest: true,
|
||||
browser: true
|
||||
browser: true,
|
||||
},
|
||||
|
||||
globals: {
|
||||
window: false,
|
||||
document: false,
|
||||
navigator: false
|
||||
navigator: false,
|
||||
},
|
||||
|
||||
rules: {
|
||||
@ -32,8 +32,17 @@ module.exports = {
|
||||
'no-console': 0,
|
||||
'no-plusplus': 0,
|
||||
'arrow-parens': 0,
|
||||
'comma-dangle': 0,
|
||||
'default-case': 0,
|
||||
'comma-dangle': [
|
||||
'error',
|
||||
{
|
||||
arrays: 'always-multiline',
|
||||
objects: 'always-multiline',
|
||||
imports: 'always-multiline',
|
||||
exports: 'always-multiline',
|
||||
functions: 'never',
|
||||
},
|
||||
],
|
||||
'prefer-template': 0,
|
||||
'consistent-return': 0,
|
||||
'no-param-reassign': 0,
|
||||
@ -64,6 +73,14 @@ module.exports = {
|
||||
'vue/name-property-casing': ['error', 'kebab-case'],
|
||||
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
|
||||
'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",
|
||||
"version": "1.5.1",
|
||||
"description": "eslint config of vant.",
|
||||
"version": "2.0.0",
|
||||
"description": "eslint config of vant",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@ -9,16 +9,16 @@
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-eslint-config",
|
||||
"peerDependencies": {
|
||||
"eslint": "^6.7.2"
|
||||
"eslint": "^6.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^2.12.0",
|
||||
"@typescript-eslint/parser": "^2.12.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.16.0",
|
||||
"@typescript-eslint/parser": "^2.16.0",
|
||||
"eslint-config-airbnb-base": "^14.0.0",
|
||||
"eslint-plugin-import": "^2.19.1",
|
||||
"eslint-plugin-vue": "^6.0.1"
|
||||
"eslint-plugin-import": "^2.20.0",
|
||||
"eslint-plugin-vue": "^6.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.7.2"
|
||||
"eslint": "^6.8.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
## Changelog
|
||||
|
||||
## 1.2.1
|
||||
|
||||
- update share icon
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- fix medal、medal-o typo
|
||||
|
||||
## 1.1.14
|
||||
|
||||
- add down、wap-home-o icon
|
||||
|
Binary file not shown.
@ -36,13 +36,13 @@ function font() {
|
||||
targetPath: '../src/index.less',
|
||||
normalize: true,
|
||||
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(
|
||||
iconfont({
|
||||
fontName,
|
||||
formats
|
||||
formats,
|
||||
})
|
||||
)
|
||||
.pipe(dest(srcDir));
|
||||
|
@ -4,7 +4,8 @@ const shell = require('shelljs');
|
||||
|
||||
const svgDir = path.join(__dirname, '../assets/svg');
|
||||
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);
|
||||
|
||||
|
@ -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 %>";
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/icons",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "vant icons",
|
||||
"main": "./src/config.js",
|
||||
"files": [
|
||||
@ -23,6 +23,7 @@
|
||||
"gulp-iconfont": "^10.0.3",
|
||||
"gulp-iconfont-css": "^3.0.0",
|
||||
"md5-file": "^4.0.0",
|
||||
"release-it": "^12.4.3",
|
||||
"shelljs": "^0.8.3",
|
||||
"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