@lightsoft/js-sdk 1.1.0 → 1.2.0
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/dist/index.d.ts +28 -6
- package/dist/index.js +148 -6
- package/dist/index.umd.js +159 -10
- package/dist/types/reg-exp/index.d.ts +15 -3
- package/dist/types/utils/array.d.ts +1 -0
- package/dist/types/utils/download.d.ts +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/number.d.ts +1 -0
- package/dist/types/utils/vue.d.ts +4 -0
- package/dist/types/utils/ws.d.ts +2 -2
- package/dist/{ws-EehpMWgu.js → ws-DGDUMiR9.js} +3 -3
- package/dist/ws.d.ts +3 -3
- package/dist/ws.js +1 -1
- package/dist/ws.umd.js +4 -4
- package/package.json +1 -1
- package/dist/ws-0exRUlFu.js +0 -144
- package/dist/ws-BPCzgHy0.js +0 -168
- package/dist/ws-CIMFnzix.js +0 -169
- package/dist/ws-DIZYbi31.js +0 -144
- package/dist/ws-D_5GJokP.js +0 -167
- package/dist/ws-DjIqS-Gi.js +0 -169
- package/dist/ws-mqcHwlvx.js +0 -166
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,10 @@ interface CountDown {
|
|
|
58
58
|
* @description 发送验证码倒计时
|
|
59
59
|
*/
|
|
60
60
|
declare function useCountDown(num: number, text?: string): CountDown;
|
|
61
|
+
declare function useDownload(): {
|
|
62
|
+
loading: Ref<boolean, boolean>;
|
|
63
|
+
downloadFile: (url: string, filename?: string, success?: (blob: Blob) => void) => void;
|
|
64
|
+
};
|
|
61
65
|
|
|
62
66
|
declare enum RecordType {
|
|
63
67
|
AUDIO = "audio",
|
|
@@ -261,21 +265,39 @@ interface WebSocketConfig {
|
|
|
261
265
|
declare function createWebSocket(url: string, config: WebSocketConfig | null, onOpen?: Function | null): WebSocket;
|
|
262
266
|
declare function getState(ws: WebSocket, type: WebSocketState): boolean;
|
|
263
267
|
declare function useSendMessage(ws: WebSocket, data: any): void;
|
|
264
|
-
declare function
|
|
265
|
-
declare function
|
|
268
|
+
declare function useOnMessage(ws: WebSocket, callback: Function): void;
|
|
269
|
+
declare function useClose(ws: WebSocket, code?: number, message?: string): void;
|
|
270
|
+
|
|
271
|
+
declare function download(url: string, filename: string, success?: (blob: Blob) => void): Promise<void>;
|
|
272
|
+
|
|
273
|
+
declare const countUp: (start: number, end: number, callback: (current: number) => void) => void;
|
|
274
|
+
|
|
275
|
+
declare function hasRepeatArray(arr: any[], keys?: string[]): any[];
|
|
266
276
|
|
|
267
277
|
/**
|
|
268
278
|
* 匹配中文字母数字
|
|
269
279
|
*/
|
|
270
|
-
declare const
|
|
280
|
+
declare const zhLetterNumber: RegExp;
|
|
271
281
|
/**
|
|
272
282
|
* 匹配 IP
|
|
273
283
|
*/
|
|
274
|
-
declare const
|
|
284
|
+
declare const ip: RegExp;
|
|
275
285
|
/**
|
|
276
286
|
* 匹配手机号
|
|
277
287
|
*/
|
|
278
|
-
declare const
|
|
288
|
+
declare const phone: RegExp;
|
|
289
|
+
/**
|
|
290
|
+
* 匹配身份证号
|
|
291
|
+
*/
|
|
292
|
+
declare const idCard: RegExp;
|
|
293
|
+
/**
|
|
294
|
+
* 匹配邮箱
|
|
295
|
+
*/
|
|
296
|
+
declare const email: RegExp;
|
|
297
|
+
/**
|
|
298
|
+
* 匹配 URL
|
|
299
|
+
*/
|
|
300
|
+
declare const url: RegExp;
|
|
279
301
|
|
|
280
|
-
export { HAS_FEILD,
|
|
302
|
+
export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, RecordType, Request, RequestChain, Tour, countUp, createWebSocket, dataHandler, debounce, deepMerge, download, email, findTreeDataNode, findTreeDataNodeName, getState, hasRepeatArray, idCard, ip, isMobileDevice, isNull, objectArrayToString, phone, throttle, url, useClose, useCountDown, useDownload, useOnMessage, useSendMessage, zhLetterNumber };
|
|
281
303
|
export type { ISectoralTable, Tag, typeIsNull };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as __assign, a as __awaiter, b as __generator } from './ws-
|
|
2
|
-
export { c as createWebSocket, g as getState,
|
|
1
|
+
import { _ as __assign, a as __awaiter, b as __generator } from './ws-DGDUMiR9.js';
|
|
2
|
+
export { c as createWebSocket, g as getState, e as useClose, d as useOnMessage, u as useSendMessage } from './ws-DGDUMiR9.js';
|
|
3
3
|
|
|
4
4
|
var READY_STATE;
|
|
5
5
|
(function (READY_STATE) {
|
|
@@ -2243,6 +2243,52 @@ if (!!(process.env.NODE_ENV !== "production")) {
|
|
|
2243
2243
|
initDev();
|
|
2244
2244
|
}
|
|
2245
2245
|
|
|
2246
|
+
function download(url, filename, success) {
|
|
2247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2248
|
+
var blob;
|
|
2249
|
+
return __generator(this, function (_a) {
|
|
2250
|
+
switch (_a.label) {
|
|
2251
|
+
case 0: return [4 /*yield*/, getBlob(url)];
|
|
2252
|
+
case 1:
|
|
2253
|
+
blob = _a.sent();
|
|
2254
|
+
save(blob, filename);
|
|
2255
|
+
success === null || success === void 0 ? void 0 : success(blob);
|
|
2256
|
+
return [2 /*return*/];
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
function getBlob(url) {
|
|
2262
|
+
return new Promise(function (resolve, reject) {
|
|
2263
|
+
var xhr = new XMLHttpRequest();
|
|
2264
|
+
xhr.open('GET', url, true);
|
|
2265
|
+
xhr.responseType = 'blob';
|
|
2266
|
+
xhr.onload = function () {
|
|
2267
|
+
if (xhr.status === 200) {
|
|
2268
|
+
resolve(xhr.response);
|
|
2269
|
+
}
|
|
2270
|
+
else {
|
|
2271
|
+
reject(new Error("Request failed with status ".concat(xhr.status)));
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
xhr.onerror = function () {
|
|
2275
|
+
reject(new Error('Request failed'));
|
|
2276
|
+
};
|
|
2277
|
+
xhr.send();
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
function save(blob, filename) {
|
|
2281
|
+
var link = document.createElement('a');
|
|
2282
|
+
var body = document.body;
|
|
2283
|
+
link.href = window.URL.createObjectURL(blob);
|
|
2284
|
+
link.download = filename;
|
|
2285
|
+
link.style.display = 'none';
|
|
2286
|
+
body.appendChild(link);
|
|
2287
|
+
link.click();
|
|
2288
|
+
body.removeChild(link);
|
|
2289
|
+
window.URL.revokeObjectURL(link.href);
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2246
2292
|
/**
|
|
2247
2293
|
*
|
|
2248
2294
|
* @param {number} num 倒计时时间
|
|
@@ -2271,6 +2317,21 @@ function useCountDown(num, text) {
|
|
|
2271
2317
|
};
|
|
2272
2318
|
return { countdownText: countdownText, disabled: disabled, send: send };
|
|
2273
2319
|
}
|
|
2320
|
+
function useDownload() {
|
|
2321
|
+
var loading = ref(false);
|
|
2322
|
+
var downloadFile = function (url, filename, success) {
|
|
2323
|
+
var _filename = filename || 'download_' + new Date().getTime();
|
|
2324
|
+
loading.value = true;
|
|
2325
|
+
download(url, _filename, function (blob) {
|
|
2326
|
+
loading.value = false;
|
|
2327
|
+
success === null || success === void 0 ? void 0 : success(blob);
|
|
2328
|
+
});
|
|
2329
|
+
};
|
|
2330
|
+
return {
|
|
2331
|
+
loading: loading,
|
|
2332
|
+
downloadFile: downloadFile
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2274
2335
|
|
|
2275
2336
|
var RecordType;
|
|
2276
2337
|
(function (RecordType) {
|
|
@@ -2735,17 +2796,98 @@ var Tour = /** @class */ (function () {
|
|
|
2735
2796
|
return Tour;
|
|
2736
2797
|
}());
|
|
2737
2798
|
|
|
2799
|
+
var countUp = function (start, end, callback) {
|
|
2800
|
+
var current = start;
|
|
2801
|
+
var run = function () {
|
|
2802
|
+
if (current >= end) {
|
|
2803
|
+
clearInterval(timer);
|
|
2804
|
+
}
|
|
2805
|
+
else if (current >= end - 16 && current < end - 6) {
|
|
2806
|
+
clearInterval(timer);
|
|
2807
|
+
timer = setInterval(run, 90);
|
|
2808
|
+
}
|
|
2809
|
+
else if (current >= end - 6) {
|
|
2810
|
+
clearInterval(timer);
|
|
2811
|
+
timer = setInterval(run, 200);
|
|
2812
|
+
}
|
|
2813
|
+
callback(current++);
|
|
2814
|
+
};
|
|
2815
|
+
var timer = setInterval(run, 16);
|
|
2816
|
+
};
|
|
2817
|
+
// if (!Date.now){
|
|
2818
|
+
// Date.now = function () {
|
|
2819
|
+
// return new Date().getTime();
|
|
2820
|
+
// };
|
|
2821
|
+
// }
|
|
2822
|
+
// (function () {
|
|
2823
|
+
// 'use strict';
|
|
2824
|
+
// var vendors = ['webkit', 'moz'];
|
|
2825
|
+
// for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
|
|
2826
|
+
// var vp = vendors[i];
|
|
2827
|
+
// (window as any)[vp + 'RequestAnimationFrame'];
|
|
2828
|
+
// window.cancelAnimationFrame = (
|
|
2829
|
+
// (window as any)[vp + 'CancelAnimationFrame'] ||
|
|
2830
|
+
// (window as any)[vp + 'CancelRequestAnimationFrame']
|
|
2831
|
+
// )
|
|
2832
|
+
// }
|
|
2833
|
+
// if (
|
|
2834
|
+
// /iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) ||
|
|
2835
|
+
// !window.requestAnimationFrame ||
|
|
2836
|
+
// !window.cancelAnimationFrame
|
|
2837
|
+
// ) {
|
|
2838
|
+
// var lastTime = 0;
|
|
2839
|
+
// window.requestAnimationFrame = function (callback: FrameRequestCallback): any {
|
|
2840
|
+
// var now = Date.now();
|
|
2841
|
+
// var nextTime = Math.max(lastTime + 16, now);
|
|
2842
|
+
// return setTimeout( function () {
|
|
2843
|
+
// callback(lastTime = nextTime);
|
|
2844
|
+
// },nextTime - now);
|
|
2845
|
+
// }
|
|
2846
|
+
// window.cancelAnimationFrame = clearTimeout;
|
|
2847
|
+
// }
|
|
2848
|
+
// }())
|
|
2849
|
+
|
|
2850
|
+
function hasRepeatArray(arr, keys) {
|
|
2851
|
+
var map = new Map();
|
|
2852
|
+
var _loop_1 = function (item) {
|
|
2853
|
+
var val = (keys === null || keys === void 0 ? void 0 : keys.map(function (key) { return item[key]; }).join(',')) || item;
|
|
2854
|
+
if (map.has(val)) {
|
|
2855
|
+
return { value: [true, val.split(',')] };
|
|
2856
|
+
}
|
|
2857
|
+
map.set(val, item);
|
|
2858
|
+
};
|
|
2859
|
+
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
|
|
2860
|
+
var item = arr_1[_i];
|
|
2861
|
+
var state_1 = _loop_1(item);
|
|
2862
|
+
if (typeof state_1 === "object")
|
|
2863
|
+
return state_1.value;
|
|
2864
|
+
}
|
|
2865
|
+
return [false];
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2738
2868
|
/**
|
|
2739
2869
|
* 匹配中文字母数字
|
|
2740
2870
|
*/
|
|
2741
|
-
var
|
|
2871
|
+
var zhLetterNumber = /^[\u4E00-\u9FA5\w]+$/;
|
|
2742
2872
|
/**
|
|
2743
2873
|
* 匹配 IP
|
|
2744
2874
|
*/
|
|
2745
|
-
var
|
|
2875
|
+
var ip = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})$/;
|
|
2746
2876
|
/**
|
|
2747
2877
|
* 匹配手机号
|
|
2748
2878
|
*/
|
|
2749
|
-
var
|
|
2879
|
+
var phone = /^1[3-9]\d{9}$/;
|
|
2880
|
+
/**
|
|
2881
|
+
* 匹配身份证号
|
|
2882
|
+
*/
|
|
2883
|
+
var idCard = /^\d{17}[\dXx]|\d{15}$/;
|
|
2884
|
+
/**
|
|
2885
|
+
* 匹配邮箱
|
|
2886
|
+
*/
|
|
2887
|
+
var email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
|
|
2888
|
+
/**
|
|
2889
|
+
* 匹配 URL
|
|
2890
|
+
*/
|
|
2891
|
+
var url = /^https?:\/\/[^\s/$.?#].[^\s]*$/;
|
|
2750
2892
|
|
|
2751
|
-
export { HAS_FEILD,
|
|
2893
|
+
export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, RecordType, Request, RequestChain, Tour, countUp, dataHandler, debounce, deepMerge, download, email, findTreeDataNode, findTreeDataNodeName, hasRepeatArray, idCard, ip, isMobileDevice, isNull, objectArrayToString, phone, throttle, url, useCountDown, useDownload, zhLetterNumber };
|
package/dist/index.umd.js
CHANGED
|
@@ -341,6 +341,52 @@
|
|
|
341
341
|
return RequestChain;
|
|
342
342
|
}());
|
|
343
343
|
|
|
344
|
+
function download(url, filename, success) {
|
|
345
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
346
|
+
var blob;
|
|
347
|
+
return __generator(this, function (_a) {
|
|
348
|
+
switch (_a.label) {
|
|
349
|
+
case 0: return [4 /*yield*/, getBlob(url)];
|
|
350
|
+
case 1:
|
|
351
|
+
blob = _a.sent();
|
|
352
|
+
save(blob, filename);
|
|
353
|
+
success === null || success === void 0 ? void 0 : success(blob);
|
|
354
|
+
return [2 /*return*/];
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function getBlob(url) {
|
|
360
|
+
return new Promise(function (resolve, reject) {
|
|
361
|
+
var xhr = new XMLHttpRequest();
|
|
362
|
+
xhr.open('GET', url, true);
|
|
363
|
+
xhr.responseType = 'blob';
|
|
364
|
+
xhr.onload = function () {
|
|
365
|
+
if (xhr.status === 200) {
|
|
366
|
+
resolve(xhr.response);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
reject(new Error("Request failed with status ".concat(xhr.status)));
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
xhr.onerror = function () {
|
|
373
|
+
reject(new Error('Request failed'));
|
|
374
|
+
};
|
|
375
|
+
xhr.send();
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function save(blob, filename) {
|
|
379
|
+
var link = document.createElement('a');
|
|
380
|
+
var body = document.body;
|
|
381
|
+
link.href = window.URL.createObjectURL(blob);
|
|
382
|
+
link.download = filename;
|
|
383
|
+
link.style.display = 'none';
|
|
384
|
+
body.appendChild(link);
|
|
385
|
+
link.click();
|
|
386
|
+
body.removeChild(link);
|
|
387
|
+
window.URL.revokeObjectURL(link.href);
|
|
388
|
+
}
|
|
389
|
+
|
|
344
390
|
/**
|
|
345
391
|
*
|
|
346
392
|
* @param {number} num 倒计时时间
|
|
@@ -369,6 +415,21 @@
|
|
|
369
415
|
};
|
|
370
416
|
return { countdownText: countdownText, disabled: disabled, send: send };
|
|
371
417
|
}
|
|
418
|
+
function useDownload() {
|
|
419
|
+
var loading = vue.ref(false);
|
|
420
|
+
var downloadFile = function (url, filename, success) {
|
|
421
|
+
var _filename = filename || 'download_' + new Date().getTime();
|
|
422
|
+
loading.value = true;
|
|
423
|
+
download(url, _filename, function (blob) {
|
|
424
|
+
loading.value = false;
|
|
425
|
+
success === null || success === void 0 ? void 0 : success(blob);
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
loading: loading,
|
|
430
|
+
downloadFile: downloadFile
|
|
431
|
+
};
|
|
432
|
+
}
|
|
372
433
|
|
|
373
434
|
exports.RecordType = void 0;
|
|
374
435
|
(function (RecordType) {
|
|
@@ -912,7 +973,7 @@
|
|
|
912
973
|
if (isOpen)
|
|
913
974
|
ws.send(JSON.stringify(data));
|
|
914
975
|
}
|
|
915
|
-
function
|
|
976
|
+
function useOnMessage(ws, callback) {
|
|
916
977
|
try {
|
|
917
978
|
ws.onmessage = function (e) {
|
|
918
979
|
var data = JSON.parse(e.data);
|
|
@@ -923,48 +984,136 @@
|
|
|
923
984
|
console.error(error);
|
|
924
985
|
}
|
|
925
986
|
}
|
|
926
|
-
function
|
|
987
|
+
function useClose(ws, code, message) {
|
|
927
988
|
code = code || 1000;
|
|
928
989
|
message = message || 'connection closed by client';
|
|
929
990
|
ws.close(code, message);
|
|
930
991
|
}
|
|
931
992
|
|
|
993
|
+
var countUp = function (start, end, callback) {
|
|
994
|
+
var current = start;
|
|
995
|
+
var run = function () {
|
|
996
|
+
if (current >= end) {
|
|
997
|
+
clearInterval(timer);
|
|
998
|
+
}
|
|
999
|
+
else if (current >= end - 16 && current < end - 6) {
|
|
1000
|
+
clearInterval(timer);
|
|
1001
|
+
timer = setInterval(run, 90);
|
|
1002
|
+
}
|
|
1003
|
+
else if (current >= end - 6) {
|
|
1004
|
+
clearInterval(timer);
|
|
1005
|
+
timer = setInterval(run, 200);
|
|
1006
|
+
}
|
|
1007
|
+
callback(current++);
|
|
1008
|
+
};
|
|
1009
|
+
var timer = setInterval(run, 16);
|
|
1010
|
+
};
|
|
1011
|
+
// if (!Date.now){
|
|
1012
|
+
// Date.now = function () {
|
|
1013
|
+
// return new Date().getTime();
|
|
1014
|
+
// };
|
|
1015
|
+
// }
|
|
1016
|
+
// (function () {
|
|
1017
|
+
// 'use strict';
|
|
1018
|
+
// var vendors = ['webkit', 'moz'];
|
|
1019
|
+
// for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
|
|
1020
|
+
// var vp = vendors[i];
|
|
1021
|
+
// (window as any)[vp + 'RequestAnimationFrame'];
|
|
1022
|
+
// window.cancelAnimationFrame = (
|
|
1023
|
+
// (window as any)[vp + 'CancelAnimationFrame'] ||
|
|
1024
|
+
// (window as any)[vp + 'CancelRequestAnimationFrame']
|
|
1025
|
+
// )
|
|
1026
|
+
// }
|
|
1027
|
+
// if (
|
|
1028
|
+
// /iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) ||
|
|
1029
|
+
// !window.requestAnimationFrame ||
|
|
1030
|
+
// !window.cancelAnimationFrame
|
|
1031
|
+
// ) {
|
|
1032
|
+
// var lastTime = 0;
|
|
1033
|
+
// window.requestAnimationFrame = function (callback: FrameRequestCallback): any {
|
|
1034
|
+
// var now = Date.now();
|
|
1035
|
+
// var nextTime = Math.max(lastTime + 16, now);
|
|
1036
|
+
// return setTimeout( function () {
|
|
1037
|
+
// callback(lastTime = nextTime);
|
|
1038
|
+
// },nextTime - now);
|
|
1039
|
+
// }
|
|
1040
|
+
// window.cancelAnimationFrame = clearTimeout;
|
|
1041
|
+
// }
|
|
1042
|
+
// }())
|
|
1043
|
+
|
|
1044
|
+
function hasRepeatArray(arr, keys) {
|
|
1045
|
+
var map = new Map();
|
|
1046
|
+
var _loop_1 = function (item) {
|
|
1047
|
+
var val = (keys === null || keys === void 0 ? void 0 : keys.map(function (key) { return item[key]; }).join(',')) || item;
|
|
1048
|
+
if (map.has(val)) {
|
|
1049
|
+
return { value: [true, val.split(',')] };
|
|
1050
|
+
}
|
|
1051
|
+
map.set(val, item);
|
|
1052
|
+
};
|
|
1053
|
+
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
|
|
1054
|
+
var item = arr_1[_i];
|
|
1055
|
+
var state_1 = _loop_1(item);
|
|
1056
|
+
if (typeof state_1 === "object")
|
|
1057
|
+
return state_1.value;
|
|
1058
|
+
}
|
|
1059
|
+
return [false];
|
|
1060
|
+
}
|
|
1061
|
+
|
|
932
1062
|
/**
|
|
933
1063
|
* 匹配中文字母数字
|
|
934
1064
|
*/
|
|
935
|
-
var
|
|
1065
|
+
var zhLetterNumber = /^[\u4E00-\u9FA5\w]+$/;
|
|
936
1066
|
/**
|
|
937
1067
|
* 匹配 IP
|
|
938
1068
|
*/
|
|
939
|
-
var
|
|
1069
|
+
var ip = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})$/;
|
|
940
1070
|
/**
|
|
941
1071
|
* 匹配手机号
|
|
942
1072
|
*/
|
|
943
|
-
var
|
|
1073
|
+
var phone = /^1[3-9]\d{9}$/;
|
|
1074
|
+
/**
|
|
1075
|
+
* 匹配身份证号
|
|
1076
|
+
*/
|
|
1077
|
+
var idCard = /^\d{17}[\dXx]|\d{15}$/;
|
|
1078
|
+
/**
|
|
1079
|
+
* 匹配邮箱
|
|
1080
|
+
*/
|
|
1081
|
+
var email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
|
|
1082
|
+
/**
|
|
1083
|
+
* 匹配 URL
|
|
1084
|
+
*/
|
|
1085
|
+
var url = /^https?:\/\/[^\s/$.?#].[^\s]*$/;
|
|
944
1086
|
|
|
945
|
-
exports.IP = IP;
|
|
946
1087
|
exports.InputLegalityValidate = InputLegalityValidate;
|
|
947
1088
|
exports.InputLengthValidate = InputLengthValidate;
|
|
948
1089
|
exports.Mask = Mask;
|
|
949
|
-
exports.PHONE = PHONE;
|
|
950
1090
|
exports.Request = Request;
|
|
951
1091
|
exports.RequestChain = RequestChain;
|
|
952
1092
|
exports.Tour = Tour;
|
|
953
|
-
exports.
|
|
1093
|
+
exports.countUp = countUp;
|
|
954
1094
|
exports.createWebSocket = createWebSocket;
|
|
955
1095
|
exports.dataHandler = dataHandler;
|
|
956
1096
|
exports.debounce = debounce;
|
|
957
1097
|
exports.deepMerge = deepMerge;
|
|
1098
|
+
exports.download = download;
|
|
1099
|
+
exports.email = email;
|
|
958
1100
|
exports.findTreeDataNode = findTreeDataNode;
|
|
959
1101
|
exports.findTreeDataNodeName = findTreeDataNodeName;
|
|
960
1102
|
exports.getState = getState;
|
|
1103
|
+
exports.hasRepeatArray = hasRepeatArray;
|
|
1104
|
+
exports.idCard = idCard;
|
|
1105
|
+
exports.ip = ip;
|
|
961
1106
|
exports.isMobileDevice = isMobileDevice;
|
|
962
1107
|
exports.isNull = isNull;
|
|
963
1108
|
exports.objectArrayToString = objectArrayToString;
|
|
1109
|
+
exports.phone = phone;
|
|
964
1110
|
exports.throttle = throttle;
|
|
1111
|
+
exports.url = url;
|
|
1112
|
+
exports.useClose = useClose;
|
|
965
1113
|
exports.useCountDown = useCountDown;
|
|
1114
|
+
exports.useDownload = useDownload;
|
|
1115
|
+
exports.useOnMessage = useOnMessage;
|
|
966
1116
|
exports.useSendMessage = useSendMessage;
|
|
967
|
-
exports.
|
|
968
|
-
exports.useWebSocketMessage = useWebSocketMessage;
|
|
1117
|
+
exports.zhLetterNumber = zhLetterNumber;
|
|
969
1118
|
|
|
970
1119
|
}));
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 匹配中文字母数字
|
|
3
3
|
*/
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const zhLetterNumber: RegExp;
|
|
5
5
|
/**
|
|
6
6
|
* 匹配 IP
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const ip: RegExp;
|
|
9
9
|
/**
|
|
10
10
|
* 匹配手机号
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const phone: RegExp;
|
|
13
|
+
/**
|
|
14
|
+
* 匹配身份证号
|
|
15
|
+
*/
|
|
16
|
+
export declare const idCard: RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* 匹配邮箱
|
|
19
|
+
*/
|
|
20
|
+
export declare const email: RegExp;
|
|
21
|
+
/**
|
|
22
|
+
* 匹配 URL
|
|
23
|
+
*/
|
|
24
|
+
export declare const url: RegExp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasRepeatArray(arr: any[], keys?: string[]): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function download(url: string, filename: string, success?: (blob: Blob) => void): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const countUp: (start: number, end: number, callback: (current: number) => void) => void;
|
|
@@ -12,4 +12,8 @@ interface CountDown {
|
|
|
12
12
|
* @description 发送验证码倒计时
|
|
13
13
|
*/
|
|
14
14
|
export declare function useCountDown(num: number, text?: string): CountDown;
|
|
15
|
+
export declare function useDownload(): {
|
|
16
|
+
loading: Ref<boolean, boolean>;
|
|
17
|
+
downloadFile: (url: string, filename?: string, success?: (blob: Blob) => void) => void;
|
|
18
|
+
};
|
|
15
19
|
export {};
|
package/dist/types/utils/ws.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ interface WebSocketConfig {
|
|
|
9
9
|
export declare function createWebSocket(url: string, config: WebSocketConfig | null, onOpen?: Function | null): WebSocket;
|
|
10
10
|
export declare function getState(ws: WebSocket, type: WebSocketState): boolean;
|
|
11
11
|
export declare function useSendMessage(ws: WebSocket, data: any): void;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
12
|
+
export declare function useOnMessage(ws: WebSocket, callback: Function): void;
|
|
13
|
+
export declare function useClose(ws: WebSocket, code?: number, message?: string): void;
|
|
14
14
|
export {};
|
|
@@ -148,7 +148,7 @@ function useSendMessage(ws, data) {
|
|
|
148
148
|
if (isOpen)
|
|
149
149
|
ws.send(JSON.stringify(data));
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function useOnMessage(ws, callback) {
|
|
152
152
|
try {
|
|
153
153
|
ws.onmessage = function (e) {
|
|
154
154
|
var data = JSON.parse(e.data);
|
|
@@ -159,10 +159,10 @@ function useWebSocketMessage(ws, callback) {
|
|
|
159
159
|
console.error(error);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function useClose(ws, code, message) {
|
|
163
163
|
code = code || 1000;
|
|
164
164
|
message = message || 'connection closed by client';
|
|
165
165
|
ws.close(code, message);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
export { __assign as _, __awaiter as a, __generator as b, createWebSocket as c,
|
|
168
|
+
export { __assign as _, __awaiter as a, __generator as b, createWebSocket as c, useOnMessage as d, useClose as e, getState as g, useSendMessage as u };
|
package/dist/ws.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface WebSocketConfig {
|
|
|
9
9
|
declare function createWebSocket(url: string, config: WebSocketConfig | null, onOpen?: Function | null): WebSocket;
|
|
10
10
|
declare function getState(ws: WebSocket, type: WebSocketState): boolean;
|
|
11
11
|
declare function useSendMessage(ws: WebSocket, data: any): void;
|
|
12
|
-
declare function
|
|
13
|
-
declare function
|
|
12
|
+
declare function useOnMessage(ws: WebSocket, callback: Function): void;
|
|
13
|
+
declare function useClose(ws: WebSocket, code?: number, message?: string): void;
|
|
14
14
|
|
|
15
|
-
export { createWebSocket, getState,
|
|
15
|
+
export { createWebSocket, getState, useClose, useOnMessage, useSendMessage };
|
package/dist/ws.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as createWebSocket, g as getState,
|
|
1
|
+
export { c as createWebSocket, g as getState, e as useClose, d as useOnMessage, u as useSendMessage } from './ws-DGDUMiR9.js';
|
package/dist/ws.umd.js
CHANGED
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
if (isOpen)
|
|
117
117
|
ws.send(JSON.stringify(data));
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function useOnMessage(ws, callback) {
|
|
120
120
|
try {
|
|
121
121
|
ws.onmessage = function (e) {
|
|
122
122
|
var data = JSON.parse(e.data);
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
console.error(error);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function useClose(ws, code, message) {
|
|
131
131
|
code = code || 1000;
|
|
132
132
|
message = message || 'connection closed by client';
|
|
133
133
|
ws.close(code, message);
|
|
@@ -135,8 +135,8 @@
|
|
|
135
135
|
|
|
136
136
|
exports.createWebSocket = createWebSocket;
|
|
137
137
|
exports.getState = getState;
|
|
138
|
+
exports.useClose = useClose;
|
|
139
|
+
exports.useOnMessage = useOnMessage;
|
|
138
140
|
exports.useSendMessage = useSendMessage;
|
|
139
|
-
exports.useWebSocketClose = useWebSocketClose;
|
|
140
|
-
exports.useWebSocketMessage = useWebSocketMessage;
|
|
141
141
|
|
|
142
142
|
}));
|