@whitesev/utils 2.2.5 → 2.2.7
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 +57 -9
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +57 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +57 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +57 -9
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +57 -9
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +57 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Httpx.d.ts +7 -6
- package/dist/types/src/Utils.d.ts +39 -3
- package/package.json +3 -2
- package/src/Httpx.ts +7 -6
- package/src/Utils.ts +99 -20
package/dist/index.iife.js
CHANGED
|
@@ -3654,7 +3654,7 @@ var Utils = (function () {
|
|
|
3654
3654
|
this.windowApi = new WindowApi(option);
|
|
3655
3655
|
}
|
|
3656
3656
|
/** 版本号 */
|
|
3657
|
-
version = "2024.9.
|
|
3657
|
+
version = "2024.9.10";
|
|
3658
3658
|
addStyle(cssText) {
|
|
3659
3659
|
if (typeof cssText !== "string") {
|
|
3660
3660
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -4350,32 +4350,66 @@ var Utils = (function () {
|
|
|
4350
4350
|
return Math.max(...newResult);
|
|
4351
4351
|
}
|
|
4352
4352
|
}
|
|
4353
|
-
|
|
4353
|
+
getMaxZIndexNodeInfo(deviation = 1) {
|
|
4354
4354
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
4355
|
+
const UtilsContext = this;
|
|
4355
4356
|
// 最大值2147483647
|
|
4356
|
-
|
|
4357
|
+
const maxZIndex = Math.pow(2, 31) - 1;
|
|
4357
4358
|
// 比较值2000000000
|
|
4358
|
-
|
|
4359
|
+
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
4359
4360
|
// 当前页面最大的z-index
|
|
4360
4361
|
let zIndex = 0;
|
|
4361
|
-
|
|
4362
|
-
|
|
4362
|
+
// 当前的最大z-index的元素,调试使用
|
|
4363
|
+
// @ts-ignore
|
|
4364
|
+
let maxZIndexNode = null;
|
|
4365
|
+
/**
|
|
4366
|
+
* 元素是否可见
|
|
4367
|
+
* @param $css
|
|
4368
|
+
*/
|
|
4369
|
+
function isVisibleNode($css) {
|
|
4370
|
+
return $css.position !== "static" && $css.display !== "none";
|
|
4371
|
+
}
|
|
4372
|
+
/**
|
|
4373
|
+
* 查询元素的z-index
|
|
4374
|
+
* 并比较值是否是已获取的最大值
|
|
4375
|
+
* @param $ele
|
|
4376
|
+
*/
|
|
4377
|
+
function queryMaxZIndex($ele) {
|
|
4378
|
+
/** 元素的样式 */
|
|
4379
|
+
const nodeStyle = UtilsContext.windowApi.window.getComputedStyle($ele);
|
|
4363
4380
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
4364
|
-
if (nodeStyle
|
|
4381
|
+
if (isVisibleNode(nodeStyle)) {
|
|
4365
4382
|
let nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
4366
4383
|
if (!isNaN(nodeZIndex)) {
|
|
4367
4384
|
if (nodeZIndex > zIndex) {
|
|
4385
|
+
// 赋值到全局
|
|
4368
4386
|
zIndex = nodeZIndex;
|
|
4387
|
+
maxZIndexNode = $ele;
|
|
4369
4388
|
}
|
|
4370
4389
|
}
|
|
4390
|
+
// 判断shadowRoot
|
|
4391
|
+
if ($ele.shadowRoot != null && $ele instanceof ShadowRoot) {
|
|
4392
|
+
$ele.shadowRoot.querySelectorAll("*").forEach(($shadowEle) => {
|
|
4393
|
+
queryMaxZIndex($shadowEle);
|
|
4394
|
+
});
|
|
4395
|
+
}
|
|
4371
4396
|
}
|
|
4397
|
+
}
|
|
4398
|
+
this.windowApi.document.querySelectorAll("*").forEach(($ele, index) => {
|
|
4399
|
+
queryMaxZIndex($ele);
|
|
4372
4400
|
});
|
|
4373
4401
|
zIndex += deviation;
|
|
4374
4402
|
if (zIndex >= maxZIndexCompare) {
|
|
4375
4403
|
// 最好不要超过最大值
|
|
4376
4404
|
zIndex = maxZIndex;
|
|
4377
4405
|
}
|
|
4378
|
-
return
|
|
4406
|
+
return {
|
|
4407
|
+
node: maxZIndexNode,
|
|
4408
|
+
zIndex: zIndex,
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
getMaxZIndex(deviation = 1) {
|
|
4412
|
+
return this.getMaxZIndexNodeInfo(deviation).zIndex;
|
|
4379
4413
|
}
|
|
4380
4414
|
getMinValue(...args) {
|
|
4381
4415
|
let result = [...args];
|
|
@@ -6094,7 +6128,7 @@ var Utils = (function () {
|
|
|
6094
6128
|
});
|
|
6095
6129
|
return result;
|
|
6096
6130
|
}
|
|
6097
|
-
toSearchParamsStr(obj) {
|
|
6131
|
+
toSearchParamsStr(obj, addPrefix) {
|
|
6098
6132
|
let UtilsContext = this;
|
|
6099
6133
|
let searhParamsStr = "";
|
|
6100
6134
|
if (Array.isArray(obj)) {
|
|
@@ -6110,8 +6144,22 @@ var Utils = (function () {
|
|
|
6110
6144
|
else {
|
|
6111
6145
|
searhParamsStr = new URLSearchParams(Object.entries(obj)).toString();
|
|
6112
6146
|
}
|
|
6147
|
+
if (addPrefix && !searhParamsStr.startsWith("?")) {
|
|
6148
|
+
searhParamsStr = "?" + searhParamsStr;
|
|
6149
|
+
}
|
|
6113
6150
|
return searhParamsStr;
|
|
6114
6151
|
}
|
|
6152
|
+
/**
|
|
6153
|
+
* 将UrlSearchParams格式的字符串转为对象
|
|
6154
|
+
*/
|
|
6155
|
+
searchParamStrToObj(searhParamsStr) {
|
|
6156
|
+
if (typeof searhParamsStr !== "string") {
|
|
6157
|
+
// @ts-ignore
|
|
6158
|
+
return {};
|
|
6159
|
+
}
|
|
6160
|
+
// @ts-ignore
|
|
6161
|
+
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
6162
|
+
}
|
|
6115
6163
|
/**
|
|
6116
6164
|
* 提供一个封装了 try-catch 的函数,可以执行传入的函数并捕获其可能抛出的错误,并通过传入的错误处理函数进行处理。
|
|
6117
6165
|
* @example
|