@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.umd.js
CHANGED
|
@@ -21,14 +21,13 @@
|
|
|
21
21
|
/**
|
|
22
22
|
* 16进制颜色转rgba
|
|
23
23
|
*
|
|
24
|
-
*
|
|
24
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
25
25
|
* @param hex
|
|
26
26
|
* @param opacity
|
|
27
27
|
*/
|
|
28
28
|
hexToRgba(hex, opacity) {
|
|
29
29
|
if (!this.isHex(hex)) {
|
|
30
|
-
|
|
31
|
-
throw new TypeError("输入错误的hex", hex);
|
|
30
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
32
31
|
}
|
|
33
32
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
34
33
|
? "rgba(" +
|
|
@@ -45,19 +44,16 @@
|
|
|
45
44
|
/**
|
|
46
45
|
* hex转rgb
|
|
47
46
|
* @param str
|
|
48
|
-
* @returns
|
|
49
47
|
*/
|
|
50
48
|
hexToRgb(str) {
|
|
51
49
|
if (!this.isHex(str)) {
|
|
52
|
-
|
|
53
|
-
throw new TypeError("输入错误的hex", str);
|
|
50
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
54
51
|
}
|
|
55
52
|
/* replace替换查找的到的字符串 */
|
|
56
53
|
str = str.replace("#", "");
|
|
57
54
|
/* match得到查询数组 */
|
|
58
55
|
let hxs = str.match(/../g);
|
|
59
56
|
for (let index = 0; index < 3; index++) {
|
|
60
|
-
// @ts-ignore
|
|
61
57
|
hxs[index] = parseInt(hxs[index], 16);
|
|
62
58
|
}
|
|
63
59
|
return hxs;
|
|
@@ -67,7 +63,6 @@
|
|
|
67
63
|
* @param redValue
|
|
68
64
|
* @param greenValue
|
|
69
65
|
* @param blueValue
|
|
70
|
-
* @returns
|
|
71
66
|
*/
|
|
72
67
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
73
68
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -90,38 +85,30 @@
|
|
|
90
85
|
* 获取颜色变暗或亮
|
|
91
86
|
* @param color 颜色
|
|
92
87
|
* @param level 0~1.0
|
|
93
|
-
* @returns
|
|
94
88
|
*/
|
|
95
89
|
getDarkColor(color, level) {
|
|
96
90
|
if (!this.isHex(color)) {
|
|
97
|
-
|
|
98
|
-
throw new TypeError("输入错误的hex", color);
|
|
91
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
99
92
|
}
|
|
100
93
|
let rgbc = this.hexToRgb(color);
|
|
101
94
|
for (let index = 0; index < 3; index++) {
|
|
102
|
-
// @ts-ignore
|
|
103
95
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
104
96
|
}
|
|
105
|
-
// @ts-ignore
|
|
106
97
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
107
98
|
}
|
|
108
99
|
/**
|
|
109
100
|
* 获取颜色变亮
|
|
110
101
|
* @param color 颜色
|
|
111
102
|
* @param level 0~1.0
|
|
112
|
-
* @returns
|
|
113
103
|
*/
|
|
114
104
|
getLightColor(color, level) {
|
|
115
105
|
if (!this.isHex(color)) {
|
|
116
|
-
|
|
117
|
-
throw new TypeError("输入错误的hex", color);
|
|
106
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
118
107
|
}
|
|
119
108
|
let rgbc = this.hexToRgb(color);
|
|
120
109
|
for (let index = 0; index < 3; index++) {
|
|
121
|
-
// @ts-ignore
|
|
122
110
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
123
111
|
}
|
|
124
|
-
// @ts-ignore
|
|
125
112
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
126
113
|
}
|
|
127
114
|
}
|
|
@@ -209,20 +196,20 @@
|
|
|
209
196
|
* @param str
|
|
210
197
|
*/
|
|
211
198
|
decode(str) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
199
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
200
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
201
|
+
// let gbk = true;
|
|
202
|
+
let utf = true;
|
|
203
|
+
const that = this;
|
|
217
204
|
while (utf) {
|
|
218
205
|
let gbkMatch = str.match(GBKMatcher);
|
|
219
206
|
let utfMatch = str.match(UTFMatcher);
|
|
207
|
+
// gbk = Boolean(gbkMatch);
|
|
220
208
|
utf = Boolean(utfMatch);
|
|
221
209
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
222
210
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
223
211
|
}
|
|
224
212
|
else {
|
|
225
|
-
// @ts-ignore
|
|
226
213
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
227
214
|
}
|
|
228
215
|
}
|
|
@@ -253,7 +240,6 @@
|
|
|
253
240
|
* @param handler
|
|
254
241
|
*/
|
|
255
242
|
error(handler) {
|
|
256
|
-
// @ts-ignore
|
|
257
243
|
handleError = handler;
|
|
258
244
|
return TryCatchCore;
|
|
259
245
|
},
|
|
@@ -268,8 +254,9 @@
|
|
|
268
254
|
callbackFunction = callback;
|
|
269
255
|
context = __context__ || this;
|
|
270
256
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
271
|
-
|
|
272
|
-
|
|
257
|
+
return result !== void 0
|
|
258
|
+
? result
|
|
259
|
+
: TryCatchCore;
|
|
273
260
|
},
|
|
274
261
|
};
|
|
275
262
|
/**
|
|
@@ -1953,25 +1940,24 @@
|
|
|
1953
1940
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1954
1941
|
/** 油猴菜单上显示的文本 */
|
|
1955
1942
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1956
|
-
//
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
});
|
|
1943
|
+
// const GMMenuOptions = {
|
|
1944
|
+
// /**
|
|
1945
|
+
// * 菜单的id
|
|
1946
|
+
// */
|
|
1947
|
+
// id: menuOption.id,
|
|
1948
|
+
// /**
|
|
1949
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1950
|
+
// */
|
|
1951
|
+
// autoClose: menuOption.autoClose,
|
|
1952
|
+
// /**
|
|
1953
|
+
// * 菜单项的可选访问键
|
|
1954
|
+
// */
|
|
1955
|
+
// accessKey: menuOption.accessKey,
|
|
1956
|
+
// /**
|
|
1957
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1958
|
+
// */
|
|
1959
|
+
// title: menuOption.title,
|
|
1960
|
+
// };
|
|
1975
1961
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1976
1962
|
menuOption.autoReload =
|
|
1977
1963
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2549,7 +2535,9 @@
|
|
|
2549
2535
|
* 对请求的参数进行合并处理
|
|
2550
2536
|
*/
|
|
2551
2537
|
handleBeforeRequestOptionArgs(...args) {
|
|
2552
|
-
let option = {
|
|
2538
|
+
let option = {
|
|
2539
|
+
url: void 0,
|
|
2540
|
+
};
|
|
2553
2541
|
if (typeof args[0] === "string") {
|
|
2554
2542
|
/* 传入的是url,转为配置 */
|
|
2555
2543
|
let url = args[0];
|
|
@@ -2573,7 +2561,7 @@
|
|
|
2573
2561
|
* @param method 当前请求方法,默认get
|
|
2574
2562
|
* @param userRequestOption 用户的请求配置
|
|
2575
2563
|
* @param resolve promise回调
|
|
2576
|
-
* @param reject 抛出错误回调
|
|
2564
|
+
* @param reject promise抛出错误回调
|
|
2577
2565
|
*/
|
|
2578
2566
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2579
2567
|
let that = this;
|
|
@@ -2631,25 +2619,25 @@
|
|
|
2631
2619
|
password: userRequestOption.password ||
|
|
2632
2620
|
this.context.#defaultRequestOption.password,
|
|
2633
2621
|
onabort(...args) {
|
|
2634
|
-
that.context.
|
|
2622
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2635
2623
|
},
|
|
2636
2624
|
onerror(...args) {
|
|
2637
|
-
that.context.
|
|
2625
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2638
2626
|
},
|
|
2639
2627
|
onloadstart(...args) {
|
|
2640
|
-
that.context.
|
|
2628
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2641
2629
|
},
|
|
2642
2630
|
onprogress(...args) {
|
|
2643
|
-
that.context.
|
|
2631
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2644
2632
|
},
|
|
2645
2633
|
onreadystatechange(...args) {
|
|
2646
|
-
that.context.
|
|
2634
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2647
2635
|
},
|
|
2648
2636
|
ontimeout(...args) {
|
|
2649
|
-
that.context.
|
|
2637
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2650
2638
|
},
|
|
2651
2639
|
onload(...args) {
|
|
2652
|
-
that.context.
|
|
2640
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2653
2641
|
},
|
|
2654
2642
|
};
|
|
2655
2643
|
// 补全allowInterceptConfig参数
|
|
@@ -2761,7 +2749,6 @@
|
|
|
2761
2749
|
else if (typeof requestOption.data === "object") {
|
|
2762
2750
|
isHandler = true;
|
|
2763
2751
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2764
|
-
// @ts-ignore
|
|
2765
2752
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2766
2753
|
urlSearch = searchParams.toString();
|
|
2767
2754
|
}
|
|
@@ -2816,9 +2803,7 @@
|
|
|
2816
2803
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2817
2804
|
// application/x-www-form-urlencoded
|
|
2818
2805
|
if (typeof requestOption.data === "object") {
|
|
2819
|
-
requestOption.data = new URLSearchParams(
|
|
2820
|
-
// @ts-ignore
|
|
2821
|
-
requestOption.data).toString();
|
|
2806
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2822
2807
|
}
|
|
2823
2808
|
}
|
|
2824
2809
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2838,7 +2823,7 @@
|
|
|
2838
2823
|
},
|
|
2839
2824
|
/**
|
|
2840
2825
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2841
|
-
* @param option
|
|
2826
|
+
* @param option 请求配置
|
|
2842
2827
|
*/
|
|
2843
2828
|
removeRequestNullOption(option) {
|
|
2844
2829
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2850,13 +2835,13 @@
|
|
|
2850
2835
|
}
|
|
2851
2836
|
});
|
|
2852
2837
|
if (commonUtil.isNull(option.url)) {
|
|
2853
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2838
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2854
2839
|
}
|
|
2855
2840
|
return option;
|
|
2856
2841
|
},
|
|
2857
2842
|
/**
|
|
2858
2843
|
* 处理fetch的配置
|
|
2859
|
-
* @param option
|
|
2844
|
+
* @param option 请求配置
|
|
2860
2845
|
*/
|
|
2861
2846
|
handleFetchOption(option) {
|
|
2862
2847
|
/**
|
|
@@ -2909,21 +2894,21 @@
|
|
|
2909
2894
|
};
|
|
2910
2895
|
},
|
|
2911
2896
|
};
|
|
2912
|
-
|
|
2897
|
+
HttpxResponseCallBack = {
|
|
2913
2898
|
context: this,
|
|
2914
2899
|
/**
|
|
2915
2900
|
* onabort请求被取消-触发
|
|
2916
2901
|
* @param details 配置
|
|
2917
|
-
* @param resolve 回调
|
|
2918
|
-
* @param reject
|
|
2902
|
+
* @param resolve promise回调
|
|
2903
|
+
* @param reject promise抛出错误回调
|
|
2919
2904
|
* @param argsResult 返回的参数列表
|
|
2920
2905
|
*/
|
|
2921
2906
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2922
2907
|
// console.log(argsResult);
|
|
2923
|
-
if (
|
|
2908
|
+
if (typeof details?.onabort === "function") {
|
|
2924
2909
|
details.onabort.apply(this, argsResult);
|
|
2925
2910
|
}
|
|
2926
|
-
else if (
|
|
2911
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2927
2912
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2928
2913
|
}
|
|
2929
2914
|
let response = argsResult;
|
|
@@ -2932,11 +2917,11 @@
|
|
|
2932
2917
|
}
|
|
2933
2918
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2934
2919
|
type: "onabort",
|
|
2935
|
-
error: new
|
|
2920
|
+
error: new Error("request canceled"),
|
|
2936
2921
|
response: null,
|
|
2937
2922
|
details: details,
|
|
2938
2923
|
})) == null) {
|
|
2939
|
-
// reject(new
|
|
2924
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2940
2925
|
return;
|
|
2941
2926
|
}
|
|
2942
2927
|
resolve({
|
|
@@ -2949,93 +2934,83 @@
|
|
|
2949
2934
|
});
|
|
2950
2935
|
},
|
|
2951
2936
|
/**
|
|
2952
|
-
*
|
|
2937
|
+
* ontimeout请求超时-触发
|
|
2953
2938
|
* @param details 配置
|
|
2954
2939
|
* @param resolve 回调
|
|
2955
2940
|
* @param reject 抛出错误
|
|
2956
2941
|
* @param argsResult 返回的参数列表
|
|
2957
2942
|
*/
|
|
2958
|
-
async
|
|
2943
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2959
2944
|
// console.log(argsResult);
|
|
2960
|
-
if ("
|
|
2961
|
-
|
|
2945
|
+
if (typeof details?.ontimeout === "function") {
|
|
2946
|
+
// 执行配置中的ontime回调
|
|
2947
|
+
details.ontimeout.apply(this, argsResult);
|
|
2962
2948
|
}
|
|
2963
|
-
else if (
|
|
2964
|
-
|
|
2949
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2950
|
+
// 执行默认配置的ontime回调
|
|
2951
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2965
2952
|
}
|
|
2953
|
+
// 获取响应结果
|
|
2966
2954
|
let response = argsResult;
|
|
2967
2955
|
if (response.length) {
|
|
2968
2956
|
response = response[0];
|
|
2969
2957
|
}
|
|
2958
|
+
// 执行错误回调的钩子
|
|
2970
2959
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2971
|
-
type: "
|
|
2972
|
-
error: new
|
|
2960
|
+
type: "ontimeout",
|
|
2961
|
+
error: new Error("request timeout"),
|
|
2973
2962
|
response: response,
|
|
2974
2963
|
details: details,
|
|
2975
2964
|
})) == null) {
|
|
2976
|
-
// reject(new
|
|
2965
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2977
2966
|
return;
|
|
2978
2967
|
}
|
|
2979
2968
|
resolve({
|
|
2980
2969
|
data: response,
|
|
2981
2970
|
details: details,
|
|
2982
|
-
msg: "
|
|
2971
|
+
msg: "请求超时",
|
|
2983
2972
|
status: false,
|
|
2984
|
-
statusCode:
|
|
2985
|
-
type: "
|
|
2973
|
+
statusCode: 0,
|
|
2974
|
+
type: "ontimeout",
|
|
2986
2975
|
});
|
|
2987
2976
|
},
|
|
2988
2977
|
/**
|
|
2989
|
-
*
|
|
2978
|
+
* onerror请求异常-触发
|
|
2990
2979
|
* @param details 配置
|
|
2991
2980
|
* @param resolve 回调
|
|
2992
2981
|
* @param reject 抛出错误
|
|
2993
2982
|
* @param argsResult 返回的参数列表
|
|
2994
2983
|
*/
|
|
2995
|
-
async
|
|
2984
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2996
2985
|
// console.log(argsResult);
|
|
2997
|
-
if ("
|
|
2998
|
-
details.
|
|
2986
|
+
if (typeof details?.onerror === "function") {
|
|
2987
|
+
details.onerror.apply(this, argsResult);
|
|
2999
2988
|
}
|
|
3000
|
-
else if (
|
|
3001
|
-
this.context.#defaultRequestOption.
|
|
2989
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2990
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
3002
2991
|
}
|
|
3003
2992
|
let response = argsResult;
|
|
3004
2993
|
if (response.length) {
|
|
3005
2994
|
response = response[0];
|
|
3006
2995
|
}
|
|
3007
2996
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
3008
|
-
type: "
|
|
3009
|
-
error: new
|
|
3010
|
-
response:
|
|
2997
|
+
type: "onerror",
|
|
2998
|
+
error: new Error("request error"),
|
|
2999
|
+
response: response,
|
|
3011
3000
|
details: details,
|
|
3012
3001
|
})) == null) {
|
|
3013
|
-
// reject(new
|
|
3002
|
+
// reject(new Error("response is intercept with onerror"));
|
|
3014
3003
|
return;
|
|
3015
3004
|
}
|
|
3016
3005
|
resolve({
|
|
3017
3006
|
data: response,
|
|
3018
3007
|
details: details,
|
|
3019
|
-
msg: "
|
|
3008
|
+
msg: "请求异常",
|
|
3020
3009
|
status: false,
|
|
3021
|
-
statusCode:
|
|
3022
|
-
type: "
|
|
3010
|
+
statusCode: response["status"],
|
|
3011
|
+
type: "onerror",
|
|
3023
3012
|
});
|
|
3024
3013
|
},
|
|
3025
|
-
/**
|
|
3026
|
-
* onloadstart请求开始-触发
|
|
3027
|
-
* @param details 配置
|
|
3028
|
-
* @param argsResult 返回的参数列表
|
|
3029
|
-
*/
|
|
3030
|
-
onLoadStart(details, argsResult) {
|
|
3031
|
-
// console.log(argsResult);
|
|
3032
|
-
if ("onloadstart" in details) {
|
|
3033
|
-
details.onloadstart.apply(this, argsResult);
|
|
3034
|
-
}
|
|
3035
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3036
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3037
|
-
}
|
|
3038
|
-
},
|
|
3039
3014
|
/**
|
|
3040
3015
|
* onload加载完毕-触发
|
|
3041
3016
|
* @param details 请求的配置
|
|
@@ -3115,7 +3090,7 @@
|
|
|
3115
3090
|
/* 状态码2xx都是成功的 */
|
|
3116
3091
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3117
3092
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3118
|
-
// reject(new
|
|
3093
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3119
3094
|
return;
|
|
3120
3095
|
}
|
|
3121
3096
|
resolve({
|
|
@@ -3128,21 +3103,21 @@
|
|
|
3128
3103
|
});
|
|
3129
3104
|
}
|
|
3130
3105
|
else {
|
|
3131
|
-
this.context.
|
|
3106
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3132
3107
|
}
|
|
3133
3108
|
},
|
|
3134
3109
|
/**
|
|
3135
|
-
*
|
|
3110
|
+
* onloadstart请求开始-触发
|
|
3136
3111
|
* @param details 配置
|
|
3137
3112
|
* @param argsResult 返回的参数列表
|
|
3138
3113
|
*/
|
|
3139
|
-
|
|
3114
|
+
onLoadStart(details, argsResult) {
|
|
3140
3115
|
// console.log(argsResult);
|
|
3141
|
-
if ("
|
|
3142
|
-
details.
|
|
3116
|
+
if (typeof details?.onloadstart === "function") {
|
|
3117
|
+
details.onloadstart.apply(this, argsResult);
|
|
3143
3118
|
}
|
|
3144
|
-
else if (
|
|
3145
|
-
this.context.#defaultRequestOption.
|
|
3119
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3120
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3146
3121
|
}
|
|
3147
3122
|
},
|
|
3148
3123
|
/**
|
|
@@ -3152,13 +3127,28 @@
|
|
|
3152
3127
|
*/
|
|
3153
3128
|
onReadyStateChange(details, argsResult) {
|
|
3154
3129
|
// console.log(argsResult);
|
|
3155
|
-
if (
|
|
3130
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3156
3131
|
details.onreadystatechange.apply(this, argsResult);
|
|
3157
3132
|
}
|
|
3158
|
-
else if (
|
|
3133
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3134
|
+
"function") {
|
|
3159
3135
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3160
3136
|
}
|
|
3161
3137
|
},
|
|
3138
|
+
/**
|
|
3139
|
+
* onprogress上传进度-触发
|
|
3140
|
+
* @param details 配置
|
|
3141
|
+
* @param argsResult 返回的参数列表
|
|
3142
|
+
*/
|
|
3143
|
+
onProgress(details, argsResult) {
|
|
3144
|
+
// console.log(argsResult);
|
|
3145
|
+
if (typeof details?.onprogress === "function") {
|
|
3146
|
+
details.onprogress.apply(this, argsResult);
|
|
3147
|
+
}
|
|
3148
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3149
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3150
|
+
}
|
|
3151
|
+
},
|
|
3162
3152
|
};
|
|
3163
3153
|
HttpxRequest = {
|
|
3164
3154
|
context: this,
|
|
@@ -3208,15 +3198,12 @@
|
|
|
3208
3198
|
isFetch: true,
|
|
3209
3199
|
finalUrl: fetchResponse.url,
|
|
3210
3200
|
readyState: 4,
|
|
3211
|
-
// @ts-ignore
|
|
3212
3201
|
status: fetchResponse.status,
|
|
3213
3202
|
statusText: fetchResponse.statusText,
|
|
3214
|
-
|
|
3215
|
-
response: void 0,
|
|
3203
|
+
response: "",
|
|
3216
3204
|
responseFetchHeaders: fetchResponse.headers,
|
|
3217
3205
|
responseHeaders: "",
|
|
3218
|
-
|
|
3219
|
-
responseText: void 0,
|
|
3206
|
+
responseText: "",
|
|
3220
3207
|
responseType: option.responseType,
|
|
3221
3208
|
responseXML: void 0,
|
|
3222
3209
|
};
|
|
@@ -3289,9 +3276,9 @@
|
|
|
3289
3276
|
// 转为XML结构
|
|
3290
3277
|
let parser = new DOMParser();
|
|
3291
3278
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3279
|
+
httpxResponse.response = response;
|
|
3280
|
+
httpxResponse.responseText = responseText;
|
|
3281
|
+
httpxResponse.responseXML = responseXML;
|
|
3295
3282
|
// 执行回调
|
|
3296
3283
|
option.onload(httpxResponse);
|
|
3297
3284
|
})
|
|
@@ -3472,7 +3459,7 @@
|
|
|
3472
3459
|
}
|
|
3473
3460
|
/**
|
|
3474
3461
|
* GET 请求
|
|
3475
|
-
* @param url
|
|
3462
|
+
* @param url 请求的url
|
|
3476
3463
|
* @param details 配置
|
|
3477
3464
|
*/
|
|
3478
3465
|
get(...args) {
|
|
@@ -3538,27 +3525,22 @@
|
|
|
3538
3525
|
/** 取消请求 */
|
|
3539
3526
|
let abortFn = null;
|
|
3540
3527
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3541
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3528
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3542
3529
|
if (typeof beforeRequestOption === "function") {
|
|
3543
|
-
// @ts-ignore
|
|
3544
3530
|
beforeRequestOption(requestOption);
|
|
3545
3531
|
}
|
|
3546
|
-
|
|
3547
|
-
requestOption =
|
|
3548
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3532
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3549
3533
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3550
3534
|
if (requestResult != null &&
|
|
3551
3535
|
typeof requestResult.abort === "function") {
|
|
3552
3536
|
abortFn = requestResult.abort;
|
|
3553
3537
|
}
|
|
3554
3538
|
});
|
|
3555
|
-
// @ts-ignore
|
|
3556
3539
|
promise.abort = () => {
|
|
3557
3540
|
if (typeof abortFn === "function") {
|
|
3558
3541
|
abortFn();
|
|
3559
3542
|
}
|
|
3560
3543
|
};
|
|
3561
|
-
// @ts-ignore
|
|
3562
3544
|
return promise;
|
|
3563
3545
|
}
|
|
3564
3546
|
}
|
|
@@ -3568,8 +3550,7 @@
|
|
|
3568
3550
|
#storeName;
|
|
3569
3551
|
#dbVersion;
|
|
3570
3552
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3571
|
-
//
|
|
3572
|
-
#slqVersion = "1";
|
|
3553
|
+
// #slqVersion = "1";
|
|
3573
3554
|
/* 监听IndexDB */
|
|
3574
3555
|
#indexedDB = window.indexedDB ||
|
|
3575
3556
|
window.mozIndexedDB ||
|
|
@@ -3577,8 +3558,7 @@
|
|
|
3577
3558
|
window.msIndexedDB;
|
|
3578
3559
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3579
3560
|
#db = {};
|
|
3580
|
-
//
|
|
3581
|
-
#store = null;
|
|
3561
|
+
// #store: IDBObjectStore = null as any;
|
|
3582
3562
|
/** 状态码 */
|
|
3583
3563
|
#statusCode = {
|
|
3584
3564
|
operationSuccess: {
|
|
@@ -3623,7 +3603,7 @@
|
|
|
3623
3603
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3624
3604
|
/* IndexDB的读写权限 */
|
|
3625
3605
|
store = txn.objectStore(this.#storeName);
|
|
3626
|
-
this.#store = store;
|
|
3606
|
+
// this.#store = store;
|
|
3627
3607
|
return store;
|
|
3628
3608
|
}
|
|
3629
3609
|
/**
|
|
@@ -4348,12 +4328,40 @@
|
|
|
4348
4328
|
}
|
|
4349
4329
|
|
|
4350
4330
|
class UtilsDictionary {
|
|
4351
|
-
items
|
|
4331
|
+
items;
|
|
4352
4332
|
constructor(key, value) {
|
|
4333
|
+
this.items = {};
|
|
4353
4334
|
if (key != null) {
|
|
4354
4335
|
this.set(key, value);
|
|
4355
4336
|
}
|
|
4356
4337
|
}
|
|
4338
|
+
/**
|
|
4339
|
+
* 获取字典的长度,同this.size
|
|
4340
|
+
*/
|
|
4341
|
+
get length() {
|
|
4342
|
+
return this.size();
|
|
4343
|
+
}
|
|
4344
|
+
/**
|
|
4345
|
+
* 迭代器
|
|
4346
|
+
*/
|
|
4347
|
+
get entries() {
|
|
4348
|
+
let that = this;
|
|
4349
|
+
return function* () {
|
|
4350
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4351
|
+
for (const keyName of itemKeys) {
|
|
4352
|
+
yield [keyName, that.get(keyName)];
|
|
4353
|
+
}
|
|
4354
|
+
};
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
* 是否可遍历
|
|
4358
|
+
*/
|
|
4359
|
+
get [Symbol.iterator]() {
|
|
4360
|
+
let that = this;
|
|
4361
|
+
return function () {
|
|
4362
|
+
return that.entries();
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4357
4365
|
/**
|
|
4358
4366
|
* 检查是否有某一个键
|
|
4359
4367
|
* @param key 键
|
|
@@ -4454,7 +4462,6 @@
|
|
|
4454
4462
|
* 返回字典本身
|
|
4455
4463
|
*/
|
|
4456
4464
|
getItems() {
|
|
4457
|
-
// @ts-ignore
|
|
4458
4465
|
return this.items;
|
|
4459
4466
|
}
|
|
4460
4467
|
/**
|
|
@@ -4464,38 +4471,15 @@
|
|
|
4464
4471
|
concat(data) {
|
|
4465
4472
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4466
4473
|
}
|
|
4474
|
+
/**
|
|
4475
|
+
* 迭代字典
|
|
4476
|
+
* @param callbackfn 回调函数
|
|
4477
|
+
*/
|
|
4467
4478
|
forEach(callbackfn) {
|
|
4468
4479
|
for (const key in this.getItems()) {
|
|
4469
4480
|
callbackfn(this.get(key), key, this.getItems());
|
|
4470
4481
|
}
|
|
4471
4482
|
}
|
|
4472
|
-
/**
|
|
4473
|
-
* 获取字典的长度,同this.size
|
|
4474
|
-
*/
|
|
4475
|
-
get length() {
|
|
4476
|
-
return this.size();
|
|
4477
|
-
}
|
|
4478
|
-
/**
|
|
4479
|
-
* 迭代器
|
|
4480
|
-
*/
|
|
4481
|
-
get entries() {
|
|
4482
|
-
let that = this;
|
|
4483
|
-
return function* () {
|
|
4484
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4485
|
-
for (const keyName of itemKeys) {
|
|
4486
|
-
yield [keyName, that.get(keyName)];
|
|
4487
|
-
}
|
|
4488
|
-
};
|
|
4489
|
-
}
|
|
4490
|
-
/**
|
|
4491
|
-
* 是否可遍历
|
|
4492
|
-
*/
|
|
4493
|
-
get [Symbol.iterator]() {
|
|
4494
|
-
let that = this;
|
|
4495
|
-
return function () {
|
|
4496
|
-
return that.entries();
|
|
4497
|
-
};
|
|
4498
|
-
}
|
|
4499
4483
|
}
|
|
4500
4484
|
|
|
4501
4485
|
class WindowApi {
|
|
@@ -4521,7 +4505,6 @@
|
|
|
4521
4505
|
if (!option) {
|
|
4522
4506
|
option = Object.assign({}, this.defaultApi);
|
|
4523
4507
|
}
|
|
4524
|
-
// @ts-ignore
|
|
4525
4508
|
this.api = Object.assign({}, option);
|
|
4526
4509
|
}
|
|
4527
4510
|
get document() {
|
|
@@ -4579,11 +4562,10 @@
|
|
|
4579
4562
|
deps = [];
|
|
4580
4563
|
active = true;
|
|
4581
4564
|
fn;
|
|
4582
|
-
//
|
|
4583
|
-
scheduler;
|
|
4565
|
+
// private scheduler;
|
|
4584
4566
|
constructor(fn, scheduler) {
|
|
4585
4567
|
this.fn = fn;
|
|
4586
|
-
this.scheduler = scheduler;
|
|
4568
|
+
// this.scheduler = scheduler;
|
|
4587
4569
|
}
|
|
4588
4570
|
run(cb) {
|
|
4589
4571
|
if (!this.active) {
|
|
@@ -4650,8 +4632,7 @@
|
|
|
4650
4632
|
reactive(target) {
|
|
4651
4633
|
const that = this;
|
|
4652
4634
|
if (!(typeof target === "object" && target !== null)) {
|
|
4653
|
-
|
|
4654
|
-
return;
|
|
4635
|
+
return void 0;
|
|
4655
4636
|
}
|
|
4656
4637
|
if (VueUtils.isReactive(target)) {
|
|
4657
4638
|
return target;
|
|
@@ -4721,7 +4702,6 @@
|
|
|
4721
4702
|
toRefs(object) {
|
|
4722
4703
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4723
4704
|
for (let key in object) {
|
|
4724
|
-
// @ts-ignore
|
|
4725
4705
|
result[key] = this.toRef(object, key);
|
|
4726
4706
|
}
|
|
4727
4707
|
return result;
|
|
@@ -5017,7 +4997,7 @@
|
|
|
5017
4997
|
};
|
|
5018
4998
|
|
|
5019
4999
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5020
|
-
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),
|
|
5000
|
+
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
|
|
5021
5001
|
|
|
5022
5002
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5023
5003
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5449,7 +5429,6 @@
|
|
|
5449
5429
|
let text = textMatch[2];
|
|
5450
5430
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5451
5431
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5452
|
-
// @ts-ignore
|
|
5453
5432
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5454
5433
|
});
|
|
5455
5434
|
}
|
|
@@ -5467,7 +5446,6 @@
|
|
|
5467
5446
|
let regexp = new RegExp(pattern, flags);
|
|
5468
5447
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5469
5448
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5470
|
-
// @ts-ignore
|
|
5471
5449
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5472
5450
|
});
|
|
5473
5451
|
}
|
|
@@ -5513,7 +5491,6 @@
|
|
|
5513
5491
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5514
5492
|
let text = textMatch[2];
|
|
5515
5493
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5516
|
-
// @ts-ignore
|
|
5517
5494
|
let content = $el?.textContent || $el?.innerText;
|
|
5518
5495
|
if (typeof content !== "string") {
|
|
5519
5496
|
content = "";
|
|
@@ -5533,7 +5510,6 @@
|
|
|
5533
5510
|
}
|
|
5534
5511
|
let regexp = new RegExp(pattern, flags);
|
|
5535
5512
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5536
|
-
// @ts-ignore
|
|
5537
5513
|
let content = $el?.textContent || $el?.innerText;
|
|
5538
5514
|
if (typeof content !== "string") {
|
|
5539
5515
|
content = "";
|
|
@@ -5564,7 +5540,6 @@
|
|
|
5564
5540
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5565
5541
|
let $closest = $el?.closest(selector);
|
|
5566
5542
|
if ($closest) {
|
|
5567
|
-
// @ts-ignore
|
|
5568
5543
|
let content = $el?.textContent || $el?.innerText;
|
|
5569
5544
|
if (typeof content === "string" && content.includes(text)) {
|
|
5570
5545
|
return $closest;
|
|
@@ -5587,7 +5562,6 @@
|
|
|
5587
5562
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5588
5563
|
let $closest = $el?.closest(selector);
|
|
5589
5564
|
if ($closest) {
|
|
5590
|
-
// @ts-ignore
|
|
5591
5565
|
let content = $el?.textContent || $el?.innerText;
|
|
5592
5566
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5593
5567
|
return $closest;
|
|
@@ -5707,7 +5681,7 @@
|
|
|
5707
5681
|
return ajaxHooker();
|
|
5708
5682
|
}
|
|
5709
5683
|
};
|
|
5710
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5684
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5711
5685
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5712
5686
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5713
5687
|
}
|
|
@@ -5718,7 +5692,6 @@
|
|
|
5718
5692
|
cancelable: true,
|
|
5719
5693
|
clientX: clientX,
|
|
5720
5694
|
clientY: clientY,
|
|
5721
|
-
// @ts-ignore
|
|
5722
5695
|
view: view,
|
|
5723
5696
|
detail: 1,
|
|
5724
5697
|
};
|
|
@@ -6225,12 +6198,10 @@
|
|
|
6225
6198
|
}
|
|
6226
6199
|
getElementSelector(element) {
|
|
6227
6200
|
let UtilsContext = this;
|
|
6228
|
-
// @ts-ignore
|
|
6229
6201
|
if (!element)
|
|
6230
|
-
return;
|
|
6231
|
-
// @ts-ignore
|
|
6202
|
+
return void 0;
|
|
6232
6203
|
if (!element.parentElement)
|
|
6233
|
-
return;
|
|
6204
|
+
return void 0;
|
|
6234
6205
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6235
6206
|
if (element.id)
|
|
6236
6207
|
return "#" + element.id;
|
|
@@ -6261,8 +6232,7 @@
|
|
|
6261
6232
|
let result = [...args];
|
|
6262
6233
|
let newResult = [];
|
|
6263
6234
|
if (result.length === 0) {
|
|
6264
|
-
|
|
6265
|
-
return;
|
|
6235
|
+
return void 0;
|
|
6266
6236
|
}
|
|
6267
6237
|
if (result.length > 1) {
|
|
6268
6238
|
if (result.length === 2 &&
|
|
@@ -6302,7 +6272,6 @@
|
|
|
6302
6272
|
// 当前页面最大的z-index
|
|
6303
6273
|
let zIndex = 0;
|
|
6304
6274
|
// 当前的最大z-index的元素,调试使用
|
|
6305
|
-
// @ts-ignore
|
|
6306
6275
|
let maxZIndexNode = null;
|
|
6307
6276
|
/**
|
|
6308
6277
|
* 元素是否可见
|
|
@@ -6363,8 +6332,7 @@
|
|
|
6363
6332
|
let result = [...args];
|
|
6364
6333
|
let newResult = [];
|
|
6365
6334
|
if (result.length === 0) {
|
|
6366
|
-
|
|
6367
|
-
return;
|
|
6335
|
+
return void 0;
|
|
6368
6336
|
}
|
|
6369
6337
|
if (result.length > 1) {
|
|
6370
6338
|
if (result.length === 2 &&
|
|
@@ -6838,7 +6806,6 @@
|
|
|
6838
6806
|
}
|
|
6839
6807
|
isJQuery(target) {
|
|
6840
6808
|
let result = false;
|
|
6841
|
-
// @ts-ignore
|
|
6842
6809
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6843
6810
|
result = true;
|
|
6844
6811
|
}
|
|
@@ -7619,29 +7586,27 @@
|
|
|
7619
7586
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7620
7587
|
let type = args[0];
|
|
7621
7588
|
let callback = args[1];
|
|
7622
|
-
//
|
|
7623
|
-
args[2];
|
|
7589
|
+
// let options = args[2];
|
|
7624
7590
|
if (filter(type)) {
|
|
7625
7591
|
if (typeof callback === "function") {
|
|
7626
7592
|
args[1] = function (event) {
|
|
7627
7593
|
callback.call(this, trustEvent(event));
|
|
7628
7594
|
};
|
|
7629
7595
|
}
|
|
7630
|
-
else if (typeof callback === "object" &&
|
|
7631
|
-
"handleEvent" in callback) {
|
|
7596
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7632
7597
|
let oldHandleEvent = callback["handleEvent"];
|
|
7633
7598
|
args[1]["handleEvent"] = function (event) {
|
|
7634
7599
|
if (event == null) {
|
|
7635
7600
|
return;
|
|
7636
7601
|
}
|
|
7637
7602
|
try {
|
|
7638
|
-
|
|
7603
|
+
// Proxy对象使用instanceof会报错
|
|
7604
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7639
7605
|
event instanceof Proxy;
|
|
7640
7606
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7641
7607
|
}
|
|
7642
7608
|
catch (error) {
|
|
7643
|
-
|
|
7644
|
-
event["isTrusted"] = isTrustValue;
|
|
7609
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7645
7610
|
}
|
|
7646
7611
|
};
|
|
7647
7612
|
}
|
|
@@ -7714,8 +7679,8 @@
|
|
|
7714
7679
|
}
|
|
7715
7680
|
async init() {
|
|
7716
7681
|
let copyStatus = false;
|
|
7717
|
-
|
|
7718
|
-
|
|
7682
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7683
|
+
console.log(requestPermissionStatus);
|
|
7719
7684
|
if (this.hasClipboard() &&
|
|
7720
7685
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7721
7686
|
try {
|
|
@@ -7733,11 +7698,8 @@
|
|
|
7733
7698
|
this.destroy();
|
|
7734
7699
|
}
|
|
7735
7700
|
destroy() {
|
|
7736
|
-
// @ts-ignore
|
|
7737
7701
|
this.#resolve = null;
|
|
7738
|
-
// @ts-ignore
|
|
7739
7702
|
this.#copyData = null;
|
|
7740
|
-
// @ts-ignore
|
|
7741
7703
|
this.#copyDataType = null;
|
|
7742
7704
|
}
|
|
7743
7705
|
isText() {
|
|
@@ -7781,7 +7743,6 @@
|
|
|
7781
7743
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7782
7744
|
navigator.permissions
|
|
7783
7745
|
.query({
|
|
7784
|
-
// @ts-ignore
|
|
7785
7746
|
name: "clipboard-write",
|
|
7786
7747
|
})
|
|
7787
7748
|
.then((permissionStatus) => {
|
|
@@ -7877,7 +7838,6 @@
|
|
|
7877
7838
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7878
7839
|
let UtilsContext = this;
|
|
7879
7840
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7880
|
-
// @ts-ignore
|
|
7881
7841
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7882
7842
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7883
7843
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8036,7 +7996,6 @@
|
|
|
8036
7996
|
}
|
|
8037
7997
|
stringToRegular(targetString, flags = "ig") {
|
|
8038
7998
|
let reg;
|
|
8039
|
-
// @ts-ignore
|
|
8040
7999
|
flags = flags.toLowerCase();
|
|
8041
8000
|
if (typeof targetString === "string") {
|
|
8042
8001
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8129,10 +8088,8 @@
|
|
|
8129
8088
|
*/
|
|
8130
8089
|
searchParamStrToObj(searhParamsStr) {
|
|
8131
8090
|
if (typeof searhParamsStr !== "string") {
|
|
8132
|
-
// @ts-ignore
|
|
8133
8091
|
return {};
|
|
8134
8092
|
}
|
|
8135
|
-
// @ts-ignore
|
|
8136
8093
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8137
8094
|
}
|
|
8138
8095
|
/**
|
|
@@ -8835,7 +8792,6 @@
|
|
|
8835
8792
|
function requestPermissionsWithClipboard() {
|
|
8836
8793
|
navigator.permissions
|
|
8837
8794
|
.query({
|
|
8838
|
-
// @ts-ignore
|
|
8839
8795
|
name: "clipboard-read",
|
|
8840
8796
|
})
|
|
8841
8797
|
.then((permissionStatus) => {
|