@whitesev/utils 2.3.6 → 2.3.8
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 +37 -22
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +37 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +37 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +37 -22
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +37 -22
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +37 -22
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +3 -3
- package/package.json +1 -1
- package/src/Utils.ts +48 -38
- package/src/indexedDB.ts +12 -10
package/dist/index.cjs.js
CHANGED
|
@@ -2682,6 +2682,10 @@ class indexedDB {
|
|
|
2682
2682
|
code: 401,
|
|
2683
2683
|
msg: "操作失败",
|
|
2684
2684
|
},
|
|
2685
|
+
empty: {
|
|
2686
|
+
code: 201,
|
|
2687
|
+
msg: "操作成功,但是没有数据",
|
|
2688
|
+
},
|
|
2685
2689
|
openFailed: { code: 91001, msg: "打开数据库失败" },
|
|
2686
2690
|
saveFailed: { code: 91002, msg: "保存数据失败" },
|
|
2687
2691
|
getFailed: { code: 91003, msg: "获取数据失败" },
|
|
@@ -2870,11 +2874,11 @@ class indexedDB {
|
|
|
2870
2874
|
/* result 返回的是 {key: string, value: any} */
|
|
2871
2875
|
/* 键值对存储 */
|
|
2872
2876
|
let data = result ? result.value : void 0;
|
|
2873
|
-
if (data) {
|
|
2877
|
+
if (data == null) {
|
|
2874
2878
|
resolve({
|
|
2875
2879
|
success: true,
|
|
2876
|
-
code: that.#statusCode.
|
|
2877
|
-
msg: that.#statusCode.
|
|
2880
|
+
code: that.#statusCode.empty.code,
|
|
2881
|
+
msg: that.#statusCode.empty.msg,
|
|
2878
2882
|
data: data,
|
|
2879
2883
|
event: event,
|
|
2880
2884
|
result: result,
|
|
@@ -2882,10 +2886,10 @@ class indexedDB {
|
|
|
2882
2886
|
}
|
|
2883
2887
|
else {
|
|
2884
2888
|
resolve({
|
|
2885
|
-
success:
|
|
2886
|
-
code: that.#statusCode.
|
|
2887
|
-
msg: that.#statusCode.
|
|
2888
|
-
data:
|
|
2889
|
+
success: true,
|
|
2890
|
+
code: that.#statusCode.operationSuccess.code,
|
|
2891
|
+
msg: that.#statusCode.operationSuccess.msg,
|
|
2892
|
+
data: data,
|
|
2889
2893
|
event: event,
|
|
2890
2894
|
result: result,
|
|
2891
2895
|
});
|
|
@@ -3952,7 +3956,7 @@ class Utils {
|
|
|
3952
3956
|
this.windowApi = new WindowApi(option);
|
|
3953
3957
|
}
|
|
3954
3958
|
/** 版本号 */
|
|
3955
|
-
version = "2024.10.
|
|
3959
|
+
version = "2024.10.19";
|
|
3956
3960
|
addStyle(cssText) {
|
|
3957
3961
|
if (typeof cssText !== "string") {
|
|
3958
3962
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -4099,22 +4103,33 @@ class Utils {
|
|
|
4099
4103
|
if (!UtilsContext.isDOM(element)) {
|
|
4100
4104
|
throw new Error("Utils.checkUserClickInNode 参数 targetNode 必须为 Element|Node 类型");
|
|
4101
4105
|
}
|
|
4102
|
-
let
|
|
4103
|
-
let
|
|
4104
|
-
let
|
|
4105
|
-
|
|
4106
|
-
let
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4106
|
+
let clickEvent = UtilsContext.windowApi.window.event;
|
|
4107
|
+
let touchEvent = UtilsContext.windowApi.window.event;
|
|
4108
|
+
let $click = clickEvent?.composedPath()?.[0];
|
|
4109
|
+
// 点击的x坐标
|
|
4110
|
+
let clickPosX = clickEvent?.clientX != null
|
|
4111
|
+
? clickEvent.clientX
|
|
4112
|
+
: touchEvent.touches[0].clientX;
|
|
4113
|
+
// 点击的y坐标
|
|
4114
|
+
let clickPosY = clickEvent?.clientY != null
|
|
4115
|
+
? clickEvent.clientY
|
|
4116
|
+
: touchEvent.touches[0].clientY;
|
|
4117
|
+
let {
|
|
4118
|
+
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
4119
|
+
left: elementPosXLeft,
|
|
4120
|
+
/* 要检测的元素的相对屏幕的横坐标最右边 */
|
|
4121
|
+
right: elementPosXRight,
|
|
4122
|
+
/* 要检测的元素的相对屏幕的纵坐标最上边 */
|
|
4123
|
+
top: elementPosYTop,
|
|
4124
|
+
/* 要检测的元素的相对屏幕的纵坐标最下边 */
|
|
4125
|
+
bottom: elementPosYBottom, } = element.getBoundingClientRect();
|
|
4126
|
+
if (clickPosX >= elementPosXLeft &&
|
|
4127
|
+
clickPosX <= elementPosXRight &&
|
|
4128
|
+
clickPosY >= elementPosYTop &&
|
|
4129
|
+
clickPosY <= elementPosYBottom) {
|
|
4114
4130
|
return true;
|
|
4115
4131
|
}
|
|
4116
|
-
else if (
|
|
4117
|
-
element.innerHTML.includes(clickNodeHTML)) {
|
|
4132
|
+
else if (($click && element.contains($click)) || $click == element) {
|
|
4118
4133
|
/* 这种情况是应对在界面中隐藏的元素,getBoundingClientRect获取的都是0 */
|
|
4119
4134
|
return true;
|
|
4120
4135
|
}
|