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