@whitesev/utils 2.7.1 → 2.7.2
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.amd.js +168 -212
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +168 -212
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +168 -212
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +168 -212
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +168 -212
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +168 -212
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/ColorConversion.d.ts +3 -8
- package/dist/types/src/Dictionary.d.ts +21 -14
- package/dist/types/src/GBKEncoder.d.ts +1 -2
- package/dist/types/src/Hooks.d.ts +1 -2
- package/dist/types/src/Httpx.d.ts +45 -46
- package/dist/types/src/LockFunction.d.ts +1 -2
- package/dist/types/src/Log.d.ts +1 -2
- package/dist/types/src/Progress.d.ts +1 -2
- package/dist/types/src/UtilsGMMenu.d.ts +1 -2
- package/dist/types/src/WindowApi.d.ts +1 -2
- package/dist/types/src/indexedDB.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +73 -67
- package/dist/types/src/types/env.d.ts +2 -0
- package/dist/types/src/types/global.d.ts +3 -0
- package/package.json +1 -1
- package/src/ColorConversion.ts +14 -25
- package/src/DOMUtils.ts +14 -16
- package/src/Dictionary.ts +39 -35
- package/src/GBKEncoder.ts +8 -12
- package/src/Hooks.ts +1 -3
- package/src/Httpx.ts +194 -174
- package/src/LockFunction.ts +3 -3
- package/src/Log.ts +1 -3
- package/src/Progress.ts +1 -3
- package/src/TryCatch.ts +4 -4
- package/src/Utils.ts +27 -43
- package/src/UtilsGMMenu.ts +19 -22
- package/src/Vue.ts +4 -7
- package/src/WindowApi.ts +2 -5
- package/src/indexedDB.ts +8 -8
- package/src/types/Httpx.d.ts +73 -67
- package/src/types/env.d.ts +2 -0
- package/src/types/global.d.ts +3 -0
package/dist/index.esm.js
CHANGED
|
@@ -15,14 +15,13 @@ class ColorConversion {
|
|
|
15
15
|
/**
|
|
16
16
|
* 16进制颜色转rgba
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
19
19
|
* @param hex
|
|
20
20
|
* @param opacity
|
|
21
21
|
*/
|
|
22
22
|
hexToRgba(hex, opacity) {
|
|
23
23
|
if (!this.isHex(hex)) {
|
|
24
|
-
|
|
25
|
-
throw new TypeError("输入错误的hex", hex);
|
|
24
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
26
25
|
}
|
|
27
26
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
28
27
|
? "rgba(" +
|
|
@@ -39,19 +38,16 @@ class ColorConversion {
|
|
|
39
38
|
/**
|
|
40
39
|
* hex转rgb
|
|
41
40
|
* @param str
|
|
42
|
-
* @returns
|
|
43
41
|
*/
|
|
44
42
|
hexToRgb(str) {
|
|
45
43
|
if (!this.isHex(str)) {
|
|
46
|
-
|
|
47
|
-
throw new TypeError("输入错误的hex", str);
|
|
44
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
48
45
|
}
|
|
49
46
|
/* replace替换查找的到的字符串 */
|
|
50
47
|
str = str.replace("#", "");
|
|
51
48
|
/* match得到查询数组 */
|
|
52
49
|
let hxs = str.match(/../g);
|
|
53
50
|
for (let index = 0; index < 3; index++) {
|
|
54
|
-
// @ts-ignore
|
|
55
51
|
hxs[index] = parseInt(hxs[index], 16);
|
|
56
52
|
}
|
|
57
53
|
return hxs;
|
|
@@ -61,7 +57,6 @@ class ColorConversion {
|
|
|
61
57
|
* @param redValue
|
|
62
58
|
* @param greenValue
|
|
63
59
|
* @param blueValue
|
|
64
|
-
* @returns
|
|
65
60
|
*/
|
|
66
61
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
67
62
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -84,38 +79,30 @@ class ColorConversion {
|
|
|
84
79
|
* 获取颜色变暗或亮
|
|
85
80
|
* @param color 颜色
|
|
86
81
|
* @param level 0~1.0
|
|
87
|
-
* @returns
|
|
88
82
|
*/
|
|
89
83
|
getDarkColor(color, level) {
|
|
90
84
|
if (!this.isHex(color)) {
|
|
91
|
-
|
|
92
|
-
throw new TypeError("输入错误的hex", color);
|
|
85
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
93
86
|
}
|
|
94
87
|
let rgbc = this.hexToRgb(color);
|
|
95
88
|
for (let index = 0; index < 3; index++) {
|
|
96
|
-
// @ts-ignore
|
|
97
89
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
98
90
|
}
|
|
99
|
-
// @ts-ignore
|
|
100
91
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
101
92
|
}
|
|
102
93
|
/**
|
|
103
94
|
* 获取颜色变亮
|
|
104
95
|
* @param color 颜色
|
|
105
96
|
* @param level 0~1.0
|
|
106
|
-
* @returns
|
|
107
97
|
*/
|
|
108
98
|
getLightColor(color, level) {
|
|
109
99
|
if (!this.isHex(color)) {
|
|
110
|
-
|
|
111
|
-
throw new TypeError("输入错误的hex", color);
|
|
100
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
112
101
|
}
|
|
113
102
|
let rgbc = this.hexToRgb(color);
|
|
114
103
|
for (let index = 0; index < 3; index++) {
|
|
115
|
-
// @ts-ignore
|
|
116
104
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
117
105
|
}
|
|
118
|
-
// @ts-ignore
|
|
119
106
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
120
107
|
}
|
|
121
108
|
}
|
|
@@ -203,20 +190,20 @@ class GBKEncoder {
|
|
|
203
190
|
* @param str
|
|
204
191
|
*/
|
|
205
192
|
decode(str) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
194
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
195
|
+
// let gbk = true;
|
|
196
|
+
let utf = true;
|
|
197
|
+
const that = this;
|
|
211
198
|
while (utf) {
|
|
212
199
|
let gbkMatch = str.match(GBKMatcher);
|
|
213
200
|
let utfMatch = str.match(UTFMatcher);
|
|
201
|
+
// gbk = Boolean(gbkMatch);
|
|
214
202
|
utf = Boolean(utfMatch);
|
|
215
203
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
216
204
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
217
205
|
}
|
|
218
206
|
else {
|
|
219
|
-
// @ts-ignore
|
|
220
207
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
221
208
|
}
|
|
222
209
|
}
|
|
@@ -247,7 +234,6 @@ const TryCatch = function (...args) {
|
|
|
247
234
|
* @param handler
|
|
248
235
|
*/
|
|
249
236
|
error(handler) {
|
|
250
|
-
// @ts-ignore
|
|
251
237
|
handleError = handler;
|
|
252
238
|
return TryCatchCore;
|
|
253
239
|
},
|
|
@@ -262,8 +248,9 @@ const TryCatch = function (...args) {
|
|
|
262
248
|
callbackFunction = callback;
|
|
263
249
|
context = __context__ || this;
|
|
264
250
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
265
|
-
|
|
266
|
-
|
|
251
|
+
return result !== void 0
|
|
252
|
+
? result
|
|
253
|
+
: TryCatchCore;
|
|
267
254
|
},
|
|
268
255
|
};
|
|
269
256
|
/**
|
|
@@ -1947,25 +1934,24 @@ class GMMenu {
|
|
|
1947
1934
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1948
1935
|
/** 油猴菜单上显示的文本 */
|
|
1949
1936
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1950
|
-
//
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
});
|
|
1937
|
+
// const GMMenuOptions = {
|
|
1938
|
+
// /**
|
|
1939
|
+
// * 菜单的id
|
|
1940
|
+
// */
|
|
1941
|
+
// id: menuOption.id,
|
|
1942
|
+
// /**
|
|
1943
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1944
|
+
// */
|
|
1945
|
+
// autoClose: menuOption.autoClose,
|
|
1946
|
+
// /**
|
|
1947
|
+
// * 菜单项的可选访问键
|
|
1948
|
+
// */
|
|
1949
|
+
// accessKey: menuOption.accessKey,
|
|
1950
|
+
// /**
|
|
1951
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1952
|
+
// */
|
|
1953
|
+
// title: menuOption.title,
|
|
1954
|
+
// };
|
|
1969
1955
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1970
1956
|
menuOption.autoReload =
|
|
1971
1957
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2543,7 +2529,9 @@ class Httpx {
|
|
|
2543
2529
|
* 对请求的参数进行合并处理
|
|
2544
2530
|
*/
|
|
2545
2531
|
handleBeforeRequestOptionArgs(...args) {
|
|
2546
|
-
let option = {
|
|
2532
|
+
let option = {
|
|
2533
|
+
url: void 0,
|
|
2534
|
+
};
|
|
2547
2535
|
if (typeof args[0] === "string") {
|
|
2548
2536
|
/* 传入的是url,转为配置 */
|
|
2549
2537
|
let url = args[0];
|
|
@@ -2567,7 +2555,7 @@ class Httpx {
|
|
|
2567
2555
|
* @param method 当前请求方法,默认get
|
|
2568
2556
|
* @param userRequestOption 用户的请求配置
|
|
2569
2557
|
* @param resolve promise回调
|
|
2570
|
-
* @param reject 抛出错误回调
|
|
2558
|
+
* @param reject promise抛出错误回调
|
|
2571
2559
|
*/
|
|
2572
2560
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2573
2561
|
let that = this;
|
|
@@ -2625,25 +2613,25 @@ class Httpx {
|
|
|
2625
2613
|
password: userRequestOption.password ||
|
|
2626
2614
|
this.context.#defaultRequestOption.password,
|
|
2627
2615
|
onabort(...args) {
|
|
2628
|
-
that.context.
|
|
2616
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2629
2617
|
},
|
|
2630
2618
|
onerror(...args) {
|
|
2631
|
-
that.context.
|
|
2619
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2632
2620
|
},
|
|
2633
2621
|
onloadstart(...args) {
|
|
2634
|
-
that.context.
|
|
2622
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2635
2623
|
},
|
|
2636
2624
|
onprogress(...args) {
|
|
2637
|
-
that.context.
|
|
2625
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2638
2626
|
},
|
|
2639
2627
|
onreadystatechange(...args) {
|
|
2640
|
-
that.context.
|
|
2628
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2641
2629
|
},
|
|
2642
2630
|
ontimeout(...args) {
|
|
2643
|
-
that.context.
|
|
2631
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2644
2632
|
},
|
|
2645
2633
|
onload(...args) {
|
|
2646
|
-
that.context.
|
|
2634
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2647
2635
|
},
|
|
2648
2636
|
};
|
|
2649
2637
|
// 补全allowInterceptConfig参数
|
|
@@ -2755,7 +2743,6 @@ class Httpx {
|
|
|
2755
2743
|
else if (typeof requestOption.data === "object") {
|
|
2756
2744
|
isHandler = true;
|
|
2757
2745
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2758
|
-
// @ts-ignore
|
|
2759
2746
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2760
2747
|
urlSearch = searchParams.toString();
|
|
2761
2748
|
}
|
|
@@ -2810,9 +2797,7 @@ class Httpx {
|
|
|
2810
2797
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2811
2798
|
// application/x-www-form-urlencoded
|
|
2812
2799
|
if (typeof requestOption.data === "object") {
|
|
2813
|
-
requestOption.data = new URLSearchParams(
|
|
2814
|
-
// @ts-ignore
|
|
2815
|
-
requestOption.data).toString();
|
|
2800
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2816
2801
|
}
|
|
2817
2802
|
}
|
|
2818
2803
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2832,7 +2817,7 @@ class Httpx {
|
|
|
2832
2817
|
},
|
|
2833
2818
|
/**
|
|
2834
2819
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2835
|
-
* @param option
|
|
2820
|
+
* @param option 请求配置
|
|
2836
2821
|
*/
|
|
2837
2822
|
removeRequestNullOption(option) {
|
|
2838
2823
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2844,13 +2829,13 @@ class Httpx {
|
|
|
2844
2829
|
}
|
|
2845
2830
|
});
|
|
2846
2831
|
if (commonUtil.isNull(option.url)) {
|
|
2847
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2832
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2848
2833
|
}
|
|
2849
2834
|
return option;
|
|
2850
2835
|
},
|
|
2851
2836
|
/**
|
|
2852
2837
|
* 处理fetch的配置
|
|
2853
|
-
* @param option
|
|
2838
|
+
* @param option 请求配置
|
|
2854
2839
|
*/
|
|
2855
2840
|
handleFetchOption(option) {
|
|
2856
2841
|
/**
|
|
@@ -2903,21 +2888,21 @@ class Httpx {
|
|
|
2903
2888
|
};
|
|
2904
2889
|
},
|
|
2905
2890
|
};
|
|
2906
|
-
|
|
2891
|
+
HttpxResponseCallBack = {
|
|
2907
2892
|
context: this,
|
|
2908
2893
|
/**
|
|
2909
2894
|
* onabort请求被取消-触发
|
|
2910
2895
|
* @param details 配置
|
|
2911
|
-
* @param resolve 回调
|
|
2912
|
-
* @param reject
|
|
2896
|
+
* @param resolve promise回调
|
|
2897
|
+
* @param reject promise抛出错误回调
|
|
2913
2898
|
* @param argsResult 返回的参数列表
|
|
2914
2899
|
*/
|
|
2915
2900
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2916
2901
|
// console.log(argsResult);
|
|
2917
|
-
if (
|
|
2902
|
+
if (typeof details?.onabort === "function") {
|
|
2918
2903
|
details.onabort.apply(this, argsResult);
|
|
2919
2904
|
}
|
|
2920
|
-
else if (
|
|
2905
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2921
2906
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2922
2907
|
}
|
|
2923
2908
|
let response = argsResult;
|
|
@@ -2926,11 +2911,11 @@ class Httpx {
|
|
|
2926
2911
|
}
|
|
2927
2912
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2928
2913
|
type: "onabort",
|
|
2929
|
-
error: new
|
|
2914
|
+
error: new Error("request canceled"),
|
|
2930
2915
|
response: null,
|
|
2931
2916
|
details: details,
|
|
2932
2917
|
})) == null) {
|
|
2933
|
-
// reject(new
|
|
2918
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2934
2919
|
return;
|
|
2935
2920
|
}
|
|
2936
2921
|
resolve({
|
|
@@ -2943,93 +2928,83 @@ class Httpx {
|
|
|
2943
2928
|
});
|
|
2944
2929
|
},
|
|
2945
2930
|
/**
|
|
2946
|
-
*
|
|
2931
|
+
* ontimeout请求超时-触发
|
|
2947
2932
|
* @param details 配置
|
|
2948
2933
|
* @param resolve 回调
|
|
2949
2934
|
* @param reject 抛出错误
|
|
2950
2935
|
* @param argsResult 返回的参数列表
|
|
2951
2936
|
*/
|
|
2952
|
-
async
|
|
2937
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2953
2938
|
// console.log(argsResult);
|
|
2954
|
-
if ("
|
|
2955
|
-
|
|
2939
|
+
if (typeof details?.ontimeout === "function") {
|
|
2940
|
+
// 执行配置中的ontime回调
|
|
2941
|
+
details.ontimeout.apply(this, argsResult);
|
|
2956
2942
|
}
|
|
2957
|
-
else if (
|
|
2958
|
-
|
|
2943
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2944
|
+
// 执行默认配置的ontime回调
|
|
2945
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2959
2946
|
}
|
|
2947
|
+
// 获取响应结果
|
|
2960
2948
|
let response = argsResult;
|
|
2961
2949
|
if (response.length) {
|
|
2962
2950
|
response = response[0];
|
|
2963
2951
|
}
|
|
2952
|
+
// 执行错误回调的钩子
|
|
2964
2953
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2965
|
-
type: "
|
|
2966
|
-
error: new
|
|
2954
|
+
type: "ontimeout",
|
|
2955
|
+
error: new Error("request timeout"),
|
|
2967
2956
|
response: response,
|
|
2968
2957
|
details: details,
|
|
2969
2958
|
})) == null) {
|
|
2970
|
-
// reject(new
|
|
2959
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2971
2960
|
return;
|
|
2972
2961
|
}
|
|
2973
2962
|
resolve({
|
|
2974
2963
|
data: response,
|
|
2975
2964
|
details: details,
|
|
2976
|
-
msg: "
|
|
2965
|
+
msg: "请求超时",
|
|
2977
2966
|
status: false,
|
|
2978
|
-
statusCode:
|
|
2979
|
-
type: "
|
|
2967
|
+
statusCode: 0,
|
|
2968
|
+
type: "ontimeout",
|
|
2980
2969
|
});
|
|
2981
2970
|
},
|
|
2982
2971
|
/**
|
|
2983
|
-
*
|
|
2972
|
+
* onerror请求异常-触发
|
|
2984
2973
|
* @param details 配置
|
|
2985
2974
|
* @param resolve 回调
|
|
2986
2975
|
* @param reject 抛出错误
|
|
2987
2976
|
* @param argsResult 返回的参数列表
|
|
2988
2977
|
*/
|
|
2989
|
-
async
|
|
2978
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2990
2979
|
// console.log(argsResult);
|
|
2991
|
-
if ("
|
|
2992
|
-
details.
|
|
2980
|
+
if (typeof details?.onerror === "function") {
|
|
2981
|
+
details.onerror.apply(this, argsResult);
|
|
2993
2982
|
}
|
|
2994
|
-
else if (
|
|
2995
|
-
this.context.#defaultRequestOption.
|
|
2983
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2984
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
2996
2985
|
}
|
|
2997
2986
|
let response = argsResult;
|
|
2998
2987
|
if (response.length) {
|
|
2999
2988
|
response = response[0];
|
|
3000
2989
|
}
|
|
3001
2990
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
3002
|
-
type: "
|
|
3003
|
-
error: new
|
|
3004
|
-
response:
|
|
2991
|
+
type: "onerror",
|
|
2992
|
+
error: new Error("request error"),
|
|
2993
|
+
response: response,
|
|
3005
2994
|
details: details,
|
|
3006
2995
|
})) == null) {
|
|
3007
|
-
// reject(new
|
|
2996
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3008
2997
|
return;
|
|
3009
2998
|
}
|
|
3010
2999
|
resolve({
|
|
3011
3000
|
data: response,
|
|
3012
3001
|
details: details,
|
|
3013
|
-
msg: "
|
|
3002
|
+
msg: "请求异常",
|
|
3014
3003
|
status: false,
|
|
3015
|
-
statusCode:
|
|
3016
|
-
type: "
|
|
3004
|
+
statusCode: response["status"],
|
|
3005
|
+
type: "onerror",
|
|
3017
3006
|
});
|
|
3018
3007
|
},
|
|
3019
|
-
/**
|
|
3020
|
-
* onloadstart请求开始-触发
|
|
3021
|
-
* @param details 配置
|
|
3022
|
-
* @param argsResult 返回的参数列表
|
|
3023
|
-
*/
|
|
3024
|
-
onLoadStart(details, argsResult) {
|
|
3025
|
-
// console.log(argsResult);
|
|
3026
|
-
if ("onloadstart" in details) {
|
|
3027
|
-
details.onloadstart.apply(this, argsResult);
|
|
3028
|
-
}
|
|
3029
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3030
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3031
|
-
}
|
|
3032
|
-
},
|
|
3033
3008
|
/**
|
|
3034
3009
|
* onload加载完毕-触发
|
|
3035
3010
|
* @param details 请求的配置
|
|
@@ -3109,7 +3084,7 @@ class Httpx {
|
|
|
3109
3084
|
/* 状态码2xx都是成功的 */
|
|
3110
3085
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3111
3086
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3112
|
-
// reject(new
|
|
3087
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3113
3088
|
return;
|
|
3114
3089
|
}
|
|
3115
3090
|
resolve({
|
|
@@ -3122,21 +3097,21 @@ class Httpx {
|
|
|
3122
3097
|
});
|
|
3123
3098
|
}
|
|
3124
3099
|
else {
|
|
3125
|
-
this.context.
|
|
3100
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3126
3101
|
}
|
|
3127
3102
|
},
|
|
3128
3103
|
/**
|
|
3129
|
-
*
|
|
3104
|
+
* onloadstart请求开始-触发
|
|
3130
3105
|
* @param details 配置
|
|
3131
3106
|
* @param argsResult 返回的参数列表
|
|
3132
3107
|
*/
|
|
3133
|
-
|
|
3108
|
+
onLoadStart(details, argsResult) {
|
|
3134
3109
|
// console.log(argsResult);
|
|
3135
|
-
if ("
|
|
3136
|
-
details.
|
|
3110
|
+
if (typeof details?.onloadstart === "function") {
|
|
3111
|
+
details.onloadstart.apply(this, argsResult);
|
|
3137
3112
|
}
|
|
3138
|
-
else if (
|
|
3139
|
-
this.context.#defaultRequestOption.
|
|
3113
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3114
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3140
3115
|
}
|
|
3141
3116
|
},
|
|
3142
3117
|
/**
|
|
@@ -3146,13 +3121,28 @@ class Httpx {
|
|
|
3146
3121
|
*/
|
|
3147
3122
|
onReadyStateChange(details, argsResult) {
|
|
3148
3123
|
// console.log(argsResult);
|
|
3149
|
-
if (
|
|
3124
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3150
3125
|
details.onreadystatechange.apply(this, argsResult);
|
|
3151
3126
|
}
|
|
3152
|
-
else if (
|
|
3127
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3128
|
+
"function") {
|
|
3153
3129
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3154
3130
|
}
|
|
3155
3131
|
},
|
|
3132
|
+
/**
|
|
3133
|
+
* onprogress上传进度-触发
|
|
3134
|
+
* @param details 配置
|
|
3135
|
+
* @param argsResult 返回的参数列表
|
|
3136
|
+
*/
|
|
3137
|
+
onProgress(details, argsResult) {
|
|
3138
|
+
// console.log(argsResult);
|
|
3139
|
+
if (typeof details?.onprogress === "function") {
|
|
3140
|
+
details.onprogress.apply(this, argsResult);
|
|
3141
|
+
}
|
|
3142
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3143
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3144
|
+
}
|
|
3145
|
+
},
|
|
3156
3146
|
};
|
|
3157
3147
|
HttpxRequest = {
|
|
3158
3148
|
context: this,
|
|
@@ -3202,15 +3192,12 @@ class Httpx {
|
|
|
3202
3192
|
isFetch: true,
|
|
3203
3193
|
finalUrl: fetchResponse.url,
|
|
3204
3194
|
readyState: 4,
|
|
3205
|
-
// @ts-ignore
|
|
3206
3195
|
status: fetchResponse.status,
|
|
3207
3196
|
statusText: fetchResponse.statusText,
|
|
3208
|
-
|
|
3209
|
-
response: void 0,
|
|
3197
|
+
response: "",
|
|
3210
3198
|
responseFetchHeaders: fetchResponse.headers,
|
|
3211
3199
|
responseHeaders: "",
|
|
3212
|
-
|
|
3213
|
-
responseText: void 0,
|
|
3200
|
+
responseText: "",
|
|
3214
3201
|
responseType: option.responseType,
|
|
3215
3202
|
responseXML: void 0,
|
|
3216
3203
|
};
|
|
@@ -3283,9 +3270,9 @@ class Httpx {
|
|
|
3283
3270
|
// 转为XML结构
|
|
3284
3271
|
let parser = new DOMParser();
|
|
3285
3272
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3273
|
+
httpxResponse.response = response;
|
|
3274
|
+
httpxResponse.responseText = responseText;
|
|
3275
|
+
httpxResponse.responseXML = responseXML;
|
|
3289
3276
|
// 执行回调
|
|
3290
3277
|
option.onload(httpxResponse);
|
|
3291
3278
|
})
|
|
@@ -3466,7 +3453,7 @@ class Httpx {
|
|
|
3466
3453
|
}
|
|
3467
3454
|
/**
|
|
3468
3455
|
* GET 请求
|
|
3469
|
-
* @param url
|
|
3456
|
+
* @param url 请求的url
|
|
3470
3457
|
* @param details 配置
|
|
3471
3458
|
*/
|
|
3472
3459
|
get(...args) {
|
|
@@ -3532,27 +3519,22 @@ class Httpx {
|
|
|
3532
3519
|
/** 取消请求 */
|
|
3533
3520
|
let abortFn = null;
|
|
3534
3521
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3535
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3522
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3536
3523
|
if (typeof beforeRequestOption === "function") {
|
|
3537
|
-
// @ts-ignore
|
|
3538
3524
|
beforeRequestOption(requestOption);
|
|
3539
3525
|
}
|
|
3540
|
-
|
|
3541
|
-
requestOption =
|
|
3542
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3526
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3543
3527
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3544
3528
|
if (requestResult != null &&
|
|
3545
3529
|
typeof requestResult.abort === "function") {
|
|
3546
3530
|
abortFn = requestResult.abort;
|
|
3547
3531
|
}
|
|
3548
3532
|
});
|
|
3549
|
-
// @ts-ignore
|
|
3550
3533
|
promise.abort = () => {
|
|
3551
3534
|
if (typeof abortFn === "function") {
|
|
3552
3535
|
abortFn();
|
|
3553
3536
|
}
|
|
3554
3537
|
};
|
|
3555
|
-
// @ts-ignore
|
|
3556
3538
|
return promise;
|
|
3557
3539
|
}
|
|
3558
3540
|
}
|
|
@@ -3562,8 +3544,7 @@ class indexedDB {
|
|
|
3562
3544
|
#storeName;
|
|
3563
3545
|
#dbVersion;
|
|
3564
3546
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3565
|
-
//
|
|
3566
|
-
#slqVersion = "1";
|
|
3547
|
+
// #slqVersion = "1";
|
|
3567
3548
|
/* 监听IndexDB */
|
|
3568
3549
|
#indexedDB = window.indexedDB ||
|
|
3569
3550
|
window.mozIndexedDB ||
|
|
@@ -3571,8 +3552,7 @@ class indexedDB {
|
|
|
3571
3552
|
window.msIndexedDB;
|
|
3572
3553
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3573
3554
|
#db = {};
|
|
3574
|
-
//
|
|
3575
|
-
#store = null;
|
|
3555
|
+
// #store: IDBObjectStore = null as any;
|
|
3576
3556
|
/** 状态码 */
|
|
3577
3557
|
#statusCode = {
|
|
3578
3558
|
operationSuccess: {
|
|
@@ -3617,7 +3597,7 @@ class indexedDB {
|
|
|
3617
3597
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3618
3598
|
/* IndexDB的读写权限 */
|
|
3619
3599
|
store = txn.objectStore(this.#storeName);
|
|
3620
|
-
this.#store = store;
|
|
3600
|
+
// this.#store = store;
|
|
3621
3601
|
return store;
|
|
3622
3602
|
}
|
|
3623
3603
|
/**
|
|
@@ -4342,12 +4322,40 @@ class Progress {
|
|
|
4342
4322
|
}
|
|
4343
4323
|
|
|
4344
4324
|
class UtilsDictionary {
|
|
4345
|
-
items
|
|
4325
|
+
items;
|
|
4346
4326
|
constructor(key, value) {
|
|
4327
|
+
this.items = {};
|
|
4347
4328
|
if (key != null) {
|
|
4348
4329
|
this.set(key, value);
|
|
4349
4330
|
}
|
|
4350
4331
|
}
|
|
4332
|
+
/**
|
|
4333
|
+
* 获取字典的长度,同this.size
|
|
4334
|
+
*/
|
|
4335
|
+
get length() {
|
|
4336
|
+
return this.size();
|
|
4337
|
+
}
|
|
4338
|
+
/**
|
|
4339
|
+
* 迭代器
|
|
4340
|
+
*/
|
|
4341
|
+
get entries() {
|
|
4342
|
+
let that = this;
|
|
4343
|
+
return function* () {
|
|
4344
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4345
|
+
for (const keyName of itemKeys) {
|
|
4346
|
+
yield [keyName, that.get(keyName)];
|
|
4347
|
+
}
|
|
4348
|
+
};
|
|
4349
|
+
}
|
|
4350
|
+
/**
|
|
4351
|
+
* 是否可遍历
|
|
4352
|
+
*/
|
|
4353
|
+
get [Symbol.iterator]() {
|
|
4354
|
+
let that = this;
|
|
4355
|
+
return function () {
|
|
4356
|
+
return that.entries();
|
|
4357
|
+
};
|
|
4358
|
+
}
|
|
4351
4359
|
/**
|
|
4352
4360
|
* 检查是否有某一个键
|
|
4353
4361
|
* @param key 键
|
|
@@ -4448,7 +4456,6 @@ class UtilsDictionary {
|
|
|
4448
4456
|
* 返回字典本身
|
|
4449
4457
|
*/
|
|
4450
4458
|
getItems() {
|
|
4451
|
-
// @ts-ignore
|
|
4452
4459
|
return this.items;
|
|
4453
4460
|
}
|
|
4454
4461
|
/**
|
|
@@ -4458,38 +4465,15 @@ class UtilsDictionary {
|
|
|
4458
4465
|
concat(data) {
|
|
4459
4466
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4460
4467
|
}
|
|
4468
|
+
/**
|
|
4469
|
+
* 迭代字典
|
|
4470
|
+
* @param callbackfn 回调函数
|
|
4471
|
+
*/
|
|
4461
4472
|
forEach(callbackfn) {
|
|
4462
4473
|
for (const key in this.getItems()) {
|
|
4463
4474
|
callbackfn(this.get(key), key, this.getItems());
|
|
4464
4475
|
}
|
|
4465
4476
|
}
|
|
4466
|
-
/**
|
|
4467
|
-
* 获取字典的长度,同this.size
|
|
4468
|
-
*/
|
|
4469
|
-
get length() {
|
|
4470
|
-
return this.size();
|
|
4471
|
-
}
|
|
4472
|
-
/**
|
|
4473
|
-
* 迭代器
|
|
4474
|
-
*/
|
|
4475
|
-
get entries() {
|
|
4476
|
-
let that = this;
|
|
4477
|
-
return function* () {
|
|
4478
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4479
|
-
for (const keyName of itemKeys) {
|
|
4480
|
-
yield [keyName, that.get(keyName)];
|
|
4481
|
-
}
|
|
4482
|
-
};
|
|
4483
|
-
}
|
|
4484
|
-
/**
|
|
4485
|
-
* 是否可遍历
|
|
4486
|
-
*/
|
|
4487
|
-
get [Symbol.iterator]() {
|
|
4488
|
-
let that = this;
|
|
4489
|
-
return function () {
|
|
4490
|
-
return that.entries();
|
|
4491
|
-
};
|
|
4492
|
-
}
|
|
4493
4477
|
}
|
|
4494
4478
|
|
|
4495
4479
|
class WindowApi {
|
|
@@ -4515,7 +4499,6 @@ class WindowApi {
|
|
|
4515
4499
|
if (!option) {
|
|
4516
4500
|
option = Object.assign({}, this.defaultApi);
|
|
4517
4501
|
}
|
|
4518
|
-
// @ts-ignore
|
|
4519
4502
|
this.api = Object.assign({}, option);
|
|
4520
4503
|
}
|
|
4521
4504
|
get document() {
|
|
@@ -4573,11 +4556,10 @@ class ReactiveEffect {
|
|
|
4573
4556
|
deps = [];
|
|
4574
4557
|
active = true;
|
|
4575
4558
|
fn;
|
|
4576
|
-
//
|
|
4577
|
-
scheduler;
|
|
4559
|
+
// private scheduler;
|
|
4578
4560
|
constructor(fn, scheduler) {
|
|
4579
4561
|
this.fn = fn;
|
|
4580
|
-
this.scheduler = scheduler;
|
|
4562
|
+
// this.scheduler = scheduler;
|
|
4581
4563
|
}
|
|
4582
4564
|
run(cb) {
|
|
4583
4565
|
if (!this.active) {
|
|
@@ -4644,8 +4626,7 @@ class Vue {
|
|
|
4644
4626
|
reactive(target) {
|
|
4645
4627
|
const that = this;
|
|
4646
4628
|
if (!(typeof target === "object" && target !== null)) {
|
|
4647
|
-
|
|
4648
|
-
return;
|
|
4629
|
+
return void 0;
|
|
4649
4630
|
}
|
|
4650
4631
|
if (VueUtils.isReactive(target)) {
|
|
4651
4632
|
return target;
|
|
@@ -4715,7 +4696,6 @@ class Vue {
|
|
|
4715
4696
|
toRefs(object) {
|
|
4716
4697
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4717
4698
|
for (let key in object) {
|
|
4718
|
-
// @ts-ignore
|
|
4719
4699
|
result[key] = this.toRef(object, key);
|
|
4720
4700
|
}
|
|
4721
4701
|
return result;
|
|
@@ -5011,7 +4991,7 @@ const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
|
5011
4991
|
};
|
|
5012
4992
|
|
|
5013
4993
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5014
|
-
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),
|
|
4994
|
+
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{n(),t.close(),u.delete(o)})),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise((t=>{e.set(a,[r(n,u,i,e,t,a),t])}))},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
5015
4995
|
|
|
5016
4996
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5017
4997
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5443,7 +5423,6 @@ class DOMUtils {
|
|
|
5443
5423
|
let text = textMatch[2];
|
|
5444
5424
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5445
5425
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5446
|
-
// @ts-ignore
|
|
5447
5426
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5448
5427
|
});
|
|
5449
5428
|
}
|
|
@@ -5461,7 +5440,6 @@ class DOMUtils {
|
|
|
5461
5440
|
let regexp = new RegExp(pattern, flags);
|
|
5462
5441
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5463
5442
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5464
|
-
// @ts-ignore
|
|
5465
5443
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5466
5444
|
});
|
|
5467
5445
|
}
|
|
@@ -5507,7 +5485,6 @@ class DOMUtils {
|
|
|
5507
5485
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5508
5486
|
let text = textMatch[2];
|
|
5509
5487
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5510
|
-
// @ts-ignore
|
|
5511
5488
|
let content = $el?.textContent || $el?.innerText;
|
|
5512
5489
|
if (typeof content !== "string") {
|
|
5513
5490
|
content = "";
|
|
@@ -5527,7 +5504,6 @@ class DOMUtils {
|
|
|
5527
5504
|
}
|
|
5528
5505
|
let regexp = new RegExp(pattern, flags);
|
|
5529
5506
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5530
|
-
// @ts-ignore
|
|
5531
5507
|
let content = $el?.textContent || $el?.innerText;
|
|
5532
5508
|
if (typeof content !== "string") {
|
|
5533
5509
|
content = "";
|
|
@@ -5558,7 +5534,6 @@ class DOMUtils {
|
|
|
5558
5534
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5559
5535
|
let $closest = $el?.closest(selector);
|
|
5560
5536
|
if ($closest) {
|
|
5561
|
-
// @ts-ignore
|
|
5562
5537
|
let content = $el?.textContent || $el?.innerText;
|
|
5563
5538
|
if (typeof content === "string" && content.includes(text)) {
|
|
5564
5539
|
return $closest;
|
|
@@ -5581,7 +5556,6 @@ class DOMUtils {
|
|
|
5581
5556
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5582
5557
|
let $closest = $el?.closest(selector);
|
|
5583
5558
|
if ($closest) {
|
|
5584
|
-
// @ts-ignore
|
|
5585
5559
|
let content = $el?.textContent || $el?.innerText;
|
|
5586
5560
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5587
5561
|
return $closest;
|
|
@@ -5701,7 +5675,7 @@ class Utils {
|
|
|
5701
5675
|
return ajaxHooker();
|
|
5702
5676
|
}
|
|
5703
5677
|
};
|
|
5704
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5678
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5705
5679
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5706
5680
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5707
5681
|
}
|
|
@@ -5712,7 +5686,6 @@ class Utils {
|
|
|
5712
5686
|
cancelable: true,
|
|
5713
5687
|
clientX: clientX,
|
|
5714
5688
|
clientY: clientY,
|
|
5715
|
-
// @ts-ignore
|
|
5716
5689
|
view: view,
|
|
5717
5690
|
detail: 1,
|
|
5718
5691
|
};
|
|
@@ -6219,12 +6192,10 @@ class Utils {
|
|
|
6219
6192
|
}
|
|
6220
6193
|
getElementSelector(element) {
|
|
6221
6194
|
let UtilsContext = this;
|
|
6222
|
-
// @ts-ignore
|
|
6223
6195
|
if (!element)
|
|
6224
|
-
return;
|
|
6225
|
-
// @ts-ignore
|
|
6196
|
+
return void 0;
|
|
6226
6197
|
if (!element.parentElement)
|
|
6227
|
-
return;
|
|
6198
|
+
return void 0;
|
|
6228
6199
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6229
6200
|
if (element.id)
|
|
6230
6201
|
return "#" + element.id;
|
|
@@ -6255,8 +6226,7 @@ class Utils {
|
|
|
6255
6226
|
let result = [...args];
|
|
6256
6227
|
let newResult = [];
|
|
6257
6228
|
if (result.length === 0) {
|
|
6258
|
-
|
|
6259
|
-
return;
|
|
6229
|
+
return void 0;
|
|
6260
6230
|
}
|
|
6261
6231
|
if (result.length > 1) {
|
|
6262
6232
|
if (result.length === 2 &&
|
|
@@ -6296,7 +6266,6 @@ class Utils {
|
|
|
6296
6266
|
// 当前页面最大的z-index
|
|
6297
6267
|
let zIndex = 0;
|
|
6298
6268
|
// 当前的最大z-index的元素,调试使用
|
|
6299
|
-
// @ts-ignore
|
|
6300
6269
|
let maxZIndexNode = null;
|
|
6301
6270
|
/**
|
|
6302
6271
|
* 元素是否可见
|
|
@@ -6357,8 +6326,7 @@ class Utils {
|
|
|
6357
6326
|
let result = [...args];
|
|
6358
6327
|
let newResult = [];
|
|
6359
6328
|
if (result.length === 0) {
|
|
6360
|
-
|
|
6361
|
-
return;
|
|
6329
|
+
return void 0;
|
|
6362
6330
|
}
|
|
6363
6331
|
if (result.length > 1) {
|
|
6364
6332
|
if (result.length === 2 &&
|
|
@@ -6832,7 +6800,6 @@ class Utils {
|
|
|
6832
6800
|
}
|
|
6833
6801
|
isJQuery(target) {
|
|
6834
6802
|
let result = false;
|
|
6835
|
-
// @ts-ignore
|
|
6836
6803
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6837
6804
|
result = true;
|
|
6838
6805
|
}
|
|
@@ -7613,29 +7580,27 @@ class Utils {
|
|
|
7613
7580
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7614
7581
|
let type = args[0];
|
|
7615
7582
|
let callback = args[1];
|
|
7616
|
-
//
|
|
7617
|
-
args[2];
|
|
7583
|
+
// let options = args[2];
|
|
7618
7584
|
if (filter(type)) {
|
|
7619
7585
|
if (typeof callback === "function") {
|
|
7620
7586
|
args[1] = function (event) {
|
|
7621
7587
|
callback.call(this, trustEvent(event));
|
|
7622
7588
|
};
|
|
7623
7589
|
}
|
|
7624
|
-
else if (typeof callback === "object" &&
|
|
7625
|
-
"handleEvent" in callback) {
|
|
7590
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7626
7591
|
let oldHandleEvent = callback["handleEvent"];
|
|
7627
7592
|
args[1]["handleEvent"] = function (event) {
|
|
7628
7593
|
if (event == null) {
|
|
7629
7594
|
return;
|
|
7630
7595
|
}
|
|
7631
7596
|
try {
|
|
7632
|
-
|
|
7597
|
+
// Proxy对象使用instanceof会报错
|
|
7598
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7633
7599
|
event instanceof Proxy;
|
|
7634
7600
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7635
7601
|
}
|
|
7636
7602
|
catch (error) {
|
|
7637
|
-
|
|
7638
|
-
event["isTrusted"] = isTrustValue;
|
|
7603
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7639
7604
|
}
|
|
7640
7605
|
};
|
|
7641
7606
|
}
|
|
@@ -7708,8 +7673,8 @@ class Utils {
|
|
|
7708
7673
|
}
|
|
7709
7674
|
async init() {
|
|
7710
7675
|
let copyStatus = false;
|
|
7711
|
-
|
|
7712
|
-
|
|
7676
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7677
|
+
console.log(requestPermissionStatus);
|
|
7713
7678
|
if (this.hasClipboard() &&
|
|
7714
7679
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7715
7680
|
try {
|
|
@@ -7727,11 +7692,8 @@ class Utils {
|
|
|
7727
7692
|
this.destroy();
|
|
7728
7693
|
}
|
|
7729
7694
|
destroy() {
|
|
7730
|
-
// @ts-ignore
|
|
7731
7695
|
this.#resolve = null;
|
|
7732
|
-
// @ts-ignore
|
|
7733
7696
|
this.#copyData = null;
|
|
7734
|
-
// @ts-ignore
|
|
7735
7697
|
this.#copyDataType = null;
|
|
7736
7698
|
}
|
|
7737
7699
|
isText() {
|
|
@@ -7775,7 +7737,6 @@ class Utils {
|
|
|
7775
7737
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7776
7738
|
navigator.permissions
|
|
7777
7739
|
.query({
|
|
7778
|
-
// @ts-ignore
|
|
7779
7740
|
name: "clipboard-write",
|
|
7780
7741
|
})
|
|
7781
7742
|
.then((permissionStatus) => {
|
|
@@ -7871,7 +7832,6 @@ class Utils {
|
|
|
7871
7832
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7872
7833
|
let UtilsContext = this;
|
|
7873
7834
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7874
|
-
// @ts-ignore
|
|
7875
7835
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7876
7836
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7877
7837
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8030,7 +7990,6 @@ class Utils {
|
|
|
8030
7990
|
}
|
|
8031
7991
|
stringToRegular(targetString, flags = "ig") {
|
|
8032
7992
|
let reg;
|
|
8033
|
-
// @ts-ignore
|
|
8034
7993
|
flags = flags.toLowerCase();
|
|
8035
7994
|
if (typeof targetString === "string") {
|
|
8036
7995
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8123,10 +8082,8 @@ class Utils {
|
|
|
8123
8082
|
*/
|
|
8124
8083
|
searchParamStrToObj(searhParamsStr) {
|
|
8125
8084
|
if (typeof searhParamsStr !== "string") {
|
|
8126
|
-
// @ts-ignore
|
|
8127
8085
|
return {};
|
|
8128
8086
|
}
|
|
8129
|
-
// @ts-ignore
|
|
8130
8087
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8131
8088
|
}
|
|
8132
8089
|
/**
|
|
@@ -8829,7 +8786,6 @@ class Utils {
|
|
|
8829
8786
|
function requestPermissionsWithClipboard() {
|
|
8830
8787
|
navigator.permissions
|
|
8831
8788
|
.query({
|
|
8832
|
-
// @ts-ignore
|
|
8833
8789
|
name: "clipboard-read",
|
|
8834
8790
|
})
|
|
8835
8791
|
.then((permissionStatus) => {
|