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