@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/README.md
CHANGED
package/dist/index.amd.js
CHANGED
|
@@ -1565,11 +1565,13 @@ define((function () { 'use strict';
|
|
|
1565
1565
|
* @private
|
|
1566
1566
|
*/
|
|
1567
1567
|
beforeRequestCallBack(details) {
|
|
1568
|
-
if (
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1568
|
+
if (details.allowInterceptConfig) {
|
|
1569
|
+
// 首先配置得存在,不然默认允许拦截
|
|
1570
|
+
if (typeof details.allowInterceptConfig.beforeRequest === "boolean" &&
|
|
1571
|
+
!details.allowInterceptConfig.beforeRequest) {
|
|
1572
|
+
// 设置了禁止拦截
|
|
1573
|
+
return details;
|
|
1574
|
+
}
|
|
1573
1575
|
}
|
|
1574
1576
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1575
1577
|
let item = this.$config.configList[index];
|
|
@@ -1632,11 +1634,14 @@ define((function () { 'use strict';
|
|
|
1632
1634
|
* @param details 请求的配置
|
|
1633
1635
|
*/
|
|
1634
1636
|
successResponseCallBack(response, details) {
|
|
1635
|
-
if (
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1637
|
+
if (details.allowInterceptConfig) {
|
|
1638
|
+
// 首先配置得存在,不然默认允许拦截
|
|
1639
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
1640
|
+
"boolean" &&
|
|
1641
|
+
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
1642
|
+
// 设置了禁止拦截
|
|
1643
|
+
return details;
|
|
1644
|
+
}
|
|
1640
1645
|
}
|
|
1641
1646
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1642
1647
|
let item = this.$config.configList[index];
|
|
@@ -1653,11 +1658,14 @@ define((function () { 'use strict';
|
|
|
1653
1658
|
* @param data 配置
|
|
1654
1659
|
*/
|
|
1655
1660
|
errorResponseCallBack(data) {
|
|
1656
|
-
if (
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
+
if (data.details.allowInterceptConfig) {
|
|
1662
|
+
// 首先配置得存在,不然默认允许拦截
|
|
1663
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
1664
|
+
"boolean" &&
|
|
1665
|
+
!data.details.allowInterceptConfig.afterResponseError) {
|
|
1666
|
+
// 设置了禁止拦截
|
|
1667
|
+
return data;
|
|
1668
|
+
}
|
|
1661
1669
|
}
|
|
1662
1670
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1663
1671
|
let item = this.$config.configList[index];
|
|
@@ -3278,14 +3286,14 @@ define((function () { 'use strict';
|
|
|
3278
3286
|
};
|
|
3279
3287
|
|
|
3280
3288
|
class UtilsDictionary {
|
|
3281
|
-
items = {};
|
|
3289
|
+
#items = {};
|
|
3282
3290
|
constructor() { }
|
|
3283
3291
|
/**
|
|
3284
3292
|
* 检查是否有某一个键
|
|
3285
3293
|
* @param key 键
|
|
3286
3294
|
*/
|
|
3287
3295
|
has(key) {
|
|
3288
|
-
return this
|
|
3296
|
+
return this.#items.hasOwnProperty(key);
|
|
3289
3297
|
}
|
|
3290
3298
|
/**
|
|
3291
3299
|
* 检查已有的键中是否以xx开头
|
|
@@ -3309,7 +3317,7 @@ define((function () { 'use strict';
|
|
|
3309
3317
|
let result = null;
|
|
3310
3318
|
for (const keyName of allKeys) {
|
|
3311
3319
|
if (keyName.startsWith(key)) {
|
|
3312
|
-
result = this
|
|
3320
|
+
result = this.#items[keyName];
|
|
3313
3321
|
break;
|
|
3314
3322
|
}
|
|
3315
3323
|
}
|
|
@@ -3324,7 +3332,7 @@ define((function () { 'use strict';
|
|
|
3324
3332
|
if (key === void 0) {
|
|
3325
3333
|
throw new Error("Utils.Dictionary().set 参数 key 不能为空");
|
|
3326
3334
|
}
|
|
3327
|
-
this
|
|
3335
|
+
this.#items[key] = val;
|
|
3328
3336
|
}
|
|
3329
3337
|
/**
|
|
3330
3338
|
* 删除某一个键
|
|
@@ -3332,7 +3340,7 @@ define((function () { 'use strict';
|
|
|
3332
3340
|
*/
|
|
3333
3341
|
delete(key) {
|
|
3334
3342
|
if (this.has(key)) {
|
|
3335
|
-
Reflect.deleteProperty(this
|
|
3343
|
+
Reflect.deleteProperty(this.#items, key);
|
|
3336
3344
|
return true;
|
|
3337
3345
|
}
|
|
3338
3346
|
return false;
|
|
@@ -3360,8 +3368,8 @@ define((function () { 'use strict';
|
|
|
3360
3368
|
* 清空字典
|
|
3361
3369
|
*/
|
|
3362
3370
|
clear() {
|
|
3363
|
-
this
|
|
3364
|
-
this
|
|
3371
|
+
this.#items = void 0;
|
|
3372
|
+
this.#items = {};
|
|
3365
3373
|
}
|
|
3366
3374
|
/**
|
|
3367
3375
|
* 获取字典的长度
|
|
@@ -3379,14 +3387,14 @@ define((function () { 'use strict';
|
|
|
3379
3387
|
* 返回字典本身
|
|
3380
3388
|
*/
|
|
3381
3389
|
getItems() {
|
|
3382
|
-
return this
|
|
3390
|
+
return this.#items;
|
|
3383
3391
|
}
|
|
3384
3392
|
/**
|
|
3385
3393
|
* 合并另一个字典
|
|
3386
3394
|
* @param data 需要合并的字典
|
|
3387
3395
|
*/
|
|
3388
3396
|
concat(data) {
|
|
3389
|
-
this
|
|
3397
|
+
this.#items = utils.assign(this.#items, data.getItems());
|
|
3390
3398
|
}
|
|
3391
3399
|
forEach(callbackfn) {
|
|
3392
3400
|
for (const key in this.getItems()) {
|
|
@@ -3427,7 +3435,7 @@ define((function () { 'use strict';
|
|
|
3427
3435
|
UtilsCore.init(option);
|
|
3428
3436
|
}
|
|
3429
3437
|
/** 版本号 */
|
|
3430
|
-
version = "2024.
|
|
3438
|
+
version = "2024.7.20";
|
|
3431
3439
|
addStyle(cssText) {
|
|
3432
3440
|
if (typeof cssText !== "string") {
|
|
3433
3441
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -4121,21 +4129,31 @@ define((function () { 'use strict';
|
|
|
4121
4129
|
}
|
|
4122
4130
|
}
|
|
4123
4131
|
getMaxZIndex(deviation = 1) {
|
|
4124
|
-
let nodeIndexList = [];
|
|
4125
4132
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
4126
|
-
|
|
4133
|
+
// 最大值2147483647
|
|
4134
|
+
let maxZIndex = Math.pow(2, 31) - 1;
|
|
4135
|
+
// 比较值2000000000
|
|
4136
|
+
let maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
4137
|
+
// 当前页面最大的z-index
|
|
4138
|
+
let zIndex = 0;
|
|
4139
|
+
document.querySelectorAll("*").forEach((element, index) => {
|
|
4127
4140
|
let nodeStyle = window.getComputedStyle(element);
|
|
4128
4141
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
4129
4142
|
if (nodeStyle.position !== "static" && nodeStyle.display !== "none") {
|
|
4130
|
-
|
|
4143
|
+
let nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
4144
|
+
if (!isNaN(nodeZIndex)) {
|
|
4145
|
+
if (nodeZIndex > zIndex) {
|
|
4146
|
+
zIndex = nodeZIndex;
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4131
4149
|
}
|
|
4132
4150
|
});
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
return
|
|
4151
|
+
zIndex += deviation;
|
|
4152
|
+
if (zIndex >= maxZIndexCompare) {
|
|
4153
|
+
// 最好不要超过最大值
|
|
4154
|
+
zIndex = maxZIndex;
|
|
4155
|
+
}
|
|
4156
|
+
return zIndex;
|
|
4139
4157
|
}
|
|
4140
4158
|
getMinValue(...args) {
|
|
4141
4159
|
let result = [...args];
|