@whitesev/utils 1.6.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.amd.js +52 -34
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +52 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +52 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +52 -34
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +52 -34
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +52 -34
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Dictionary.d.ts +1 -1
- package/package.json +13 -2
- package/index.ts +0 -3
- package/rollup.config.js +0 -57
- package/src/AjaxHookerType.ts +0 -155
- package/src/ColorConversion.ts +0 -130
- package/src/Dictionary.ts +0 -152
- package/src/Event.ts +0 -189
- package/src/GBKEncoder.ts +0 -120
- package/src/Hooks.ts +0 -87
- package/src/Httpx.ts +0 -2402
- package/src/LockFunction.ts +0 -67
- package/src/Log.ts +0 -284
- package/src/Progress.ts +0 -143
- package/src/TryCatch.ts +0 -107
- package/src/Utils.ts +0 -4917
- package/src/UtilsCommon.ts +0 -20
- package/src/UtilsCore.ts +0 -47
- package/src/UtilsGMCookie.ts +0 -261
- package/src/UtilsGMMenu.ts +0 -530
- package/src/VueObject.ts +0 -128
- package/src/ajaxHooker/ajaxHooker.js +0 -566
- package/src/indexedDB.ts +0 -419
- package/tsconfig.json +0 -31
package/dist/index.esm.js
CHANGED
|
@@ -1563,11 +1563,13 @@ class Httpx {
|
|
|
1563
1563
|
* @private
|
|
1564
1564
|
*/
|
|
1565
1565
|
beforeRequestCallBack(details) {
|
|
1566
|
-
if (
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1566
|
+
if (details.allowInterceptConfig) {
|
|
1567
|
+
// 首先配置得存在,不然默认允许拦截
|
|
1568
|
+
if (typeof details.allowInterceptConfig.beforeRequest === "boolean" &&
|
|
1569
|
+
!details.allowInterceptConfig.beforeRequest) {
|
|
1570
|
+
// 设置了禁止拦截
|
|
1571
|
+
return details;
|
|
1572
|
+
}
|
|
1571
1573
|
}
|
|
1572
1574
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1573
1575
|
let item = this.$config.configList[index];
|
|
@@ -1630,11 +1632,14 @@ class Httpx {
|
|
|
1630
1632
|
* @param details 请求的配置
|
|
1631
1633
|
*/
|
|
1632
1634
|
successResponseCallBack(response, details) {
|
|
1633
|
-
if (
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1635
|
+
if (details.allowInterceptConfig) {
|
|
1636
|
+
// 首先配置得存在,不然默认允许拦截
|
|
1637
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
1638
|
+
"boolean" &&
|
|
1639
|
+
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
1640
|
+
// 设置了禁止拦截
|
|
1641
|
+
return details;
|
|
1642
|
+
}
|
|
1638
1643
|
}
|
|
1639
1644
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1640
1645
|
let item = this.$config.configList[index];
|
|
@@ -1651,11 +1656,14 @@ class Httpx {
|
|
|
1651
1656
|
* @param data 配置
|
|
1652
1657
|
*/
|
|
1653
1658
|
errorResponseCallBack(data) {
|
|
1654
|
-
if (
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
+
if (data.details.allowInterceptConfig) {
|
|
1660
|
+
// 首先配置得存在,不然默认允许拦截
|
|
1661
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
1662
|
+
"boolean" &&
|
|
1663
|
+
!data.details.allowInterceptConfig.afterResponseError) {
|
|
1664
|
+
// 设置了禁止拦截
|
|
1665
|
+
return data;
|
|
1666
|
+
}
|
|
1659
1667
|
}
|
|
1660
1668
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1661
1669
|
let item = this.$config.configList[index];
|
|
@@ -3276,14 +3284,14 @@ const TryCatch = function (...args) {
|
|
|
3276
3284
|
};
|
|
3277
3285
|
|
|
3278
3286
|
class UtilsDictionary {
|
|
3279
|
-
items = {};
|
|
3287
|
+
#items = {};
|
|
3280
3288
|
constructor() { }
|
|
3281
3289
|
/**
|
|
3282
3290
|
* 检查是否有某一个键
|
|
3283
3291
|
* @param key 键
|
|
3284
3292
|
*/
|
|
3285
3293
|
has(key) {
|
|
3286
|
-
return this
|
|
3294
|
+
return this.#items.hasOwnProperty(key);
|
|
3287
3295
|
}
|
|
3288
3296
|
/**
|
|
3289
3297
|
* 检查已有的键中是否以xx开头
|
|
@@ -3307,7 +3315,7 @@ class UtilsDictionary {
|
|
|
3307
3315
|
let result = null;
|
|
3308
3316
|
for (const keyName of allKeys) {
|
|
3309
3317
|
if (keyName.startsWith(key)) {
|
|
3310
|
-
result = this
|
|
3318
|
+
result = this.#items[keyName];
|
|
3311
3319
|
break;
|
|
3312
3320
|
}
|
|
3313
3321
|
}
|
|
@@ -3322,7 +3330,7 @@ class UtilsDictionary {
|
|
|
3322
3330
|
if (key === void 0) {
|
|
3323
3331
|
throw new Error("Utils.Dictionary().set 参数 key 不能为空");
|
|
3324
3332
|
}
|
|
3325
|
-
this
|
|
3333
|
+
this.#items[key] = val;
|
|
3326
3334
|
}
|
|
3327
3335
|
/**
|
|
3328
3336
|
* 删除某一个键
|
|
@@ -3330,7 +3338,7 @@ class UtilsDictionary {
|
|
|
3330
3338
|
*/
|
|
3331
3339
|
delete(key) {
|
|
3332
3340
|
if (this.has(key)) {
|
|
3333
|
-
Reflect.deleteProperty(this
|
|
3341
|
+
Reflect.deleteProperty(this.#items, key);
|
|
3334
3342
|
return true;
|
|
3335
3343
|
}
|
|
3336
3344
|
return false;
|
|
@@ -3358,8 +3366,8 @@ class UtilsDictionary {
|
|
|
3358
3366
|
* 清空字典
|
|
3359
3367
|
*/
|
|
3360
3368
|
clear() {
|
|
3361
|
-
this
|
|
3362
|
-
this
|
|
3369
|
+
this.#items = void 0;
|
|
3370
|
+
this.#items = {};
|
|
3363
3371
|
}
|
|
3364
3372
|
/**
|
|
3365
3373
|
* 获取字典的长度
|
|
@@ -3377,14 +3385,14 @@ class UtilsDictionary {
|
|
|
3377
3385
|
* 返回字典本身
|
|
3378
3386
|
*/
|
|
3379
3387
|
getItems() {
|
|
3380
|
-
return this
|
|
3388
|
+
return this.#items;
|
|
3381
3389
|
}
|
|
3382
3390
|
/**
|
|
3383
3391
|
* 合并另一个字典
|
|
3384
3392
|
* @param data 需要合并的字典
|
|
3385
3393
|
*/
|
|
3386
3394
|
concat(data) {
|
|
3387
|
-
this
|
|
3395
|
+
this.#items = utils.assign(this.#items, data.getItems());
|
|
3388
3396
|
}
|
|
3389
3397
|
forEach(callbackfn) {
|
|
3390
3398
|
for (const key in this.getItems()) {
|
|
@@ -3425,7 +3433,7 @@ class Utils {
|
|
|
3425
3433
|
UtilsCore.init(option);
|
|
3426
3434
|
}
|
|
3427
3435
|
/** 版本号 */
|
|
3428
|
-
version = "2024.
|
|
3436
|
+
version = "2024.7.20";
|
|
3429
3437
|
addStyle(cssText) {
|
|
3430
3438
|
if (typeof cssText !== "string") {
|
|
3431
3439
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -4119,21 +4127,31 @@ class Utils {
|
|
|
4119
4127
|
}
|
|
4120
4128
|
}
|
|
4121
4129
|
getMaxZIndex(deviation = 1) {
|
|
4122
|
-
let nodeIndexList = [];
|
|
4123
4130
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
4124
|
-
|
|
4131
|
+
// 最大值2147483647
|
|
4132
|
+
let maxZIndex = Math.pow(2, 31) - 1;
|
|
4133
|
+
// 比较值2000000000
|
|
4134
|
+
let maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
4135
|
+
// 当前页面最大的z-index
|
|
4136
|
+
let zIndex = 0;
|
|
4137
|
+
document.querySelectorAll("*").forEach((element, index) => {
|
|
4125
4138
|
let nodeStyle = window.getComputedStyle(element);
|
|
4126
4139
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
4127
4140
|
if (nodeStyle.position !== "static" && nodeStyle.display !== "none") {
|
|
4128
|
-
|
|
4141
|
+
let nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
4142
|
+
if (!isNaN(nodeZIndex)) {
|
|
4143
|
+
if (nodeZIndex > zIndex) {
|
|
4144
|
+
zIndex = nodeZIndex;
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4129
4147
|
}
|
|
4130
4148
|
});
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
return
|
|
4149
|
+
zIndex += deviation;
|
|
4150
|
+
if (zIndex >= maxZIndexCompare) {
|
|
4151
|
+
// 最好不要超过最大值
|
|
4152
|
+
zIndex = maxZIndex;
|
|
4153
|
+
}
|
|
4154
|
+
return zIndex;
|
|
4137
4155
|
}
|
|
4138
4156
|
getMinValue(...args) {
|
|
4139
4157
|
let result = [...args];
|