uview-plus 3.1.51 → 3.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +3 -0
- package/components/u-button/u-button.vue +6 -6
- package/components/u-cell/u-cell.vue +2 -1
- package/components/u-copy/u-copy.vue +70 -0
- package/components/u-gap/u-gap.vue +5 -4
- package/index.js +5 -1
- package/libs/css/flex.scss +45 -45
- package/libs/function/colorGradient.js +8 -8
- package/libs/function/debounce.js +2 -2
- package/libs/function/digit.js +5 -5
- package/libs/function/index.js +29 -29
- package/libs/function/test.js +28 -28
- package/libs/function/throttle.js +2 -2
- package/package.json +2 -2
package/changelog.md
CHANGED
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
<!-- #endif -->
|
|
109
109
|
</template>
|
|
110
110
|
|
|
111
|
-
<script>
|
|
111
|
+
<script lang="ts">
|
|
112
112
|
import button from "../../libs/mixin/button.js";
|
|
113
113
|
import openType from "../../libs/mixin/openType.js";
|
|
114
114
|
import mpMixin from '../../libs/mixin/mpMixin.js';
|
|
@@ -275,19 +275,19 @@ export default {
|
|
|
275
275
|
}
|
|
276
276
|
},
|
|
277
277
|
// 下面为对接uniapp官方按钮开放能力事件回调的对接
|
|
278
|
-
getphonenumber(res) {
|
|
278
|
+
getphonenumber(res: any) {
|
|
279
279
|
this.$emit("getphonenumber", res);
|
|
280
280
|
},
|
|
281
|
-
getuserinfo(res) {
|
|
281
|
+
getuserinfo(res: any) {
|
|
282
282
|
this.$emit("getuserinfo", res);
|
|
283
283
|
},
|
|
284
|
-
error(res) {
|
|
284
|
+
error(res: any) {
|
|
285
285
|
this.$emit("error", res);
|
|
286
286
|
},
|
|
287
|
-
opensetting(res) {
|
|
287
|
+
opensetting(res: any) {
|
|
288
288
|
this.$emit("opensetting", res);
|
|
289
289
|
},
|
|
290
|
-
launchapp(res) {
|
|
290
|
+
launchapp(res: any) {
|
|
291
291
|
this.$emit("launchapp", res);
|
|
292
292
|
},
|
|
293
293
|
},
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
import props from './props.js';
|
|
49
49
|
import mpMixin from '../../libs/mixin/mpMixin.js';
|
|
50
50
|
import mixin from '../../libs/mixin/mixin.js';
|
|
51
|
+
import { addStyle } from '../../libs/function/index.js';
|
|
51
52
|
/**
|
|
52
53
|
* cell 单元格
|
|
53
54
|
* @description cell单元格一般用于一组列表的情况,比如个人中心页,设置页等。
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
mixins: [mpMixin, mixin, props],
|
|
87
88
|
computed: {
|
|
88
89
|
titleTextStyle() {
|
|
89
|
-
return
|
|
90
|
+
return addStyle(this.titleStyle)
|
|
90
91
|
}
|
|
91
92
|
},
|
|
92
93
|
emits: ['click'],
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view @click="handleClick">
|
|
3
|
+
<slot>复制</slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
export default {
|
|
8
|
+
name: "xy-copy",
|
|
9
|
+
props: {
|
|
10
|
+
content: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ''
|
|
13
|
+
},
|
|
14
|
+
alertStyle: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: 'toast'
|
|
17
|
+
},
|
|
18
|
+
notice: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: '复制成功'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
emits: ['success'],
|
|
24
|
+
methods: {
|
|
25
|
+
handleClick() {
|
|
26
|
+
let content = this.content;
|
|
27
|
+
if (!content) {
|
|
28
|
+
uni.showToast({
|
|
29
|
+
title: '暂无',
|
|
30
|
+
icon: 'none',
|
|
31
|
+
duration: 2000,
|
|
32
|
+
});
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
content = typeof content === 'string' ? content : content.toString() // 复制内容,必须字符串,数字需要转换为字符串
|
|
36
|
+
/**
|
|
37
|
+
* 小程序端 和 app端的复制逻辑
|
|
38
|
+
*/
|
|
39
|
+
let that = this;
|
|
40
|
+
uni.setClipboardData({
|
|
41
|
+
data: content,
|
|
42
|
+
success: function() {
|
|
43
|
+
if (that.alertStyle == 'modal') {
|
|
44
|
+
uni.showModal({
|
|
45
|
+
title: '提示',
|
|
46
|
+
content: that.notice
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
uni.showToast({
|
|
50
|
+
title: that.notice,
|
|
51
|
+
icon: 'none'
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
that.$emit('success');
|
|
55
|
+
},
|
|
56
|
+
fail:function(){
|
|
57
|
+
uni.showToast({
|
|
58
|
+
title: '复制失败',
|
|
59
|
+
icon: 'none',
|
|
60
|
+
duration:3000,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<style lang="scss" scoped>
|
|
70
|
+
</style>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import props from './props.js';
|
|
7
7
|
import mpMixin from '../../libs/mixin/mpMixin.js';
|
|
8
8
|
import mixin from '../../libs/mixin/mixin.js';
|
|
9
|
+
import { addStyle, addUnit, deepMerge } from '../../libs/function/index.js';
|
|
9
10
|
/**
|
|
10
11
|
* gap 间隔槽
|
|
11
12
|
* @description 该组件一般用于内容块之间的用一个灰色块隔开的场景,方便用户风格统一,减少工作量
|
|
@@ -25,11 +26,11 @@
|
|
|
25
26
|
gapStyle() {
|
|
26
27
|
const style = {
|
|
27
28
|
backgroundColor: this.bgColor,
|
|
28
|
-
height:
|
|
29
|
-
marginTop:
|
|
30
|
-
marginBottom:
|
|
29
|
+
height: addUnit(this.height),
|
|
30
|
+
marginTop: addUnit(this.marginTop),
|
|
31
|
+
marginBottom: addUnit(this.marginBottom),
|
|
31
32
|
}
|
|
32
|
-
return
|
|
33
|
+
return deepMerge(style, addStyle(this.customStyle))
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
};
|
package/index.js
CHANGED
|
@@ -33,6 +33,10 @@ import color from './libs/config/color.js'
|
|
|
33
33
|
// 平台
|
|
34
34
|
import platform from './libs/function/platform'
|
|
35
35
|
|
|
36
|
+
// 导出
|
|
37
|
+
export * from './libs/function/index.js'
|
|
38
|
+
export const http = new Request()
|
|
39
|
+
|
|
36
40
|
const $u = {
|
|
37
41
|
route,
|
|
38
42
|
date: index.timeFormat, // 另名date
|
|
@@ -42,7 +46,7 @@ const $u = {
|
|
|
42
46
|
colorToRgba: colorGradient.colorToRgba,
|
|
43
47
|
test,
|
|
44
48
|
type: ['primary', 'success', 'error', 'warning', 'info'],
|
|
45
|
-
http
|
|
49
|
+
http,
|
|
46
50
|
config, // uview-plus配置信息相关,比如版本号
|
|
47
51
|
zIndex,
|
|
48
52
|
debounce,
|
package/libs/css/flex.scss
CHANGED
|
@@ -188,74 +188,74 @@
|
|
|
188
188
|
// 以下属于项目(子元素)的类
|
|
189
189
|
|
|
190
190
|
// 子元素交叉轴起点对齐
|
|
191
|
-
.u-flex-self-start {
|
|
192
|
-
|
|
193
|
-
}
|
|
191
|
+
// .u-flex-self-start {
|
|
192
|
+
// align-self: flex-start;
|
|
193
|
+
// }
|
|
194
194
|
|
|
195
|
-
// 子元素交叉轴居中对齐
|
|
196
|
-
.u-flex-self-center {
|
|
197
|
-
|
|
198
|
-
}
|
|
195
|
+
// // 子元素交叉轴居中对齐
|
|
196
|
+
// .u-flex-self-center {
|
|
197
|
+
// align-self: center;
|
|
198
|
+
// }
|
|
199
199
|
|
|
200
|
-
// 子元素交叉轴终点对齐
|
|
201
|
-
.u-flex-self-end {
|
|
202
|
-
|
|
203
|
-
}
|
|
200
|
+
// // 子元素交叉轴终点对齐
|
|
201
|
+
// .u-flex-self-end {
|
|
202
|
+
// align-self: flex-end;
|
|
203
|
+
// }
|
|
204
204
|
|
|
205
205
|
// 子元素交叉轴第一行文字基线对齐
|
|
206
|
-
.u-flex-self-baseline {
|
|
207
|
-
|
|
208
|
-
}
|
|
206
|
+
// .u-flex-self-baseline {
|
|
207
|
+
// align-self: baseline;
|
|
208
|
+
// }
|
|
209
209
|
|
|
210
|
-
// 子元素交叉轴方向拉伸对齐
|
|
211
|
-
.u-flex-self-stretch {
|
|
212
|
-
|
|
213
|
-
}
|
|
210
|
+
// // 子元素交叉轴方向拉伸对齐
|
|
211
|
+
// .u-flex-self-stretch {
|
|
212
|
+
// align-self: stretch;
|
|
213
|
+
// }
|
|
214
214
|
|
|
215
215
|
// 多轴交叉时的对齐方式
|
|
216
216
|
|
|
217
217
|
// 起点对齐
|
|
218
|
-
.u-flex-content-start {
|
|
219
|
-
|
|
220
|
-
}
|
|
218
|
+
// .u-flex-content-start {
|
|
219
|
+
// align-content: flex-start;
|
|
220
|
+
// }
|
|
221
221
|
|
|
222
|
-
// 居中对齐
|
|
223
|
-
.u-flex-content-center {
|
|
224
|
-
|
|
225
|
-
}
|
|
222
|
+
// // 居中对齐
|
|
223
|
+
// .u-flex-content-center {
|
|
224
|
+
// align-content: center;
|
|
225
|
+
// }
|
|
226
226
|
|
|
227
|
-
// 终点对齐
|
|
228
|
-
.u-flex-content-end {
|
|
229
|
-
|
|
230
|
-
}
|
|
227
|
+
// // 终点对齐
|
|
228
|
+
// .u-flex-content-end {
|
|
229
|
+
// align-content: flex-end;
|
|
230
|
+
// }
|
|
231
231
|
|
|
232
|
-
// 两端对齐
|
|
233
|
-
.u-flex-content-between {
|
|
234
|
-
|
|
235
|
-
}
|
|
232
|
+
// // 两端对齐
|
|
233
|
+
// .u-flex-content-between {
|
|
234
|
+
// align-content: space-between;
|
|
235
|
+
// }
|
|
236
236
|
|
|
237
|
-
// 均分间距
|
|
238
|
-
.u-flex-content-around {
|
|
239
|
-
|
|
240
|
-
}
|
|
237
|
+
// // 均分间距
|
|
238
|
+
// .u-flex-content-around {
|
|
239
|
+
// align-content: space-around;
|
|
240
|
+
// }
|
|
241
241
|
|
|
242
242
|
// 全部居中对齐
|
|
243
243
|
.u-flex-middle {
|
|
244
244
|
justify-content: center;
|
|
245
245
|
align-items: center;
|
|
246
|
-
align-self: center;
|
|
247
|
-
align-content: center;
|
|
246
|
+
// align-self: center;
|
|
247
|
+
// align-content: center;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// 是否可以放大
|
|
251
|
-
.u-flex-grow {
|
|
252
|
-
|
|
253
|
-
}
|
|
251
|
+
// .u-flex-grow {
|
|
252
|
+
// flex-grow: 1;
|
|
253
|
+
// }
|
|
254
254
|
|
|
255
255
|
// 是否可以缩小
|
|
256
|
-
.u-flex-shrink {
|
|
257
|
-
|
|
258
|
-
}
|
|
256
|
+
// .u-flex-shrink {
|
|
257
|
+
// flex-shrink: 1;
|
|
258
|
+
// }
|
|
259
259
|
|
|
260
260
|
// 定义内外边距,历遍1-80
|
|
261
261
|
@for $i from 0 through 80 {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {string} endColor 结束的颜色
|
|
5
5
|
* @param {number} step 颜色等分的份额
|
|
6
6
|
* */
|
|
7
|
-
function colorGradient(startColor = 'rgb(0, 0, 0)', endColor = 'rgb(255, 255, 255)', step = 10) {
|
|
7
|
+
export function colorGradient(startColor = 'rgb(0, 0, 0)', endColor = 'rgb(255, 255, 255)', step = 10) {
|
|
8
8
|
const startRGB = hexToRgb(startColor, false) // 转换为rgb数组模式
|
|
9
9
|
const startR = startRGB[0]
|
|
10
10
|
const startG = startRGB[1]
|
|
@@ -33,7 +33,7 @@ function colorGradient(startColor = 'rgb(0, 0, 0)', endColor = 'rgb(255, 255, 25
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// 将hex表示方式转换为rgb表示方式(这里返回rgb数组模式)
|
|
36
|
-
function hexToRgb(sColor, str = true) {
|
|
36
|
+
export function hexToRgb(sColor, str = true) {
|
|
37
37
|
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
|
|
38
38
|
sColor = String(sColor).toLowerCase()
|
|
39
39
|
if (sColor && reg.test(sColor)) {
|
|
@@ -52,16 +52,16 @@ function hexToRgb(sColor, str = true) {
|
|
|
52
52
|
if (!str) {
|
|
53
53
|
return sColorChange
|
|
54
54
|
}
|
|
55
|
-
return `rgb(${sColorChange[0]},${sColorChange[1]},${sColorChange[2]})`
|
|
55
|
+
return `rgb(${sColorChange[0]},${sColorChange[1]},${sColorChange[2]})`
|
|
56
56
|
} if (/^(rgb|RGB)/.test(sColor)) {
|
|
57
57
|
const arr = sColor.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',')
|
|
58
58
|
return arr.map((val) => Number(val))
|
|
59
59
|
}
|
|
60
|
-
return sColor
|
|
60
|
+
return sColor
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// 将rgb表示方式转换为hex表示方式
|
|
64
|
-
function rgbToHex(rgb) {
|
|
64
|
+
export function rgbToHex(rgb) {
|
|
65
65
|
const _this = rgb
|
|
66
66
|
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
|
|
67
67
|
if (/^(rgb|RGB)/.test(_this)) {
|
|
@@ -100,7 +100,7 @@ function rgbToHex(rgb) {
|
|
|
100
100
|
* sHex为传入的十六进制的色值
|
|
101
101
|
* alpha为rgba的透明度
|
|
102
102
|
*/
|
|
103
|
-
function colorToRgba(color, alpha) {
|
|
103
|
+
export function colorToRgba(color, alpha) {
|
|
104
104
|
color = rgbToHex(color)
|
|
105
105
|
// 十六进制颜色值的正则表达式
|
|
106
106
|
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
|
|
@@ -123,7 +123,7 @@ function colorToRgba(color, alpha) {
|
|
|
123
123
|
return `rgba(${sColorChange.join(',')},${alpha})`
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
return sColor
|
|
126
|
+
return sColor
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export default {
|
|
@@ -131,4 +131,4 @@ export default {
|
|
|
131
131
|
hexToRgb,
|
|
132
132
|
rgbToHex,
|
|
133
133
|
colorToRgba
|
|
134
|
-
}
|
|
134
|
+
}
|
|
@@ -8,7 +8,7 @@ let timeout = null
|
|
|
8
8
|
* @param {Boolean} immediate 是否立即执行
|
|
9
9
|
* @return null
|
|
10
10
|
*/
|
|
11
|
-
function debounce(func, wait = 500, immediate = false) {
|
|
11
|
+
export function debounce(func, wait = 500, immediate = false) {
|
|
12
12
|
// 清除定时器
|
|
13
13
|
if (timeout !== null) clearTimeout(timeout)
|
|
14
14
|
// 立即执行,此类情况一般用不到
|
|
@@ -23,7 +23,7 @@ function debounce(func, wait = 500, immediate = false) {
|
|
|
23
23
|
timeout = setTimeout(() => {
|
|
24
24
|
typeof func === 'function' && func()
|
|
25
25
|
}, wait)
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export default debounce
|
package/libs/function/digit.js
CHANGED
|
@@ -5,7 +5,7 @@ let _boundaryCheckingState = true; // 是否进行越界检查的全局开关
|
|
|
5
5
|
* @private
|
|
6
6
|
* @example strip(0.09999999999999998)=0.1
|
|
7
7
|
*/
|
|
8
|
-
function strip(num, precision = 15) {
|
|
8
|
+
export function strip(num, precision = 15) {
|
|
9
9
|
return +parseFloat(Number(num).toPrecision(precision));
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ function strip(num, precision = 15) {
|
|
|
14
14
|
* @private
|
|
15
15
|
* @param {*number} num Input number
|
|
16
16
|
*/
|
|
17
|
-
function digitLength(num) {
|
|
17
|
+
export function digitLength(num) {
|
|
18
18
|
// Get digit length of e
|
|
19
19
|
const eSplit = num.toString().split(/[eE]/);
|
|
20
20
|
const len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
|
|
@@ -26,7 +26,7 @@ function digitLength(num) {
|
|
|
26
26
|
* @private
|
|
27
27
|
* @param {*number} num 输入数
|
|
28
28
|
*/
|
|
29
|
-
function float2Fixed(num) {
|
|
29
|
+
export function float2Fixed(num) {
|
|
30
30
|
if (num.toString().indexOf('e') === -1) {
|
|
31
31
|
return Number(num.toString().replace('.', ''));
|
|
32
32
|
}
|
|
@@ -39,7 +39,7 @@ function float2Fixed(num) {
|
|
|
39
39
|
* @private
|
|
40
40
|
* @param {*number} num 输入数
|
|
41
41
|
*/
|
|
42
|
-
function checkBoundary(num) {
|
|
42
|
+
export function checkBoundary(num) {
|
|
43
43
|
if (_boundaryCheckingState) {
|
|
44
44
|
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
|
|
45
45
|
console.warn(`${num} 超出了精度限制,结果可能不正确`);
|
|
@@ -53,7 +53,7 @@ function checkBoundary(num) {
|
|
|
53
53
|
* @param {function} operation 迭代操作
|
|
54
54
|
* @private
|
|
55
55
|
*/
|
|
56
|
-
function iteratorOperation(arr, operation) {
|
|
56
|
+
export function iteratorOperation(arr, operation) {
|
|
57
57
|
const [num1, num2, ...others] = arr;
|
|
58
58
|
let res = operation(num1, num2);
|
|
59
59
|
|
package/libs/function/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { round } from './digit.js'
|
|
|
6
6
|
* @param {number} max
|
|
7
7
|
* @param {number} value
|
|
8
8
|
*/
|
|
9
|
-
function range(min = 0, max = 0, value = 0) {
|
|
9
|
+
export function range(min = 0, max = 0, value = 0) {
|
|
10
10
|
return Math.max(min, Math.min(max, Number(value)))
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ function range(min = 0, max = 0, value = 0) {
|
|
|
16
16
|
* @param {boolean} unit
|
|
17
17
|
* @returns {number|string}
|
|
18
18
|
*/
|
|
19
|
-
function getPx(value, unit = false) {
|
|
19
|
+
export function getPx(value, unit = false) {
|
|
20
20
|
if (test.number(value)) {
|
|
21
21
|
return unit ? `${value}px` : Number(value)
|
|
22
22
|
}
|
|
@@ -32,7 +32,7 @@ function getPx(value, unit = false) {
|
|
|
32
32
|
* @param {number} value 堵塞时间 单位ms 毫秒
|
|
33
33
|
* @returns {Promise} 返回promise
|
|
34
34
|
*/
|
|
35
|
-
function sleep(value = 30) {
|
|
35
|
+
export function sleep(value = 30) {
|
|
36
36
|
return new Promise((resolve) => {
|
|
37
37
|
setTimeout(() => {
|
|
38
38
|
resolve()
|
|
@@ -44,14 +44,14 @@ function sleep(value = 30) {
|
|
|
44
44
|
* @returns {string} 返回所在平台(小写)
|
|
45
45
|
* @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
|
|
46
46
|
*/
|
|
47
|
-
function os() {
|
|
47
|
+
export function os() {
|
|
48
48
|
return uni.getSystemInfoSync().platform.toLowerCase()
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* @description 获取系统信息同步接口
|
|
52
52
|
* @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
|
|
53
53
|
*/
|
|
54
|
-
function sys() {
|
|
54
|
+
export function sys() {
|
|
55
55
|
return uni.getSystemInfoSync()
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -60,7 +60,7 @@ function sys() {
|
|
|
60
60
|
* @param {Number} min 最小值
|
|
61
61
|
* @param {Number} max 最大值
|
|
62
62
|
*/
|
|
63
|
-
function random(min, max) {
|
|
63
|
+
export function random(min, max) {
|
|
64
64
|
if (min >= 0 && max > 0 && max >= min) {
|
|
65
65
|
const gab = max - min + 1
|
|
66
66
|
return Math.floor(Math.random() * gab + min)
|
|
@@ -73,7 +73,7 @@ function random(min, max) {
|
|
|
73
73
|
* @param {Boolean} firstU 将返回的首字母置为"u"
|
|
74
74
|
* @param {Nubmer} radix 生成uuid的基数(意味着返回的字符串都是这个基数),2-二进制,8-八进制,10-十进制,16-十六进制
|
|
75
75
|
*/
|
|
76
|
-
function guid(len = 32, firstU = true, radix = null) {
|
|
76
|
+
export function guid(len = 32, firstU = true, radix = null) {
|
|
77
77
|
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
|
|
78
78
|
const uuid = []
|
|
79
79
|
radix = radix || chars.length
|
|
@@ -109,7 +109,7 @@ function guid(len = 32, firstU = true, radix = null) {
|
|
|
109
109
|
值(默认为undefined),就是查找最顶层的$parent
|
|
110
110
|
* @param {string|undefined} name 父组件的参数名
|
|
111
111
|
*/
|
|
112
|
-
function $parent(name = undefined) {
|
|
112
|
+
export function $parent(name = undefined) {
|
|
113
113
|
let parent = this.$parent
|
|
114
114
|
// 通过while历遍,这里主要是为了H5需要多层解析的问题
|
|
115
115
|
while (parent) {
|
|
@@ -131,7 +131,7 @@ function $parent(name = undefined) {
|
|
|
131
131
|
* @param {String} target 转换的目的,object-转为对象,string-转为字符串
|
|
132
132
|
* @returns {object|string}
|
|
133
133
|
*/
|
|
134
|
-
function addStyle(customStyle, target = 'object') {
|
|
134
|
+
export function addStyle(customStyle, target = 'object') {
|
|
135
135
|
// 字符串转字符串,对象转对象情形,直接返回
|
|
136
136
|
if (test.empty(customStyle) || typeof(customStyle) === 'object' && target === 'object' || target === 'string' &&
|
|
137
137
|
typeof(customStyle) === 'string') {
|
|
@@ -170,7 +170,7 @@ function addStyle(customStyle, target = 'object') {
|
|
|
170
170
|
* @param {string|number} value 需要添加单位的值
|
|
171
171
|
* @param {string} unit 添加的单位名 比如px
|
|
172
172
|
*/
|
|
173
|
-
function addUnit(value = 'auto', unit = '') {
|
|
173
|
+
export function addUnit(value = 'auto', unit = '') {
|
|
174
174
|
if (!unit) {
|
|
175
175
|
unit = uni.$u.config.unit || 'px'
|
|
176
176
|
}
|
|
@@ -184,7 +184,7 @@ function addUnit(value = 'auto', unit = '') {
|
|
|
184
184
|
* @param {object} obj 需要深度克隆的对象
|
|
185
185
|
* @returns {*} 克隆后的对象或者原值(不是对象)
|
|
186
186
|
*/
|
|
187
|
-
function deepClone(obj) {
|
|
187
|
+
export function deepClone(obj) {
|
|
188
188
|
// 对常见的“非”值,直接返回原来值
|
|
189
189
|
if ([null, undefined, NaN, false].includes(obj)) return obj
|
|
190
190
|
if (typeof obj !== 'object' && typeof obj !== 'function') {
|
|
@@ -206,7 +206,7 @@ function deepClone(obj) {
|
|
|
206
206
|
* @param {object} source 拷贝的来源对象
|
|
207
207
|
* @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
|
|
208
208
|
*/
|
|
209
|
-
function deepMerge(target = {}, source = {}) {
|
|
209
|
+
export function deepMerge(target = {}, source = {}) {
|
|
210
210
|
target = deepClone(target)
|
|
211
211
|
if (typeof target !== 'object' || typeof source !== 'object') return false
|
|
212
212
|
for (const prop in source) {
|
|
@@ -234,7 +234,7 @@ function deepMerge(target = {}, source = {}) {
|
|
|
234
234
|
* @description error提示
|
|
235
235
|
* @param {*} err 错误内容
|
|
236
236
|
*/
|
|
237
|
-
function error(err) {
|
|
237
|
+
export function error(err) {
|
|
238
238
|
// 开发环境才提示,生产环境不会提示
|
|
239
239
|
if (process.env.NODE_ENV === 'development') {
|
|
240
240
|
console.error(`uView提示:${err}`)
|
|
@@ -246,7 +246,7 @@ function error(err) {
|
|
|
246
246
|
* @param {array} array 需要打乱的数组
|
|
247
247
|
* @returns {array} 打乱后的数组
|
|
248
248
|
*/
|
|
249
|
-
function randomArray(array = []) {
|
|
249
|
+
export function randomArray(array = []) {
|
|
250
250
|
// 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
|
|
251
251
|
return array.sort(() => Math.random() - 0.5)
|
|
252
252
|
}
|
|
@@ -283,7 +283,7 @@ if (!String.prototype.padStart) {
|
|
|
283
283
|
* @param {String} fmt 格式化规则 yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合 默认yyyy-mm-dd
|
|
284
284
|
* @returns {string} 返回格式化后的字符串
|
|
285
285
|
*/
|
|
286
|
-
function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
|
|
286
|
+
export function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
|
|
287
287
|
let date
|
|
288
288
|
// 若传入时间为假值,则取当前时间
|
|
289
289
|
if (!dateTime) {
|
|
@@ -337,7 +337,7 @@ if (!String.prototype.padStart) {
|
|
|
337
337
|
* 如果为布尔值false,无论什么时间,都返回多久以前的格式
|
|
338
338
|
* @returns {string} 转化后的内容
|
|
339
339
|
*/
|
|
340
|
-
function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
|
|
340
|
+
export function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
|
|
341
341
|
if (timestamp == null) timestamp = Number(new Date())
|
|
342
342
|
timestamp = parseInt(timestamp)
|
|
343
343
|
// 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位)
|
|
@@ -379,7 +379,7 @@ function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
|
|
|
379
379
|
* @param String str 需要去除空格的字符串
|
|
380
380
|
* @param String pos both(左右)|left|right|all 默认both
|
|
381
381
|
*/
|
|
382
|
-
function trim(str, pos = 'both') {
|
|
382
|
+
export function trim(str, pos = 'both') {
|
|
383
383
|
str = String(str)
|
|
384
384
|
if (pos == 'both') {
|
|
385
385
|
return str.replace(/^\s+|\s+$/g, '')
|
|
@@ -402,7 +402,7 @@ function trim(str, pos = 'both') {
|
|
|
402
402
|
* @param {Boolean} isPrefix,是否自动加上"?"
|
|
403
403
|
* @param {string} arrayFormat 规则 indices|brackets|repeat|comma
|
|
404
404
|
*/
|
|
405
|
-
function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
|
|
405
|
+
export function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
|
|
406
406
|
const prefix = isPrefix ? '?' : ''
|
|
407
407
|
const _result = []
|
|
408
408
|
if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets'
|
|
@@ -459,7 +459,7 @@ function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
|
|
|
459
459
|
* @param {String} title 提示的内容,长度与 icon 取值有关。
|
|
460
460
|
* @param {Number} duration 提示的延迟时间,单位毫秒,默认:2000
|
|
461
461
|
*/
|
|
462
|
-
function toast(title, duration = 2000) {
|
|
462
|
+
export function toast(title, duration = 2000) {
|
|
463
463
|
uni.showToast({
|
|
464
464
|
title: String(title),
|
|
465
465
|
icon: 'none',
|
|
@@ -472,7 +472,7 @@ function toast(title, duration = 2000) {
|
|
|
472
472
|
* @param {String} type 主题名称,primary|info|error|warning|success
|
|
473
473
|
* @param {boolean} fill 是否使用fill填充实体的图标
|
|
474
474
|
*/
|
|
475
|
-
function type2icon(type = 'success', fill = false) {
|
|
475
|
+
export function type2icon(type = 'success', fill = false) {
|
|
476
476
|
// 如果非预置值,默认为success
|
|
477
477
|
if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success'
|
|
478
478
|
let iconName = ''
|
|
@@ -509,7 +509,7 @@ function type2icon(type = 'success', fill = false) {
|
|
|
509
509
|
* @param {string} thousandsSeparator 千分位符号
|
|
510
510
|
* @returns {string} 格式化后的数字
|
|
511
511
|
*/
|
|
512
|
-
function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparator = ',') {
|
|
512
|
+
export function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparator = ',') {
|
|
513
513
|
number = (`${number}`).replace(/[^0-9+-Ee.]/g, '')
|
|
514
514
|
const n = !isFinite(+number) ? 0 : +number
|
|
515
515
|
const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
|
|
@@ -538,7 +538,7 @@ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparato
|
|
|
538
538
|
* @param {boolean} unit 提示: 如果是false 默认返回number
|
|
539
539
|
* @return {string|number}
|
|
540
540
|
*/
|
|
541
|
-
function getDuration(value, unit = true) {
|
|
541
|
+
export function getDuration(value, unit = true) {
|
|
542
542
|
const valueNum = parseInt(value)
|
|
543
543
|
if (unit) {
|
|
544
544
|
if (/s$/.test(value)) return value
|
|
@@ -553,7 +553,7 @@ function getDuration(value, unit = true) {
|
|
|
553
553
|
* @description 日期的月或日补零操作
|
|
554
554
|
* @param {String} value 需要补零的值
|
|
555
555
|
*/
|
|
556
|
-
function padZero(value) {
|
|
556
|
+
export function padZero(value) {
|
|
557
557
|
return `00${value}`.slice(-2)
|
|
558
558
|
}
|
|
559
559
|
|
|
@@ -562,7 +562,7 @@ function padZero(value) {
|
|
|
562
562
|
* @param {*} instance
|
|
563
563
|
* @param {*} event
|
|
564
564
|
*/
|
|
565
|
-
function formValidate(instance, event) {
|
|
565
|
+
export function formValidate(instance, event) {
|
|
566
566
|
const formItem = uni.$u.$parent.call(instance, 'u-form-item')
|
|
567
567
|
const form = uni.$u.$parent.call(instance, 'u-form')
|
|
568
568
|
// 如果发生变化的input或者textarea等,其父组件中有u-form-item或者u-form等,就执行form的validate方法
|
|
@@ -578,7 +578,7 @@ function formValidate(instance, event) {
|
|
|
578
578
|
* @param {string} key 需要获取的属性字段
|
|
579
579
|
* @returns {*}
|
|
580
580
|
*/
|
|
581
|
-
function getProperty(obj, key) {
|
|
581
|
+
export function getProperty(obj, key) {
|
|
582
582
|
if (!obj) {
|
|
583
583
|
return
|
|
584
584
|
}
|
|
@@ -605,7 +605,7 @@ function getProperty(obj, key) {
|
|
|
605
605
|
* @param {string} key 需要设置的属性
|
|
606
606
|
* @param {string} value 设置的值
|
|
607
607
|
*/
|
|
608
|
-
function setProperty(obj, key, value) {
|
|
608
|
+
export function setProperty(obj, key, value) {
|
|
609
609
|
if (!obj) {
|
|
610
610
|
return
|
|
611
611
|
}
|
|
@@ -641,7 +641,7 @@ function setProperty(obj, key, value) {
|
|
|
641
641
|
/**
|
|
642
642
|
* @description 获取当前页面路径
|
|
643
643
|
*/
|
|
644
|
-
function page() {
|
|
644
|
+
export function page() {
|
|
645
645
|
const pages = getCurrentPages()
|
|
646
646
|
// 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组
|
|
647
647
|
return `/${pages[pages.length - 1].route || ''}`
|
|
@@ -650,7 +650,7 @@ function page() {
|
|
|
650
650
|
/**
|
|
651
651
|
* @description 获取当前路由栈实例数组
|
|
652
652
|
*/
|
|
653
|
-
function pages() {
|
|
653
|
+
export function pages() {
|
|
654
654
|
const pages = getCurrentPages()
|
|
655
655
|
return pages
|
|
656
656
|
}
|
|
@@ -662,7 +662,7 @@ function pages() {
|
|
|
662
662
|
* @param {object} color 修改内置color属性
|
|
663
663
|
* @param {object} zIndex 修改内置zIndex属性
|
|
664
664
|
*/
|
|
665
|
-
function setConfig({
|
|
665
|
+
export function setConfig({
|
|
666
666
|
props = {},
|
|
667
667
|
config = {},
|
|
668
668
|
color = {},
|
package/libs/function/test.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 验证电子邮箱格式
|
|
3
3
|
*/
|
|
4
|
-
function email(value) {
|
|
4
|
+
export function email(value) {
|
|
5
5
|
return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 验证手机格式
|
|
10
10
|
*/
|
|
11
|
-
function mobile(value) {
|
|
11
|
+
export function mobile(value) {
|
|
12
12
|
return /^1[23456789]\d{9}$/.test(value)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* 验证URL格式
|
|
17
17
|
*/
|
|
18
|
-
function url(value) {
|
|
18
|
+
export function url(value) {
|
|
19
19
|
return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
|
|
20
20
|
.test(value)
|
|
21
21
|
}
|
|
@@ -23,7 +23,7 @@ function url(value) {
|
|
|
23
23
|
/**
|
|
24
24
|
* 验证日期格式
|
|
25
25
|
*/
|
|
26
|
-
function date(value) {
|
|
26
|
+
export function date(value) {
|
|
27
27
|
if (!value) return false
|
|
28
28
|
// 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳
|
|
29
29
|
if (number(value)) value = +value
|
|
@@ -33,35 +33,35 @@ function date(value) {
|
|
|
33
33
|
/**
|
|
34
34
|
* 验证ISO类型的日期格式
|
|
35
35
|
*/
|
|
36
|
-
function dateISO(value) {
|
|
36
|
+
export function dateISO(value) {
|
|
37
37
|
return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* 验证十进制数字
|
|
42
42
|
*/
|
|
43
|
-
function number(value) {
|
|
43
|
+
export function number(value) {
|
|
44
44
|
return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* 验证字符串
|
|
49
49
|
*/
|
|
50
|
-
function string(value) {
|
|
50
|
+
export function string(value) {
|
|
51
51
|
return typeof value === 'string'
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* 验证整数
|
|
56
56
|
*/
|
|
57
|
-
function digits(value) {
|
|
57
|
+
export function digits(value) {
|
|
58
58
|
return /^\d+$/.test(value)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* 验证身份证号码
|
|
63
63
|
*/
|
|
64
|
-
function idCard(value) {
|
|
64
|
+
export function idCard(value) {
|
|
65
65
|
return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(
|
|
66
66
|
value
|
|
67
67
|
)
|
|
@@ -70,7 +70,7 @@ function idCard(value) {
|
|
|
70
70
|
/**
|
|
71
71
|
* 是否车牌号
|
|
72
72
|
*/
|
|
73
|
-
function carNo(value) {
|
|
73
|
+
export function carNo(value) {
|
|
74
74
|
// 新能源车牌
|
|
75
75
|
const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/
|
|
76
76
|
// 旧车牌
|
|
@@ -86,7 +86,7 @@ function carNo(value) {
|
|
|
86
86
|
/**
|
|
87
87
|
* 金额,只允许2位小数
|
|
88
88
|
*/
|
|
89
|
-
function amount(value) {
|
|
89
|
+
export function amount(value) {
|
|
90
90
|
// 金额,只允许保留两位小数
|
|
91
91
|
return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value)
|
|
92
92
|
}
|
|
@@ -94,7 +94,7 @@ function amount(value) {
|
|
|
94
94
|
/**
|
|
95
95
|
* 中文
|
|
96
96
|
*/
|
|
97
|
-
function chinese(value) {
|
|
97
|
+
export function chinese(value) {
|
|
98
98
|
const reg = /^[\u4e00-\u9fa5]+$/gi
|
|
99
99
|
return reg.test(value)
|
|
100
100
|
}
|
|
@@ -102,14 +102,14 @@ function chinese(value) {
|
|
|
102
102
|
/**
|
|
103
103
|
* 只能输入字母
|
|
104
104
|
*/
|
|
105
|
-
function letter(value) {
|
|
105
|
+
export function letter(value) {
|
|
106
106
|
return /^[a-zA-Z]*$/.test(value)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* 只能是字母或者数字
|
|
111
111
|
*/
|
|
112
|
-
function enOrNum(value) {
|
|
112
|
+
export function enOrNum(value) {
|
|
113
113
|
// 英文或者数字
|
|
114
114
|
const reg = /^[0-9a-zA-Z]*$/g
|
|
115
115
|
return reg.test(value)
|
|
@@ -118,28 +118,28 @@ function enOrNum(value) {
|
|
|
118
118
|
/**
|
|
119
119
|
* 验证是否包含某个值
|
|
120
120
|
*/
|
|
121
|
-
function contains(value, param) {
|
|
121
|
+
export function contains(value, param) {
|
|
122
122
|
return value.indexOf(param) >= 0
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* 验证一个值范围[min, max]
|
|
127
127
|
*/
|
|
128
|
-
function range(value, param) {
|
|
128
|
+
export function range(value, param) {
|
|
129
129
|
return value >= param[0] && value <= param[1]
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* 验证一个长度范围[min, max]
|
|
134
134
|
*/
|
|
135
|
-
function rangeLength(value, param) {
|
|
135
|
+
export function rangeLength(value, param) {
|
|
136
136
|
return value.length >= param[0] && value.length <= param[1]
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* 是否固定电话
|
|
141
141
|
*/
|
|
142
|
-
function landline(value) {
|
|
142
|
+
export function landline(value) {
|
|
143
143
|
const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/
|
|
144
144
|
return reg.test(value)
|
|
145
145
|
}
|
|
@@ -147,7 +147,7 @@ function landline(value) {
|
|
|
147
147
|
/**
|
|
148
148
|
* 判断是否为空
|
|
149
149
|
*/
|
|
150
|
-
function empty(value) {
|
|
150
|
+
export function empty(value) {
|
|
151
151
|
switch (typeof value) {
|
|
152
152
|
case 'undefined':
|
|
153
153
|
return true
|
|
@@ -173,7 +173,7 @@ function empty(value) {
|
|
|
173
173
|
/**
|
|
174
174
|
* 是否json字符串
|
|
175
175
|
*/
|
|
176
|
-
function jsonString(value) {
|
|
176
|
+
export function jsonString(value) {
|
|
177
177
|
if (typeof value === 'string') {
|
|
178
178
|
try {
|
|
179
179
|
const obj = JSON.parse(value)
|
|
@@ -191,7 +191,7 @@ function jsonString(value) {
|
|
|
191
191
|
/**
|
|
192
192
|
* 是否数组
|
|
193
193
|
*/
|
|
194
|
-
function array(value) {
|
|
194
|
+
export function array(value) {
|
|
195
195
|
if (typeof Array.isArray === 'function') {
|
|
196
196
|
return Array.isArray(value)
|
|
197
197
|
}
|
|
@@ -201,14 +201,14 @@ function array(value) {
|
|
|
201
201
|
/**
|
|
202
202
|
* 是否对象
|
|
203
203
|
*/
|
|
204
|
-
function object(value) {
|
|
204
|
+
export function object(value) {
|
|
205
205
|
return Object.prototype.toString.call(value) === '[object Object]'
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* 是否短信验证码
|
|
210
210
|
*/
|
|
211
|
-
function code(value, len = 6) {
|
|
211
|
+
export function code(value, len = 6) {
|
|
212
212
|
return new RegExp(`^\\d{${len}}$`).test(value)
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -216,7 +216,7 @@ function code(value, len = 6) {
|
|
|
216
216
|
* 是否函数方法
|
|
217
217
|
* @param {Object} value
|
|
218
218
|
*/
|
|
219
|
-
function func(value) {
|
|
219
|
+
export function func(value) {
|
|
220
220
|
return typeof value === 'function'
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -224,14 +224,14 @@ function func(value) {
|
|
|
224
224
|
* 是否promise对象
|
|
225
225
|
* @param {Object} value
|
|
226
226
|
*/
|
|
227
|
-
function promise(value) {
|
|
227
|
+
export function promise(value) {
|
|
228
228
|
return object(value) && func(value.then) && func(value.catch)
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/** 是否图片格式
|
|
232
232
|
* @param {Object} value
|
|
233
233
|
*/
|
|
234
|
-
function image(value) {
|
|
234
|
+
export function image(value) {
|
|
235
235
|
const newValue = value.split('?')[0]
|
|
236
236
|
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i
|
|
237
237
|
return IMAGE_REGEXP.test(newValue)
|
|
@@ -241,7 +241,7 @@ function image(value) {
|
|
|
241
241
|
* 是否视频格式
|
|
242
242
|
* @param {Object} value
|
|
243
243
|
*/
|
|
244
|
-
function video(value) {
|
|
244
|
+
export function video(value) {
|
|
245
245
|
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i
|
|
246
246
|
return VIDEO_REGEXP.test(value)
|
|
247
247
|
}
|
|
@@ -251,7 +251,7 @@ function video(value) {
|
|
|
251
251
|
* @param {Object}
|
|
252
252
|
* @return {Boolean}
|
|
253
253
|
*/
|
|
254
|
-
function regExp(o) {
|
|
254
|
+
export function regExp(o) {
|
|
255
255
|
return o && Object.prototype.toString.call(o) === '[object RegExp]'
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let timer; let
|
|
1
|
+
let timer; let
|
|
2
2
|
flag
|
|
3
3
|
/**
|
|
4
4
|
* 节流原理:在一定时间内,只能触发一次
|
|
@@ -8,7 +8,7 @@ let timer; let
|
|
|
8
8
|
* @param {Boolean} immediate 是否立即执行
|
|
9
9
|
* @return null
|
|
10
10
|
*/
|
|
11
|
-
function throttle(func, wait = 500, immediate = true) {
|
|
11
|
+
export function throttle(func, wait = 500, immediate = true) {
|
|
12
12
|
if (immediate) {
|
|
13
13
|
if (!flag) {
|
|
14
14
|
flag = true
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "uview-plus",
|
|
3
3
|
"name": "uview-plus",
|
|
4
4
|
"displayName": "uview-plus3.0重磅发布,全面的Vue3移动组件库。",
|
|
5
|
-
"version": "3.1.
|
|
5
|
+
"version": "3.1.52",
|
|
6
6
|
"description": "uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"uview",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"contact": {
|
|
30
|
-
"qq": "
|
|
30
|
+
"qq": "598821125"
|
|
31
31
|
},
|
|
32
32
|
"declaration": {
|
|
33
33
|
"ads": "无",
|