Skip to content

Commit fbd6ce4

Browse files
aQingYun7insummer
authored andcommitted
feat:更新版本v0.5.10=>v0.5.11 (#373)
* fix:修复按需加载缺少文件问题 * feat:更改tag事件配置 * feat:更新tag事件冒泡 * feat:新增tag组件size类型 * feat:更新版本v0.5.10=>v0.5.11
1 parent d05c62c commit fbd6ce4

File tree

229 files changed

+7315
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+7315
-294
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module.exports = {
33
"browser": true,
44
"commonjs": true,
55
"es6": true,
6-
"node": true
6+
"node": true,
7+
"jest": true
78
},
89
"extends": "eslint:recommended",
910
"parserOptions": {

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div align="center">
1818

1919
![](https://img.shields.io/badge/build-passing-00d508.svg)
20-
![](https://img.shields.io/badge/version-0.5.9-3963bc.svg)
20+
![](https://img.shields.io/badge/version-0.5.11-3963bc.svg)
2121
![](https://img.shields.io/badge/license-MIT-3963bc.svg)
2222

2323
</div>
@@ -39,7 +39,7 @@ Lin UI 是基于 **微信小程序原生语法** 实现的组件库。遵循简
3939

4040
## 最新版本
4141

42-
核心库:0.5.9
42+
核心库:0.5.11
4343

4444
示例工程:0.0.1-alpha.2
4545

build/build-prod.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ const cssmin = require('gulp-clean-css');
44
const rename = require('gulp-rename');
55
const componentData = require('./build-tool');
66
const result = `{common,behaviors,${componentData()}}`;
7+
const isCustom = result == `{common,behaviors}`;
78

89
// js => js
910
gulp.task('dispose-js', () => {
10-
const path = result ? `../src/${result}/*.js` : '../src/**/*.js';
11+
const path = isCustom ? `../src/${result}/*.js` : '../src/**/*.js';
1112
return gulp.src(path)
1213
.pipe(gulp.dest('../dist/'));
1314
});
1415

1516

1617
gulp.task('dispose-wxss', () => {
17-
const path = result ? `../src/${result}/*.less` : '../src/**/*.less',
18-
remainPath = result ? `!../src/${result}/_*.less` : '!../src/**/_*.less';
18+
const path = isCustom ? `../src/${result}/*.less` : '../src/**/*.less',
19+
remainPath = isCustom ? `!../src/${result}/_*.less` : '!../src/**/_*.less';
1920
return gulp.src([path, remainPath])
2021
.pipe(less())
2122
.pipe(cssmin())
@@ -27,28 +28,28 @@ gulp.task('dispose-wxss', () => {
2728

2829
// wxs => wxs
2930
gulp.task('dispose-wxs', () => {
30-
const path = result ? `../src/${result}/*.wxs` : '../src/**/*.wxs';
31+
const path = isCustom ? `../src/${result}/*.wxs` : '../src/**/*.wxs';
3132
return gulp.src(path)
3233
.pipe(gulp.dest('../dist/'));
3334
});
3435

3536
// json => json
3637
gulp.task('dispose-json', () => {
37-
const path = result ? `../src/${result}/*.json` : '../src/**/*.json';
38+
const path = isCustom ? `../src/${result}/*.json` : '../src/**/*.json';
3839
return gulp.src(path)
3940
.pipe(gulp.dest('../dist/'));
4041
});
4142

4243
// wxml => wxml
4344
gulp.task('dispose-wxml', () => {
44-
const path = result ? `../src/${result}/*.wxml` : '../src/**/*.wxml';
45+
const path = isCustom ? `../src/${result}/*.wxml` : '../src/**/*.wxml';
4546
return gulp.src(path)
4647
.pipe(gulp.dest('../dist/'));
4748
});
4849

4950
// copy
5051
gulp.task('dispose-copy', () => {
51-
const path = result ? `../src/${result}/image/**` : '../src/**/image/**';
52+
const path = isCustom ? `../src/${result}/image/**` : '../src/**/image/**';
5253
return gulp.src(path)
5354
.pipe(gulp.dest('../dist/'));
5455
});

dist/action-sheet/index.js

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
Component({
2+
externalClasses: ['l-class-title', 'l-class-item', 'l-class-cancel'],
3+
properties: {
4+
locked: Boolean,
5+
showCancel: Boolean,
6+
show: Boolean,
7+
itemList: Array,
8+
cancelText: {
9+
type: String,
10+
value: '取消'
11+
},
12+
title: String,
13+
openApi: {
14+
type: Boolean,
15+
value: true,
16+
}
17+
},
18+
data: {
19+
success: '',
20+
fail: '',
21+
isIphoneX: false
22+
},
23+
attached() {
24+
if (this.data.openApi) {
25+
this.initActionSheet();
26+
}
27+
this.initUIAdapter();
28+
},
29+
30+
lifetimes: {
31+
show() {
32+
if (this.data.openApi) {
33+
this.initActionSheet();
34+
}
35+
36+
},
37+
},
38+
methods: {
39+
/**
40+
* 区分UI尺寸
41+
*/
42+
initUIAdapter() {
43+
wx.getSystemInfo({
44+
success: (res) => {
45+
this.setData({
46+
isIphoneX: res.model == 'iPhone X' ? true : false,
47+
});
48+
}
49+
});
50+
},
51+
initActionSheet() {
52+
const config = {
53+
itemList: [],
54+
success: null,
55+
fail: null,
56+
title: '',
57+
locked: false,
58+
cancelText: '取消',
59+
showCancel: false
60+
};
61+
wx.lin = wx.lin || {};
62+
wx.lin.showActionSheet = (options={}) => {
63+
const {
64+
itemList = config.itemList,
65+
success = config.success,
66+
fail = config.fail,
67+
title = config.title,
68+
locked = config.locked,
69+
cancelText = config.cancelText,
70+
showCancel = config.showCancel,
71+
} = options;
72+
this.setData({
73+
itemList: itemList.slice(0, 10),
74+
success,
75+
fail,
76+
title,
77+
locked,
78+
cancelText,
79+
showCancel,
80+
show: true,
81+
});
82+
return this;
83+
};
84+
},
85+
handleClickItem(e) {
86+
const {
87+
success
88+
} = this.data;
89+
success && success({ ...e.currentTarget.dataset });
90+
this.triggerEvent('linitemtap', { ...e.currentTarget.dataset });
91+
this._hideActionSheet();
92+
},
93+
94+
_showActionSheet() {
95+
this.setData({
96+
show: true
97+
});
98+
},
99+
100+
_hideActionSheet() {
101+
this.setData({
102+
show: false
103+
});
104+
},
105+
106+
handleClickCancel() {
107+
const {
108+
fail
109+
} = this.data;
110+
fail && fail({
111+
errMsg: 'showactionsheet:fail cancel'
112+
});
113+
this.triggerEvent('lincancel', {
114+
errMsg: 'showactionsheet:fail cancel'
115+
});
116+
this._hideActionSheet();
117+
},
118+
119+
handleClickPopUp() {
120+
if (!this.data.locked) {
121+
this.handleClickCancel();
122+
}
123+
},
124+
}
125+
});

dist/action-sheet/index.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"component": true,
3+
"usingComponents": {
4+
"l-icon":"../icon/index",
5+
"l-popup":"../popup/index",
6+
"l-button":"../button/index"
7+
}
8+
}

dist/action-sheet/index.wxml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<l-popup show="{{show}}" showMask="{{true}}" contentAlign="bottom" locked="{{locked}}" bind:lintap="handleClickPopUp">
2+
<view class='l-action-sheet'>
3+
<view class="l-item-button l-class-title" wx:if="{{title}}">
4+
{{ title }}
5+
</view>
6+
<view class="" wx:for="{{ itemList }}" wx:key="{{ item.name }}">
7+
<l-button bind:lintap="handleClickItem" data-index="{{ index }}" data-item="{{ item }}" open-type="{{ item.openType }}" icon="{{ item.icon }}" type="ghost" size="large" special="{{true}}" long>
8+
<view style="{{ item.color ? 'color: ' + item.color : '' }}" class="l-item-button l-class-item {{item.image || item.icon ? 'l-image-button':''}}">
9+
<image wx:if="{{item.image}}" class="l-button-image" src="{{item.image}}" style="{{item.imageStyle}}"/>
10+
<l-icon
11+
wx:elif="{{ item.icon }}"
12+
name="{{ item.icon }}"
13+
l-class="l-item-button"
14+
color="{{item.color}}"></l-icon>
15+
<text class="l-button-text">{{ item.name }}</text>
16+
</view>
17+
</l-button>
18+
</view>
19+
<view class="l-cancel l-class-cancel {{isIphoneX ? 'l-cancel-x':''}}" wx:if="{{ showCancel }}">
20+
<l-button type="ghost" size="large" long="true" bind:lintap="handleClickCancel" special="{{true}}">
21+
<view class="l-item-button l-cancel-button">{{ cancelText }}</view>
22+
</l-button>
23+
</view>
24+
</view>
25+
</l-popup>

dist/action-sheet/index.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.l-action-sheet{background:#f7f7f7}.l-item-button{height:88rpx;line-height:88rpx;text-align:center;background:#fff;border-bottom:2rpx solid #f3f3f3;font-size:28rpx;color:#45526b;display:flex;align-items:center;justify-content:center;width:100%}.l-cancel{margin-top:12rpx}.l-cancel-x .l-item-button{padding-bottom:44rpx}.l-image-button>text{margin-left:20rpx}

dist/avatar/index.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Component({
2+
externalClasses: ['l-class', 'l-class-text'],
3+
properties: {
4+
icon: String,
5+
text: String,
6+
iconStyle: {
7+
type: String,
8+
observer: '_parseCSSText'
9+
},
10+
src: String,
11+
openData: {
12+
type: Array,
13+
observer: '_initOpenData'
14+
},
15+
shape: {
16+
type: String,
17+
value: 'circle'
18+
},
19+
mode: {
20+
type: String,
21+
value: 'scaleToFill'
22+
},
23+
size: {
24+
type: Number,
25+
value: 120,
26+
},
27+
placement: {
28+
type: String,
29+
value: 'right'
30+
},
31+
},
32+
data: {
33+
_isHaveUserNickName: false,
34+
_isHaveUserAvatarUrl: false,
35+
_iconSize: '',
36+
_iconColor: '#ffffff'
37+
},
38+
methods: {
39+
_initOpenData: function (openData) {
40+
this._isHaveUserAvatarUrl(openData);
41+
this._isHaveUserNickName(openData);
42+
},
43+
_parseCSSText: function parseCSSText(cssText) {
44+
var cssTxt = cssText.replace('/\/\*(.|\s)*?\*\//g', ' ').replace('/\s+/g', ' ');
45+
var style = {};
46+
var properties = cssTxt.split(';').map(function (o) {
47+
return o.split(':').map(function (x) {
48+
return x && x.trim();
49+
});
50+
});
51+
properties.forEach(function (property) {
52+
var key = property[0];
53+
var value = property[1];
54+
style[key] = value;
55+
});
56+
57+
this.setData({
58+
_iconSize: style.size || this.data.size * 0.6,
59+
_iconColor: style.color || '#ffffff',
60+
});
61+
},
62+
_isHaveUserAvatarUrl: function (openData) {
63+
this.setData({
64+
_isHaveUserAvatarUrl: openData.indexOf('userAvatarUrl') !== -1
65+
});
66+
},
67+
68+
_isHaveUserNickName: function (openData) {
69+
this.setData({
70+
_isHaveUserNickName: openData.indexOf('userNickName') !== -1
71+
});
72+
},
73+
tapAvatar: function (e) {
74+
this.triggerEvent('lintap', {
75+
e
76+
}, {
77+
bubbles: false
78+
});
79+
this.triggerEvent('lintapcatch', {
80+
e
81+
}, {
82+
bubbles: true
83+
});
84+
},
85+
}
86+
});

dist/avatar/index.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"component": true,
3+
"usingComponents": {
4+
"l-icon":"../icon/index"
5+
}
6+
}

dist/avatar/index.wxml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
<view class="l-avatar {{text||_isHaveUserNickName?'l-placement-'+placement:''}}" bindtap="tapAvatar">
3+
<view class="l-avatar-image {{shape?'l-'+shape:''}} l-class" wx:if="{{_isHaveUserAvatarUrl||icon||src}}" style="width:{{size}}rpx;height:{{size}}rpx">
4+
<open-data wx:if="{{_isHaveUserAvatarUrl}}" type="userAvatarUrl" />
5+
<l-icon wx:elif="{{icon}}" size="{{_iconSize || size*0.6}}" color="{{_iconColor||'#ffffff'}}" name="{{icon}}" />
6+
<image wx:elif="{{src}}" src="{{src}}" mode="{{mode}}" style="width:{{size}}rpx;height:{{size}}rpx" />
7+
</view>
8+
<view class="l-avatar-text l-class-text" wx:if="{{text||_isHaveUserNickName}}">
9+
<open-data wx:if="{{_isHaveUserNickName}}" type="userNickName" />
10+
<text wx:elif="{{text}}">{{text}}</text>
11+
</view>
12+
</view>

0 commit comments

Comments
 (0)