[build] 2.4.3

This commit is contained in:
niunai 2017-12-28 16:42:02 +08:00
parent dff2430383
commit 1daaca1538
4 changed files with 57 additions and 4 deletions

54
dist/common/helper.js vendored
View File

@ -5,6 +5,56 @@ function extractComponentId(event = {}) {
return componentId;
}
module.exports = {
extractComponentId
const LIFE_CYCLE = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll'];
/*
1. 直接合并所有生命周期函数
Page(extend({}, {
onLoad() {},
...
}));
2. 只合并指定的生命周期
const extendOnload = extend(['onLoad']);
Page(extendOnload({}, {
onLoad() {},
...
}));
*/
const extend = (obj, ...rest) => {
if (Array.isArray(obj)) {
let lifeCycleList = obj.filter(item => LIFE_CYCLE.indexOf(item) >= 0);
return extendWithLife.bind(null, lifeCycleList);
}
return extendWithLife(LIFE_CYCLE, obj, ...rest);
};
const extendWithLife = (lifeCycleList, target, ...objList) => {
objList.forEach((source) => {
if (source) {
let keys = Object.keys(source);
keys.forEach((key) => {
let value = source[key];
if (lifeCycleList.indexOf(key) >= 0 && typeof value === 'function') {
// 合并生命周期函数,可选择改成闭包函数列表
let funcArrayName = `__$${key}`;
if (!target[funcArrayName]) {
target[funcArrayName] = [value];
target[key] = function(...rest) {
target[funcArrayName].forEach(func => func.apply(this, rest));
};
} else {
target[funcArrayName].push(value);
}
} else {
target[key] = value;
}
});
}
});
return target;
};
module.exports = {
extractComponentId,
extend
};

3
dist/index.js vendored
View File

@ -7,3 +7,6 @@ exports.Switch = require('./switch/index');
exports.Tab = require('./tab/index');
exports.Toast = require('./toast/index');
exports.TopTips = require('./toptips/index');
const { extend } = require('./common/helper');
exports.extend = extend;

2
dist/index.wxss vendored

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.zan-panel{position:relative;background:#fff;margin-top:10px;overflow:hidden}.zan-panel::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-top-width:1px;border-bottom-width:1px}.zan-panel-title{font-size:14px;line-height:1;color:#999;padding:20px 15px 0 15px}.zan-panel--without-margin-top{margin-top:0}
.zan-panel{position:relative;background:#fff;margin-top:10px;overflow:hidden}.zan-panel::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-top-width:1px;border-bottom-width:1px}.zan-panel-title{font-size:14px;line-height:1;color:#999;padding:20px 15px 0 15px}.zan-panel--without-margin-top{margin-top:0}.zan-panel--without-border::after{border:0 none}