Skip to content

Commit fea4374

Browse files
author
王世隆
committedJun 14, 2018
U 增加babel 编译命令;
1 parent 1b642d3 commit fea4374

File tree

7 files changed

+355
-21
lines changed

7 files changed

+355
-21
lines changed
 

‎.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist/*
2+
src/babel-utils/*

‎.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/babel-utils/*

‎README.md

+8
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ components = {
3838
<buttonPlain shape="plain">中空默认</buttonPlain>
3939
</template>;
4040
```
41+
42+
#### 注意
43+
44+
- 由于被引用的 utils 等其它资源不会被 babel 编译,所以需要我们自己预先编译
45+
46+
```node
47+
npm run babel
48+
```

‎package.json

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"scripts": {
1212
"dev": "wepy build --watch",
1313
"build": "cross-env NODE_ENV=production wepy build --no-cache",
14+
"babel": "babel --presets env,stage-1 src/utils/index.js -o src/babel-utils/index.js",
1415
"test": "echo \"Error: no test specified\" && exit 1"
1516
},
1617
"author": "王世隆 <547463736@qq.com>",
@@ -23,12 +24,15 @@
2324
"url": "https://github.com/YDJ-FE/wepy-ui-ydj"
2425
},
2526
"devDependencies": {
27+
"babel": "^6.23.0",
28+
"babel-cli": "^6.26.0",
2629
"babel-eslint": "^7.2.1",
2730
"babel-plugin-transform-class-properties": "^6.24.1",
2831
"babel-plugin-transform-decorators-legacy": "^1.3.4",
2932
"babel-plugin-transform-export-extensions": "^6.22.0",
3033
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3134
"babel-preset-env": "^1.6.1",
35+
"babel-preset-stage-1": "^6.24.1",
3236
"cross-env": "^5.1.3",
3337
"eslint": "^3.18.0",
3438
"eslint-config-standard": "^7.1.0",

‎src/babel-utils/index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
/**
7+
* @description 定时执行某些任务,场景如: 自动聊天,动画效果的分时替换
8+
* 如果是动画的话,需要自己减去动画 duration 时常
9+
* @param {Array<object>} steps
10+
* @returns {() => void}
11+
*/
12+
13+
var todoFn = exports.todoFn = function todoFn(steps) {
14+
var timer = 0;
15+
var $steps = steps.slice();
16+
var first = $steps.shift();
17+
timer = setTimeout(function () {
18+
first.cb && first.cb();
19+
if ($steps.length) todoFn($steps);
20+
}, first.delay);
21+
22+
var clearTime = function clearTime() {
23+
clearTimeout(timer);
24+
timer = 0;
25+
};
26+
return clearTime;
27+
};

‎src/components/Toast.wpy

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</template>
1414
<script>
1515
import wepy from 'wepy'
16-
import { todoFn } from '../utils/index'
16+
import { todoFn } from '../babel-utils/index'
1717

1818
const positionMap = {
1919
top: 'top',

‎yarn.lock

+313-20
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.