@whitesev/utils 2.7.2 → 2.7.3
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 +98 -203
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +98 -203
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +98 -203
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +98 -203
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +98 -203
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +98 -203
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +30 -2
- package/dist/types/src/types/Event.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +4 -21
- package/dist/types/src/types/ajaxHooker.d.ts +1 -5
- package/package.json +1 -1
- package/src/ColorConversion.ts +5 -18
- package/src/CommonUtil.ts +8 -31
- package/src/DOMUtils.ts +9 -22
- package/src/Dictionary.ts +2 -7
- package/src/GBKEncoder.ts +1 -6
- package/src/Hooks.ts +1 -4
- package/src/Httpx.ts +102 -277
- package/src/LockFunction.ts +1 -3
- package/src/Log.ts +7 -23
- package/src/Progress.ts +2 -10
- package/src/TryCatch.ts +3 -11
- package/src/Utils.ts +209 -555
- package/src/UtilsCommon.ts +5 -9
- package/src/UtilsGMCookie.ts +1 -4
- package/src/UtilsGMMenu.ts +10 -29
- package/src/Vue.ts +2 -11
- package/src/indexedDB.ts +3 -12
- package/src/types/Event.d.ts +1 -2
- package/src/types/Httpx.d.ts +4 -21
- package/src/types/ajaxHooker.d.ts +1 -5
package/dist/index.umd.js
CHANGED
|
@@ -71,11 +71,7 @@
|
|
|
71
71
|
!validPattern.test(greenValue.toString()) ||
|
|
72
72
|
!validPattern.test(blueValue.toString()))
|
|
73
73
|
throw new TypeError("输入错误的rgb颜色值");
|
|
74
|
-
let hexs = [
|
|
75
|
-
redValue.toString(16),
|
|
76
|
-
greenValue.toString(16),
|
|
77
|
-
blueValue.toString(16),
|
|
78
|
-
];
|
|
74
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
79
75
|
for (let index = 0; index < 3; index++)
|
|
80
76
|
if (hexs[index].length == 1)
|
|
81
77
|
hexs[index] = "0" + hexs[index];
|
|
@@ -123,10 +119,7 @@
|
|
|
123
119
|
this.#data = dataText.match(/..../g);
|
|
124
120
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
125
121
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
126
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
127
|
-
i.toString(16) +
|
|
128
|
-
"%" +
|
|
129
|
-
j.toString(16)).toUpperCase();
|
|
122
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
130
123
|
}
|
|
131
124
|
}
|
|
132
125
|
for (let key in this.#U2Ghash) {
|
|
@@ -254,9 +247,7 @@
|
|
|
254
247
|
callbackFunction = callback;
|
|
255
248
|
context = __context__ || this;
|
|
256
249
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
257
|
-
return result !== void 0
|
|
258
|
-
? result
|
|
259
|
-
: TryCatchCore;
|
|
250
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
260
251
|
},
|
|
261
252
|
};
|
|
262
253
|
/**
|
|
@@ -285,10 +276,7 @@
|
|
|
285
276
|
}
|
|
286
277
|
if (handleErrorFunc) {
|
|
287
278
|
if (typeof handleErrorFunc === "string") {
|
|
288
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
289
|
-
...args,
|
|
290
|
-
error,
|
|
291
|
-
]);
|
|
279
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
292
280
|
}
|
|
293
281
|
else {
|
|
294
282
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -376,10 +364,7 @@
|
|
|
376
364
|
itemResult = objItem === 0;
|
|
377
365
|
break;
|
|
378
366
|
case "string":
|
|
379
|
-
itemResult =
|
|
380
|
-
objItem.trim() === "" ||
|
|
381
|
-
objItem === "null" ||
|
|
382
|
-
objItem === "undefined";
|
|
367
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
383
368
|
break;
|
|
384
369
|
case "boolean":
|
|
385
370
|
itemResult = !objItem;
|
|
@@ -420,8 +405,7 @@
|
|
|
420
405
|
return null;
|
|
421
406
|
let clone = obj instanceof Array ? [] : {};
|
|
422
407
|
for (const [key, value] of Object.entries(obj)) {
|
|
423
|
-
clone[key] =
|
|
424
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
408
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
425
409
|
}
|
|
426
410
|
return clone;
|
|
427
411
|
}
|
|
@@ -1960,14 +1944,10 @@
|
|
|
1960
1944
|
// };
|
|
1961
1945
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1962
1946
|
menuOption.autoReload =
|
|
1963
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1964
|
-
? this.$default.autoReload
|
|
1965
|
-
: menuOption.autoReload;
|
|
1947
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1966
1948
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1967
1949
|
menuOption.isStoreValue =
|
|
1968
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1969
|
-
? this.$default.isStoreValue
|
|
1970
|
-
: menuOption.isStoreValue;
|
|
1950
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1971
1951
|
/**
|
|
1972
1952
|
* 用户点击菜单后的回调函数
|
|
1973
1953
|
* @param event
|
|
@@ -2020,8 +2000,7 @@
|
|
|
2020
2000
|
* @param menuKey 菜单-键key
|
|
2021
2001
|
*/
|
|
2022
2002
|
getMenuHandledOption(menuKey) {
|
|
2023
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2024
|
-
?.handleData;
|
|
2003
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2025
2004
|
},
|
|
2026
2005
|
};
|
|
2027
2006
|
constructor(details) {
|
|
@@ -2029,8 +2008,7 @@
|
|
|
2029
2008
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2030
2009
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2031
2010
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2032
|
-
this.MenuHandle.$default.autoReload =
|
|
2033
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2011
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2034
2012
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2035
2013
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2036
2014
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2262,8 +2240,7 @@
|
|
|
2262
2240
|
_context = context || window;
|
|
2263
2241
|
_funcName = getFuncName(this);
|
|
2264
2242
|
_context["realFunc_" + _funcName] = this;
|
|
2265
|
-
if (_context[_funcName].prototype &&
|
|
2266
|
-
_context[_funcName].prototype.isHooked) {
|
|
2243
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2267
2244
|
console.log("Already has been hooked,unhook first");
|
|
2268
2245
|
return false;
|
|
2269
2246
|
}
|
|
@@ -2441,8 +2418,7 @@
|
|
|
2441
2418
|
if (details.allowInterceptConfig != null) {
|
|
2442
2419
|
// 配置存在
|
|
2443
2420
|
// 细分处理是否拦截
|
|
2444
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2445
|
-
"boolean" &&
|
|
2421
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2446
2422
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2447
2423
|
// 设置了禁止拦截
|
|
2448
2424
|
return details;
|
|
@@ -2477,8 +2453,7 @@
|
|
|
2477
2453
|
if (data.details.allowInterceptConfig != null) {
|
|
2478
2454
|
// 配置存在
|
|
2479
2455
|
// 细分处理是否拦截
|
|
2480
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2481
|
-
"boolean" &&
|
|
2456
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2482
2457
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2483
2458
|
// 设置了禁止拦截
|
|
2484
2459
|
return data;
|
|
@@ -2580,44 +2555,31 @@
|
|
|
2580
2555
|
let requestOption = {
|
|
2581
2556
|
url: url,
|
|
2582
2557
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2583
|
-
timeout: userRequestOption.timeout ||
|
|
2584
|
-
|
|
2585
|
-
responseType: userRequestOption.responseType ||
|
|
2586
|
-
this.context.#defaultRequestOption.responseType,
|
|
2558
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2559
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2587
2560
|
/* 对象使用深拷贝 */
|
|
2588
2561
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2589
2562
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2590
|
-
redirect: userRequestOption.redirect ||
|
|
2591
|
-
this.context.#defaultRequestOption.redirect,
|
|
2563
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2592
2564
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2593
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2594
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2565
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2595
2566
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2596
|
-
nocache: userRequestOption.nocache ||
|
|
2597
|
-
|
|
2598
|
-
revalidate: userRequestOption.revalidate ||
|
|
2599
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2567
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2568
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2600
2569
|
/* 对象使用深拷贝 */
|
|
2601
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2605
|
-
anonymous: userRequestOption.anonymous ||
|
|
2606
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2570
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2571
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2572
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2607
2573
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2608
2574
|
/* 对象使用深拷贝 */
|
|
2609
2575
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2610
2576
|
allowInterceptConfig: {
|
|
2611
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2615
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2616
|
-
.allowInterceptConfig.afterResponseError,
|
|
2577
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2578
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2579
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2617
2580
|
},
|
|
2618
2581
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2619
|
-
password: userRequestOption.password ||
|
|
2620
|
-
this.context.#defaultRequestOption.password,
|
|
2582
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2621
2583
|
onabort(...args) {
|
|
2622
2584
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2623
2585
|
},
|
|
@@ -2665,14 +2627,12 @@
|
|
|
2665
2627
|
if (typeof requestOption.headers === "object") {
|
|
2666
2628
|
if (typeof userRequestOption.headers === "object") {
|
|
2667
2629
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2668
|
-
if (keyName in requestOption.headers &&
|
|
2669
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2630
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2670
2631
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2671
2632
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2672
2633
|
}
|
|
2673
2634
|
else {
|
|
2674
|
-
requestOption.headers[keyName] =
|
|
2675
|
-
userRequestOption?.headers?.[keyName];
|
|
2635
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2676
2636
|
}
|
|
2677
2637
|
});
|
|
2678
2638
|
}
|
|
@@ -2685,8 +2645,7 @@
|
|
|
2685
2645
|
/* 使用assign替换且添加 */
|
|
2686
2646
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2687
2647
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2688
|
-
if (keyName in requestOption.fetchInit &&
|
|
2689
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2648
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2690
2649
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2691
2650
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2692
2651
|
}
|
|
@@ -2700,8 +2659,7 @@
|
|
|
2700
2659
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2701
2660
|
}
|
|
2702
2661
|
// 处理新的cookiePartition
|
|
2703
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2704
|
-
requestOption.cookiePartition != null) {
|
|
2662
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2705
2663
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2706
2664
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2707
2665
|
// topLevelSite必须是字符串
|
|
@@ -2723,8 +2681,7 @@
|
|
|
2723
2681
|
}
|
|
2724
2682
|
else {
|
|
2725
2683
|
// 补充origin+/
|
|
2726
|
-
requestOption.url =
|
|
2727
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2684
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2728
2685
|
}
|
|
2729
2686
|
}
|
|
2730
2687
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2848,8 +2805,7 @@
|
|
|
2848
2805
|
* fetch的请求配置
|
|
2849
2806
|
**/
|
|
2850
2807
|
let fetchRequestOption = {};
|
|
2851
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2852
|
-
option.data != null) {
|
|
2808
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2853
2809
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2854
2810
|
Reflect.deleteProperty(option, "data");
|
|
2855
2811
|
}
|
|
@@ -3130,8 +3086,7 @@
|
|
|
3130
3086
|
if (typeof details?.onreadystatechange === "function") {
|
|
3131
3087
|
details.onreadystatechange.apply(this, argsResult);
|
|
3132
3088
|
}
|
|
3133
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3134
|
-
"function") {
|
|
3089
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3135
3090
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3136
3091
|
}
|
|
3137
3092
|
},
|
|
@@ -3160,8 +3115,7 @@
|
|
|
3160
3115
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3161
3116
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3162
3117
|
}
|
|
3163
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3164
|
-
"function") {
|
|
3118
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3165
3119
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3166
3120
|
if (hookResult == null) {
|
|
3167
3121
|
return;
|
|
@@ -3217,9 +3171,7 @@
|
|
|
3217
3171
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3218
3172
|
if (option.responseType === "stream" ||
|
|
3219
3173
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3220
|
-
fetchResponse.headers
|
|
3221
|
-
.get("Content-Type")
|
|
3222
|
-
.includes("text/event-stream"))) {
|
|
3174
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3223
3175
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3224
3176
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3225
3177
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3238,9 +3190,7 @@
|
|
|
3238
3190
|
/** 数据编码 */
|
|
3239
3191
|
let encoding = "utf-8";
|
|
3240
3192
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3241
|
-
let charsetMatched = fetchResponse.headers
|
|
3242
|
-
.get("Content-Type")
|
|
3243
|
-
?.match(/charset=(.+)/);
|
|
3193
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3244
3194
|
if (charsetMatched) {
|
|
3245
3195
|
encoding = charsetMatched[1];
|
|
3246
3196
|
encoding = encoding.toLowerCase();
|
|
@@ -3262,13 +3212,11 @@
|
|
|
3262
3212
|
response = new Blob([arrayBuffer]);
|
|
3263
3213
|
}
|
|
3264
3214
|
else if (option.responseType === "json" ||
|
|
3265
|
-
(typeof fetchResponseType === "string" &&
|
|
3266
|
-
fetchResponseType.includes("application/json"))) {
|
|
3215
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3267
3216
|
// response返回格式是JSON格式
|
|
3268
3217
|
response = commonUtil.toJSON(responseText);
|
|
3269
3218
|
}
|
|
3270
|
-
else if (option.responseType === "document" ||
|
|
3271
|
-
option.responseType == null) {
|
|
3219
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3272
3220
|
// response返回格式是文档格式
|
|
3273
3221
|
let parser = new DOMParser();
|
|
3274
3222
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3531,8 +3479,7 @@
|
|
|
3531
3479
|
}
|
|
3532
3480
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3533
3481
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3534
|
-
if (requestResult != null &&
|
|
3535
|
-
typeof requestResult.abort === "function") {
|
|
3482
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3536
3483
|
abortFn = requestResult.abort;
|
|
3537
3484
|
}
|
|
3538
3485
|
});
|
|
@@ -4023,8 +3970,7 @@
|
|
|
4023
3970
|
if (typeof __GM_info === "string") {
|
|
4024
3971
|
this.tag = __GM_info;
|
|
4025
3972
|
}
|
|
4026
|
-
else if (typeof __GM_info === "object" &&
|
|
4027
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3973
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4028
3974
|
this.tag = __GM_info.script.name;
|
|
4029
3975
|
}
|
|
4030
3976
|
this.#console = console;
|
|
@@ -4080,8 +4026,7 @@
|
|
|
4080
4026
|
*/
|
|
4081
4027
|
checkClearConsole() {
|
|
4082
4028
|
this.#logCount++;
|
|
4083
|
-
if (this.#details.autoClearConsole &&
|
|
4084
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
4029
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4085
4030
|
this.#console.clear();
|
|
4086
4031
|
this.#logCount = 0;
|
|
4087
4032
|
}
|
|
@@ -5584,7 +5529,7 @@
|
|
|
5584
5529
|
this.windowApi = new WindowApi(option);
|
|
5585
5530
|
}
|
|
5586
5531
|
/** 版本号 */
|
|
5587
|
-
version = "2025.
|
|
5532
|
+
version = "2025.8.11";
|
|
5588
5533
|
addStyle(cssText) {
|
|
5589
5534
|
if (typeof cssText !== "string") {
|
|
5590
5535
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5707,13 +5652,9 @@
|
|
|
5707
5652
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5708
5653
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5709
5654
|
// 点击的x坐标
|
|
5710
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5711
|
-
? clickEvent.clientX
|
|
5712
|
-
: touchEvent.touches[0].clientX;
|
|
5655
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5713
5656
|
// 点击的y坐标
|
|
5714
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5715
|
-
? clickEvent.clientY
|
|
5716
|
-
: touchEvent.touches[0].clientY;
|
|
5657
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5717
5658
|
let {
|
|
5718
5659
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5719
5660
|
left: elementPosXLeft,
|
|
@@ -5876,9 +5817,7 @@
|
|
|
5876
5817
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5877
5818
|
let windowFind = this.windowApi.self.find;
|
|
5878
5819
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5879
|
-
if (strFound &&
|
|
5880
|
-
this.windowApi.self.getSelection &&
|
|
5881
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5820
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5882
5821
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5883
5822
|
}
|
|
5884
5823
|
if (!strFound) {
|
|
@@ -5981,9 +5920,7 @@
|
|
|
5981
5920
|
}
|
|
5982
5921
|
}
|
|
5983
5922
|
result = result.toFixed(2);
|
|
5984
|
-
result = addType
|
|
5985
|
-
? result + resultType.toString()
|
|
5986
|
-
: parseFloat(result.toString());
|
|
5923
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5987
5924
|
return result;
|
|
5988
5925
|
}
|
|
5989
5926
|
getNodeListValue(...args) {
|
|
@@ -6062,14 +5999,7 @@
|
|
|
6062
5999
|
if (text.length === 8) {
|
|
6063
6000
|
/* 该字符串只有时分秒 */
|
|
6064
6001
|
let today = new Date();
|
|
6065
|
-
text =
|
|
6066
|
-
today.getFullYear() +
|
|
6067
|
-
"-" +
|
|
6068
|
-
(today.getMonth() + 1) +
|
|
6069
|
-
"-" +
|
|
6070
|
-
today.getDate() +
|
|
6071
|
-
" " +
|
|
6072
|
-
text;
|
|
6002
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6073
6003
|
}
|
|
6074
6004
|
text = text.substring(0, 19);
|
|
6075
6005
|
text = text.replace(/-/g, "/");
|
|
@@ -6090,25 +6020,13 @@
|
|
|
6090
6020
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6091
6021
|
*/
|
|
6092
6022
|
getTransitionEndNameList() {
|
|
6093
|
-
return [
|
|
6094
|
-
"webkitTransitionEnd",
|
|
6095
|
-
"mozTransitionEnd",
|
|
6096
|
-
"MSTransitionEnd",
|
|
6097
|
-
"otransitionend",
|
|
6098
|
-
"transitionend",
|
|
6099
|
-
];
|
|
6023
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6100
6024
|
}
|
|
6101
6025
|
/**
|
|
6102
6026
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6103
6027
|
*/
|
|
6104
6028
|
getAnimationEndNameList() {
|
|
6105
|
-
return [
|
|
6106
|
-
"webkitAnimationEnd",
|
|
6107
|
-
"mozAnimationEnd",
|
|
6108
|
-
"MSAnimationEnd",
|
|
6109
|
-
"oanimationend",
|
|
6110
|
-
"animationend",
|
|
6111
|
-
];
|
|
6029
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6112
6030
|
}
|
|
6113
6031
|
getArrayLastValue(targetObj) {
|
|
6114
6032
|
return targetObj[targetObj.length - 1];
|
|
@@ -6212,10 +6130,8 @@
|
|
|
6212
6130
|
}
|
|
6213
6131
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6214
6132
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6215
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6216
|
-
|
|
6217
|
-
selector +=
|
|
6218
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6133
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6134
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6219
6135
|
}
|
|
6220
6136
|
else {
|
|
6221
6137
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6235,9 +6151,7 @@
|
|
|
6235
6151
|
return void 0;
|
|
6236
6152
|
}
|
|
6237
6153
|
if (result.length > 1) {
|
|
6238
|
-
if (result.length === 2 &&
|
|
6239
|
-
typeof result[0] === "object" &&
|
|
6240
|
-
typeof result[1] === "function") {
|
|
6154
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6241
6155
|
let data = result[0];
|
|
6242
6156
|
let handleDataFunc = result[1];
|
|
6243
6157
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6335,9 +6249,7 @@
|
|
|
6335
6249
|
return void 0;
|
|
6336
6250
|
}
|
|
6337
6251
|
if (result.length > 1) {
|
|
6338
|
-
if (result.length === 2 &&
|
|
6339
|
-
typeof result[0] === "object" &&
|
|
6340
|
-
typeof result[1] === "function") {
|
|
6252
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6341
6253
|
let data = result[0];
|
|
6342
6254
|
let handleDataFunc = result[1];
|
|
6343
6255
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6427,12 +6339,10 @@
|
|
|
6427
6339
|
getRandomValue(...args) {
|
|
6428
6340
|
let result = [...args];
|
|
6429
6341
|
if (result.length > 1) {
|
|
6430
|
-
if (result.length === 2 &&
|
|
6431
|
-
typeof result[0] === "number" &&
|
|
6432
|
-
typeof result[1] === "number") {
|
|
6342
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6433
6343
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6434
6344
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6435
|
-
return
|
|
6345
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6436
6346
|
}
|
|
6437
6347
|
else {
|
|
6438
6348
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6443,8 +6353,7 @@
|
|
|
6443
6353
|
if (Array.isArray(paramData)) {
|
|
6444
6354
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6445
6355
|
}
|
|
6446
|
-
else if (typeof paramData === "object" &&
|
|
6447
|
-
Object.keys(paramData).length > 0) {
|
|
6356
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6448
6357
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6449
6358
|
return paramData[paramObjDataKey];
|
|
6450
6359
|
}
|
|
@@ -6751,11 +6660,9 @@
|
|
|
6751
6660
|
let nearBottomHeight = 50;
|
|
6752
6661
|
let checkWindow = () => {
|
|
6753
6662
|
// 已滚动的距离
|
|
6754
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6755
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6663
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6756
6664
|
// 视窗高度
|
|
6757
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6758
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6665
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6759
6666
|
// 最大滚动距离
|
|
6760
6667
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6761
6668
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7044,8 +6951,7 @@
|
|
|
7044
6951
|
**/
|
|
7045
6952
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7046
6953
|
isThemeDark() {
|
|
7047
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7048
|
-
.matches;
|
|
6954
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7049
6955
|
}
|
|
7050
6956
|
/**
|
|
7051
6957
|
* 判断元素是否在页面中可见
|
|
@@ -7078,10 +6984,8 @@
|
|
|
7078
6984
|
else {
|
|
7079
6985
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7080
6986
|
if (inView) {
|
|
7081
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7082
|
-
|
|
7083
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7084
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6987
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6988
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7085
6989
|
result = !(domClientRect.right < 0 ||
|
|
7086
6990
|
domClientRect.left > viewportWidth ||
|
|
7087
6991
|
domClientRect.bottom < 0 ||
|
|
@@ -7105,8 +7009,7 @@
|
|
|
7105
7009
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7106
7010
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7107
7011
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7108
|
-
if (typeof objValueFunc === "function" &&
|
|
7109
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7012
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7110
7013
|
result = true;
|
|
7111
7014
|
}
|
|
7112
7015
|
else {
|
|
@@ -7128,8 +7031,7 @@
|
|
|
7128
7031
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7129
7032
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7130
7033
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7131
|
-
if (typeof objValueFunc === "function" &&
|
|
7132
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7034
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7133
7035
|
result = true;
|
|
7134
7036
|
}
|
|
7135
7037
|
else {
|
|
@@ -7366,13 +7268,11 @@
|
|
|
7366
7268
|
* 释放所有
|
|
7367
7269
|
*/
|
|
7368
7270
|
function releaseAll() {
|
|
7369
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7370
|
-
"undefined") {
|
|
7271
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7371
7272
|
/* 已存在 */
|
|
7372
7273
|
return;
|
|
7373
7274
|
}
|
|
7374
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7375
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7275
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7376
7276
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7377
7277
|
if (typeof value === "function") {
|
|
7378
7278
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7386,8 +7286,7 @@
|
|
|
7386
7286
|
Array.from(functionNameList).forEach((item) => {
|
|
7387
7287
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7388
7288
|
if (typeof value === "function") {
|
|
7389
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7390
|
-
"undefined") {
|
|
7289
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7391
7290
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7392
7291
|
}
|
|
7393
7292
|
if (item === value.name) {
|
|
@@ -7402,8 +7301,7 @@
|
|
|
7402
7301
|
* 恢复所有
|
|
7403
7302
|
*/
|
|
7404
7303
|
function recoveryAll() {
|
|
7405
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7406
|
-
"undefined") {
|
|
7304
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7407
7305
|
/* 未存在 */
|
|
7408
7306
|
return;
|
|
7409
7307
|
}
|
|
@@ -7414,8 +7312,7 @@
|
|
|
7414
7312
|
* 恢复单个
|
|
7415
7313
|
*/
|
|
7416
7314
|
function recoveryOne() {
|
|
7417
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7418
|
-
"undefined") {
|
|
7315
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7419
7316
|
/* 未存在 */
|
|
7420
7317
|
return;
|
|
7421
7318
|
}
|
|
@@ -7423,8 +7320,7 @@
|
|
|
7423
7320
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7424
7321
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7425
7322
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7426
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7427
|
-
.length === 0) {
|
|
7323
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7428
7324
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7429
7325
|
}
|
|
7430
7326
|
}
|
|
@@ -7681,8 +7577,7 @@
|
|
|
7681
7577
|
let copyStatus = false;
|
|
7682
7578
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7683
7579
|
console.log(requestPermissionStatus);
|
|
7684
|
-
if (this.hasClipboard() &&
|
|
7685
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7580
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7686
7581
|
try {
|
|
7687
7582
|
copyStatus = await this.copyDataByClipboard();
|
|
7688
7583
|
}
|
|
@@ -7843,11 +7738,8 @@
|
|
|
7843
7738
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7844
7739
|
return mouseEvent;
|
|
7845
7740
|
}
|
|
7846
|
-
let sliderElement = typeof selector === "string"
|
|
7847
|
-
|
|
7848
|
-
: selector;
|
|
7849
|
-
if (!(sliderElement instanceof Node) ||
|
|
7850
|
-
!(sliderElement instanceof Element)) {
|
|
7741
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7742
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7851
7743
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7852
7744
|
}
|
|
7853
7745
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7899,17 +7791,14 @@
|
|
|
7899
7791
|
}
|
|
7900
7792
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7901
7793
|
let UtilsContext = this;
|
|
7902
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7903
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7794
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7904
7795
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7905
7796
|
}
|
|
7906
7797
|
if (typeof sortByDesc !== "boolean") {
|
|
7907
7798
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7908
7799
|
}
|
|
7909
7800
|
let getObjValue = function (obj) {
|
|
7910
|
-
return typeof getPropertyValueFunc === "string"
|
|
7911
|
-
? obj[getPropertyValueFunc]
|
|
7912
|
-
: getPropertyValueFunc(obj);
|
|
7801
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7913
7802
|
};
|
|
7914
7803
|
/**
|
|
7915
7804
|
* 排序方法
|
|
@@ -7984,8 +7873,7 @@
|
|
|
7984
7873
|
if (Array.isArray(data)) {
|
|
7985
7874
|
data.sort(sortFunc);
|
|
7986
7875
|
}
|
|
7987
|
-
else if (data instanceof NodeList ||
|
|
7988
|
-
UtilsContext.isJQuery(data)) {
|
|
7876
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7989
7877
|
sortNodeFunc(data, getDataFunc);
|
|
7990
7878
|
result = getDataFunc();
|
|
7991
7879
|
}
|
|
@@ -8178,9 +8066,7 @@
|
|
|
8178
8066
|
let parent = UtilsContext.windowApi.document;
|
|
8179
8067
|
// 超时时间
|
|
8180
8068
|
let timeout = 0;
|
|
8181
|
-
if (typeof args[0] !== "string" &&
|
|
8182
|
-
!Array.isArray(args[0]) &&
|
|
8183
|
-
typeof args[0] !== "function") {
|
|
8069
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8184
8070
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8185
8071
|
}
|
|
8186
8072
|
if (args.length === 1) ;
|
|
@@ -8190,8 +8076,7 @@
|
|
|
8190
8076
|
// "div",10000
|
|
8191
8077
|
timeout = secondParam;
|
|
8192
8078
|
}
|
|
8193
|
-
else if (typeof secondParam === "object" &&
|
|
8194
|
-
secondParam instanceof Node) {
|
|
8079
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8195
8080
|
// "div",document
|
|
8196
8081
|
parent = secondParam;
|
|
8197
8082
|
}
|
|
@@ -8277,8 +8162,7 @@
|
|
|
8277
8162
|
// "div",10000
|
|
8278
8163
|
timeout = secondParam;
|
|
8279
8164
|
}
|
|
8280
|
-
else if (typeof secondParam === "object" &&
|
|
8281
|
-
secondParam instanceof Node) {
|
|
8165
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8282
8166
|
// "div",document
|
|
8283
8167
|
parent = secondParam;
|
|
8284
8168
|
}
|
|
@@ -8333,8 +8217,7 @@
|
|
|
8333
8217
|
// "div",10000
|
|
8334
8218
|
timeout = secondParam;
|
|
8335
8219
|
}
|
|
8336
|
-
else if (typeof secondParam === "object" &&
|
|
8337
|
-
secondParam instanceof Node) {
|
|
8220
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8338
8221
|
// "div",document
|
|
8339
8222
|
parent = secondParam;
|
|
8340
8223
|
}
|
|
@@ -8420,8 +8303,7 @@
|
|
|
8420
8303
|
// "div",10000
|
|
8421
8304
|
timeout = secondParam;
|
|
8422
8305
|
}
|
|
8423
|
-
else if (typeof secondParam === "object" &&
|
|
8424
|
-
secondParam instanceof Node) {
|
|
8306
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8425
8307
|
// "div",document
|
|
8426
8308
|
parent = secondParam;
|
|
8427
8309
|
}
|
|
@@ -8554,8 +8436,7 @@
|
|
|
8554
8436
|
return flag;
|
|
8555
8437
|
}
|
|
8556
8438
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8557
|
-
if (typeof getCallBack !== "function" &&
|
|
8558
|
-
typeof setCallBack !== "function") {
|
|
8439
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8559
8440
|
return;
|
|
8560
8441
|
}
|
|
8561
8442
|
if (typeof getCallBack === "function") {
|
|
@@ -8607,13 +8488,27 @@
|
|
|
8607
8488
|
return;
|
|
8608
8489
|
}
|
|
8609
8490
|
let handleResult = handler(target);
|
|
8610
|
-
if (handleResult &&
|
|
8611
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8612
|
-
handleResult.isFind) {
|
|
8491
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8613
8492
|
return handleResult.data;
|
|
8614
8493
|
}
|
|
8615
8494
|
return this.queryProperty(handleResult.data, handler);
|
|
8616
8495
|
}
|
|
8496
|
+
/**
|
|
8497
|
+
* 异步-深度获取对象属性
|
|
8498
|
+
* @param target 待获取的对象
|
|
8499
|
+
* @param handler 获取属性的回调
|
|
8500
|
+
*/
|
|
8501
|
+
async asyncQueryProperty(target, handler) {
|
|
8502
|
+
if (target == null) {
|
|
8503
|
+
// @ts-ignore
|
|
8504
|
+
return;
|
|
8505
|
+
}
|
|
8506
|
+
let handleResult = await handler(target);
|
|
8507
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8508
|
+
return handleResult.data;
|
|
8509
|
+
}
|
|
8510
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8511
|
+
}
|
|
8617
8512
|
/**
|
|
8618
8513
|
* 创建一个新的Utils实例
|
|
8619
8514
|
* @param option
|