@das-fed/utils 1.0.1 → 1.0.3

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.
Files changed (131) hide show
  1. package/api-services/index.d.ts +1 -0
  2. package/api-services/index.js +3 -19845
  3. package/api-services/modules/app-manage.d.ts +2 -0
  4. package/api-services/modules/app-manage.js +5 -6
  5. package/api-services/modules/authentication.d.ts +2 -0
  6. package/api-services/modules/authentication.js +5 -6
  7. package/api-services/modules/bems.d.ts +6 -0
  8. package/api-services/modules/bems.js +8 -10
  9. package/api-services/modules/contract.d.ts +2 -0
  10. package/api-services/modules/contract.js +5 -6
  11. package/api-services/modules/duty-manage.d.ts +7 -0
  12. package/api-services/modules/duty-manage.js +9 -10
  13. package/api-services/modules/enterpriseright.d.ts +2 -0
  14. package/api-services/modules/enterpriseright.js +5 -6
  15. package/api-services/modules/file.d.ts +36 -0
  16. package/api-services/modules/file.js +449 -354
  17. package/api-services/modules/gateway-edge.d.ts +2 -0
  18. package/api-services/modules/gateway-edge.js +5 -6
  19. package/api-services/modules/index.d.ts +21 -0
  20. package/api-services/modules/index.js +501 -435
  21. package/api-services/modules/iot.d.ts +15 -0
  22. package/api-services/modules/iot.js +17 -18
  23. package/api-services/modules/justauth.d.ts +3 -0
  24. package/api-services/modules/justauth.js +6 -7
  25. package/api-services/modules/knowledge.d.ts +2 -0
  26. package/api-services/modules/knowledge.js +5 -6
  27. package/api-services/modules/link.d.ts +2 -0
  28. package/api-services/modules/link.js +5 -6
  29. package/api-services/modules/permission.d.ts +2 -0
  30. package/api-services/modules/permission.js +5 -6
  31. package/api-services/modules/platformManage.d.ts +14 -0
  32. package/api-services/modules/platformManage.js +12 -13
  33. package/api-services/modules/portal.d.ts +2 -0
  34. package/api-services/modules/portal.js +5 -6
  35. package/api-services/modules/space-manage.d.ts +2 -0
  36. package/api-services/modules/space-manage.js +5 -6
  37. package/api-services/modules/super-admin.d.ts +8 -0
  38. package/api-services/modules/super-admin.js +8 -9
  39. package/api-services/modules/supplier.d.ts +6 -0
  40. package/api-services/modules/supplier.js +7 -8
  41. package/api-services/modules/supplychain-manage.d.ts +2 -0
  42. package/api-services/modules/supplychain-manage.js +5 -6
  43. package/api-services/modules/systemConfiguration.d.ts +2 -0
  44. package/api-services/modules/systemConfiguration.js +5 -6
  45. package/api-services/modules/tool.d.ts +2 -0
  46. package/api-services/modules/tool.js +5 -6
  47. package/api-services/src/create-service.d.ts +2 -0
  48. package/api-services/src/create-service.js +3119 -19726
  49. package/api-services/src/sso.d.ts +29 -0
  50. package/api-services/src/sso.js +1547 -156
  51. package/api-services/src/util.d.ts +1 -0
  52. package/api-services/src/util.js +1462 -19
  53. package/atob/index.d.ts +2 -0
  54. package/atob/index.js +9 -10
  55. package/common-info/getIframeUrl.d.ts +9 -0
  56. package/common-info/getIframeUrl.js +9 -11
  57. package/common-info/index.d.ts +42 -0
  58. package/common-info/index.js +138 -272
  59. package/common-info/setInfoFromUrl.d.ts +8 -0
  60. package/common-info/setInfoFromUrl.js +60 -128
  61. package/common-tools/arr-tools.d.ts +15 -0
  62. package/common-tools/arr-tools.js +6 -13
  63. package/common-tools/date-format.d.ts +7 -0
  64. package/common-tools/date-format.js +18 -21
  65. package/common-tools/get-url-params.d.ts +33 -0
  66. package/common-tools/get-url-params.js +48 -88
  67. package/common-tools/handle-data.d.ts +6 -0
  68. package/common-tools/handle-data.js +3 -4
  69. package/common-tools/index.d.ts +7 -0
  70. package/common-tools/index.js +7 -213
  71. package/common-tools/nest-tree-format.d.ts +30 -0
  72. package/common-tools/nest-tree-format.js +22 -49
  73. package/common-tools/obj-tools.d.ts +7 -0
  74. package/common-tools/obj-tools.js +17 -18
  75. package/common-tools/setHtmlMinWH.d.ts +5 -0
  76. package/common-tools/setHtmlMinWH.js +6 -10
  77. package/common-tools/throttled.d.ts +7 -0
  78. package/common-tools/throttled.js +7 -16
  79. package/config/index.d.ts +2 -0
  80. package/config/index.js +8 -25
  81. package/curring-http/index.d.ts +11 -0
  82. package/curring-http/index.js +5150 -17289
  83. package/directive/auth.d.ts +8 -0
  84. package/directive/auth.js +54 -104
  85. package/directive/clickOutside.d.ts +5 -0
  86. package/directive/clickOutside.js +23 -49
  87. package/directive/hoverInside.d.ts +5 -0
  88. package/directive/hoverInside.js +16 -35
  89. package/directive/index.d.ts +3 -0
  90. package/directive/index.js +7 -182
  91. package/directive/utils.d.ts +7 -0
  92. package/directive/utils.js +6 -11
  93. package/dom-check-in/index.d.ts +6 -0
  94. package/dom-check-in/index.js +7 -15
  95. package/dom-watcher/index.d.ts +25 -0
  96. package/dom-watcher/index.js +7 -8
  97. package/hooks/popup-manager/use-zindex.d.ts +5 -0
  98. package/hooks/popup-manager/use-zindex.js +17 -36
  99. package/index.d.ts +2 -0
  100. package/index.js +2 -215
  101. package/load-js/index.d.ts +3 -0
  102. package/load-js/index.js +10 -20
  103. package/oss/index.d.ts +2 -0
  104. package/oss/index.js +11 -15
  105. package/package.json +8 -13
  106. package/pinyin-first-character/index.d.ts +2 -0
  107. package/pinyin-first-character/index.js +25011 -12217
  108. package/process-engine-info/index.d.ts +10 -0
  109. package/process-engine-info/index.js +8 -10
  110. package/pure-image-src/index.d.ts +2 -0
  111. package/pure-image-src/index.js +3 -29
  112. package/set-personal-info/index.d.ts +5 -0
  113. package/set-personal-info/index.js +1460 -16
  114. package/size-watcher/index.d.ts +6 -0
  115. package/size-watcher/index.js +17 -24
  116. package/style/index.d.ts +2 -0
  117. package/style/index.js +62 -103
  118. package/style/math.d.ts +9 -0
  119. package/style/math.js +16 -31
  120. package/style/style.d.ts +30 -0
  121. package/style/style.js +49 -72
  122. package/token-tools/index.d.ts +18 -0
  123. package/token-tools/index.js +72 -149
  124. package/vue/hooks/use-model-value.d.ts +3 -0
  125. package/vue/hooks/use-model-value.js +9 -10
  126. package/vue/index.d.ts +1 -0
  127. package/vue/index.js +3 -10
  128. package/webSocket-service/index.d.ts +40 -0
  129. package/webSocket-service/index.js +62 -138
  130. package/with-install/index.d.ts +10 -0
  131. package/with-install/index.js +5 -7
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 权限控制工具
3
+ * @param el 绑定的dom
4
+ * @param binding 使用指令时对应binding,使用函数时对应options
5
+ * @param vnode
6
+ * @returns 是否有权限
7
+ */
8
+ export declare const vAuth: (el: any, binding: any) => boolean;
package/directive/auth.js CHANGED
@@ -1,114 +1,64 @@
1
- import { getUrlParams, flatTree } from '@das-fed/utils/common-tools';
2
- import { getTabInfo, getSubApps, getPageAuth } from '@das-fed/utils/common-info';
3
-
4
- const getEl = async (el, options) => {
5
- let res = el;
6
- if (options?.target) {
7
- if (typeof options.target === "string")
8
- res = options.target;
9
- if (typeof options.target === "function")
10
- res = await options.target(el);
11
- }
12
- return res;
13
- };
14
-
15
- const hasBtnAuth = (btnList, code) => {
16
- if (!btnList || !code)
17
- return false;
18
- if (typeof code === "string") {
19
- const currentItem = btnList.find((item) => item.code === code);
20
- return !!currentItem;
21
- } else {
22
- let flag = false;
23
- for (let value of code) {
24
- const currentItem = btnList.find((item) => item.code === value);
25
- if (currentItem) {
26
- flag = true;
1
+ import { getUrlParams as g, flatTree as P } from "@das-fed/utils/common-tools";
2
+ import { getSubApps as v, getPageAuth as i } from "@das-fed/utils/common-info";
3
+ import { getEl as o } from "@das-fed/utils/directive/utils";
4
+ const A = (e, t) => {
5
+ if (!e || !t)
6
+ return !1;
7
+ if (typeof t == "string")
8
+ return !!e.find((s) => s.code === t);
9
+ {
10
+ let r = !1;
11
+ for (let s of t)
12
+ if (e.find((a) => a.code === s)) {
13
+ r = !0;
27
14
  break;
28
15
  }
29
- }
30
- return flag;
16
+ return r;
31
17
  }
32
- };
33
- const hasPermission = (options) => {
34
- const code = options?.code ?? "";
35
- const path = options?.path ?? location.pathname;
36
- const applicationCode = options?.applicationCode ?? "";
37
- let menuCode = "";
38
- if (window.__IN_MICRO_APP__) {
39
- menuCode = options?.menuCode ? options.menuCode : getUrlParams(location.href, "menu");
40
- } else {
41
- menuCode = options?.menuCode ? options.menuCode : getTabInfo().currentTab?.code;
42
- }
43
- if (!menuCode) {
44
- const currentMenus = getSubApps().currentSubApp?.menus ?? [];
45
- if (currentMenus && currentMenus.length) {
46
- const flatMenus = flatTree(currentMenus).filter((item) => item?.routeUrl);
47
- if (flatMenus && flatMenus.length) {
48
- const currentMenu = flatMenus.find((item) => {
49
- if (item?.applicationPath) {
50
- return path?.includes("/" + item.applicationPath + item.routeUrl);
51
- } else {
52
- return path?.includes(item.routeUrl);
53
- }
54
- });
55
- if (currentMenu)
56
- menuCode = currentMenu?.code ?? "";
18
+ }, h = (e) => {
19
+ var d;
20
+ const t = (e == null ? void 0 : e.code) ?? "", r = (e == null ? void 0 : e.path) ?? location.pathname, s = (e == null ? void 0 : e.applicationCode) ?? "";
21
+ let l = "";
22
+ if (l = e != null && e.menuCode ? e.menuCode : g(location.href, "menu"), !l) {
23
+ const c = ((d = v().currentSubApp) == null ? void 0 : d.menus) ?? [];
24
+ if (c && c.length) {
25
+ const n = P(c).filter((f) => f == null ? void 0 : f.routeUrl);
26
+ if (n && n.length) {
27
+ const f = n.find((u) => u != null && u.applicationPath ? r == null ? void 0 : r.includes("/" + u.applicationPath + u.routeUrl) : r == null ? void 0 : r.includes(u.routeUrl));
28
+ f && (l = (f == null ? void 0 : f.code) ?? "");
57
29
  }
58
30
  }
59
31
  }
60
- let flag = false;
61
- if (code) {
62
- const btnList = getPageAuth(menuCode, applicationCode) ?? [];
63
- flag = hasBtnAuth(btnList, code);
64
- } else {
65
- flag = !!getPageAuth(menuCode, applicationCode);
66
- }
67
- return flag;
68
- };
69
- const removeEl = (el, type) => {
70
- if (type === "hide") {
71
- el.classList.add("is-hide");
72
- } else {
73
- el.setAttribute("disabled", "");
74
- el.classList.add("is-disabled");
75
- }
76
- };
77
- const addEl = (el, type) => {
78
- if (type === "hide") {
79
- el.classList.remove("is-hide");
80
- } else {
81
- el.removeAttribute("disabled");
82
- el.classList.remove("is-disabled");
83
- }
84
- };
85
- const vAuth = (el, binding) => {
86
- let options = (el ? binding.value : binding) || {};
87
- if (typeof options === "string")
88
- options = { code: options };
89
- const type = options?.type ?? "hide";
90
- const isPermission = hasPermission(options);
91
- if (el) {
92
- if (!binding.oldValue) {
93
- if (!isPermission)
94
- getEl(el, options).then((element) => {
95
- removeEl(element, type);
96
- });
97
- } else {
98
- const oldHasPermission = hasPermission(binding.oldValue);
99
- const newHasPermission = isPermission;
100
- if (oldHasPermission === newHasPermission)
32
+ let a = !1;
33
+ if (t) {
34
+ const c = i(l, s) ?? [];
35
+ a = A(c, t);
36
+ } else
37
+ a = !!i(l, s);
38
+ return a;
39
+ }, m = (e, t) => {
40
+ t === "hide" ? e.classList.add("is-hide") : (e.setAttribute("disabled", ""), e.classList.add("is-disabled"));
41
+ }, b = (e, t) => {
42
+ t === "hide" ? e.classList.remove("is-hide") : (e.removeAttribute("disabled"), e.classList.remove("is-disabled"));
43
+ }, U = (e, t) => {
44
+ let r = (e ? t.value : t) || {};
45
+ typeof r == "string" && (r = { code: r });
46
+ const s = (r == null ? void 0 : r.type) ?? "hide", l = h(r);
47
+ if (e)
48
+ if (!t.oldValue)
49
+ l || o(e, r).then((a) => {
50
+ m(a, s);
51
+ });
52
+ else {
53
+ const a = h(t.oldValue), d = l;
54
+ if (a === d)
101
55
  return;
102
- getEl(el, options).then((element) => {
103
- if (newHasPermission) {
104
- addEl(element, type);
105
- } else {
106
- removeEl(element, type);
107
- }
56
+ o(e, r).then((c) => {
57
+ d ? b(c, s) : m(c, s);
108
58
  });
109
59
  }
110
- }
111
- return isPermission;
60
+ return l;
61
+ };
62
+ export {
63
+ U as vAuth
112
64
  };
113
-
114
- export { vAuth };
@@ -0,0 +1,5 @@
1
+ import type { Directive } from 'vue';
2
+ /**
3
+ * 指令:点击当前区域或者指定区域之外的位置
4
+ */
5
+ export declare const vClickOutside: Directive<HTMLElement>;
@@ -1,53 +1,27 @@
1
- const getEl = async (el, options) => {
2
- let res = el;
3
- if (options?.target) {
4
- if (typeof options.target === "string")
5
- res = options.target;
6
- if (typeof options.target === "function")
7
- res = await options.target(el);
8
- }
9
- return res;
10
- };
11
-
12
- const vClickOutside = {
13
- mounted: async (el, binding) => {
14
- const options = binding.value;
15
- const targetEl = await getEl(el, options);
16
- function eventHandler(e) {
17
- let flag = true;
18
- if (Array.isArray(targetEl)) {
19
- for (let dom of targetEl) {
20
- dom.__click_outside__ = eventHandler;
21
- if (dom.contains(e.target))
22
- flag = false;
23
- }
24
- } else {
25
- if (targetEl.contains(e.target)) {
26
- flag = false;
27
- }
28
- targetEl.__click_outside__ = eventHandler;
29
- }
30
- if (flag) {
31
- if (options?.fn && typeof options?.fn === "function") {
32
- options?.fn(e);
33
- }
34
- }
1
+ import { getEl as r } from "@das-fed/utils/directive/utils";
2
+ const f = {
3
+ mounted: async (i, _) => {
4
+ const e = _.value, t = await r(i, e);
5
+ function c(n) {
6
+ let l = !0;
7
+ if (Array.isArray(t))
8
+ for (let o of t)
9
+ o.__click_outside__ = c, o.contains(n.target) && (l = !1);
10
+ else
11
+ t.contains(n.target) && (l = !1), t.__click_outside__ = c;
12
+ l && e != null && e.fn && typeof (e == null ? void 0 : e.fn) == "function" && (e == null || e.fn(n));
35
13
  }
36
- document.addEventListener("click", eventHandler);
14
+ document.addEventListener("click", c);
37
15
  },
38
- beforeUnmount: async (el, binding) => {
39
- const options = binding.value;
40
- const targetEl = await getEl(el, options);
41
- if (Array.isArray(targetEl)) {
42
- for (let dom of targetEl) {
43
- document.removeEventListener("click", dom.__click_outside__);
44
- delete dom.__click_outside__;
45
- }
46
- } else {
47
- document.removeEventListener("click", targetEl.__click_outside__);
48
- delete targetEl.__click_outside__;
49
- }
16
+ beforeUnmount: async (i, _) => {
17
+ const e = _.value, t = await r(i, e);
18
+ if (Array.isArray(t))
19
+ for (let c of t)
20
+ document.removeEventListener("click", c.__click_outside__), delete c.__click_outside__;
21
+ else
22
+ document.removeEventListener("click", t.__click_outside__), delete t.__click_outside__;
50
23
  }
51
24
  };
52
-
53
- export { vClickOutside };
25
+ export {
26
+ f as vClickOutside
27
+ };
@@ -0,0 +1,5 @@
1
+ import type { Directive } from 'vue';
2
+ /**
3
+ * 指令:鼠标移入移除dom事件
4
+ */
5
+ export declare const vHoverInside: Directive<HTMLElement>;
@@ -1,40 +1,21 @@
1
- const getEl = async (el, options) => {
2
- let res = el;
3
- if (options?.target) {
4
- if (typeof options.target === "string")
5
- res = options.target;
6
- if (typeof options.target === "function")
7
- res = await options.target(el);
8
- }
9
- return res;
10
- };
11
-
12
- const vHoverInside = {
13
- mounted: async (el, binding) => {
14
- const options = binding.value;
15
- const targetEl = await getEl(el, options);
16
- function eventHandler(flag, e) {
17
- targetEl._inside_event = eventHandler;
18
- if (typeof options === "function") {
19
- options(flag, e);
20
- } else if (options?.fn && typeof options?.fn === "function") {
21
- options?.fn(flag, e);
22
- }
1
+ import { getEl as r } from "@das-fed/utils/directive/utils";
2
+ const o = {
3
+ mounted: async (s, a) => {
4
+ const e = a.value, n = await r(s, e);
5
+ function i(t, d) {
6
+ n._inside_event = i, typeof e == "function" ? e(t, d) : e != null && e.fn && typeof (e == null ? void 0 : e.fn) == "function" && (e == null || e.fn(t, d));
23
7
  }
24
- targetEl.addEventListener("mouseenter", (e) => {
25
- eventHandler(true, e);
26
- });
27
- targetEl.addEventListener("mouseleave", (e) => {
28
- eventHandler(false, e);
8
+ n.addEventListener("mouseenter", (t) => {
9
+ i(!0, t);
10
+ }), n.addEventListener("mouseleave", (t) => {
11
+ i(!1, t);
29
12
  });
30
13
  },
31
- beforeUnmount: async (el, binding) => {
32
- const options = binding.value;
33
- const targetEl = await getEl(el, options);
34
- targetEl.addEventListener("mouseenter", targetEl._inside_event);
35
- targetEl.addEventListener("mouseleave", targetEl._inside_event);
36
- delete targetEl._inside_event;
14
+ beforeUnmount: async (s, a) => {
15
+ const e = a.value, n = await r(s, e);
16
+ n.addEventListener("mouseenter", n._inside_event), n.addEventListener("mouseleave", n._inside_event), delete n._inside_event;
37
17
  }
38
18
  };
39
-
40
- export { vHoverInside };
19
+ export {
20
+ o as vHoverInside
21
+ };
@@ -0,0 +1,3 @@
1
+ export { vAuth } from '@das-fed/utils/directive/auth';
2
+ export { vClickOutside } from '@das-fed/utils/directive/clickOutside';
3
+ export { vHoverInside } from '@das-fed/utils/directive/hoverInside';
@@ -1,183 +1,8 @@
1
- import { getUrlParams, flatTree } from '@das-fed/utils/common-tools';
2
- import { getTabInfo, getSubApps, getPageAuth } from '@das-fed/utils/common-info';
3
-
4
- const getEl = async (el, options) => {
5
- let res = el;
6
- if (options?.target) {
7
- if (typeof options.target === "string")
8
- res = options.target;
9
- if (typeof options.target === "function")
10
- res = await options.target(el);
11
- }
12
- return res;
1
+ import { vAuth as e } from "@das-fed/utils/directive/auth";
2
+ import { vClickOutside as v } from "@das-fed/utils/directive/clickOutside";
3
+ import { vHoverInside as i } from "@das-fed/utils/directive/hoverInside";
4
+ export {
5
+ e as vAuth,
6
+ v as vClickOutside,
7
+ i as vHoverInside
13
8
  };
14
-
15
- const hasBtnAuth = (btnList, code) => {
16
- if (!btnList || !code)
17
- return false;
18
- if (typeof code === "string") {
19
- const currentItem = btnList.find((item) => item.code === code);
20
- return !!currentItem;
21
- } else {
22
- let flag = false;
23
- for (let value of code) {
24
- const currentItem = btnList.find((item) => item.code === value);
25
- if (currentItem) {
26
- flag = true;
27
- break;
28
- }
29
- }
30
- return flag;
31
- }
32
- };
33
- const hasPermission = (options) => {
34
- const code = options?.code ?? "";
35
- const path = options?.path ?? location.pathname;
36
- const applicationCode = options?.applicationCode ?? "";
37
- let menuCode = "";
38
- if (window.__IN_MICRO_APP__) {
39
- menuCode = options?.menuCode ? options.menuCode : getUrlParams(location.href, "menu");
40
- } else {
41
- menuCode = options?.menuCode ? options.menuCode : getTabInfo().currentTab?.code;
42
- }
43
- if (!menuCode) {
44
- const currentMenus = getSubApps().currentSubApp?.menus ?? [];
45
- if (currentMenus && currentMenus.length) {
46
- const flatMenus = flatTree(currentMenus).filter((item) => item?.routeUrl);
47
- if (flatMenus && flatMenus.length) {
48
- const currentMenu = flatMenus.find((item) => {
49
- if (item?.applicationPath) {
50
- return path?.includes("/" + item.applicationPath + item.routeUrl);
51
- } else {
52
- return path?.includes(item.routeUrl);
53
- }
54
- });
55
- if (currentMenu)
56
- menuCode = currentMenu?.code ?? "";
57
- }
58
- }
59
- }
60
- let flag = false;
61
- if (code) {
62
- const btnList = getPageAuth(menuCode, applicationCode) ?? [];
63
- flag = hasBtnAuth(btnList, code);
64
- } else {
65
- flag = !!getPageAuth(menuCode, applicationCode);
66
- }
67
- return flag;
68
- };
69
- const removeEl = (el, type) => {
70
- if (type === "hide") {
71
- el.classList.add("is-hide");
72
- } else {
73
- el.setAttribute("disabled", "");
74
- el.classList.add("is-disabled");
75
- }
76
- };
77
- const addEl = (el, type) => {
78
- if (type === "hide") {
79
- el.classList.remove("is-hide");
80
- } else {
81
- el.removeAttribute("disabled");
82
- el.classList.remove("is-disabled");
83
- }
84
- };
85
- const vAuth = (el, binding) => {
86
- let options = (el ? binding.value : binding) || {};
87
- if (typeof options === "string")
88
- options = { code: options };
89
- const type = options?.type ?? "hide";
90
- const isPermission = hasPermission(options);
91
- if (el) {
92
- if (!binding.oldValue) {
93
- if (!isPermission)
94
- getEl(el, options).then((element) => {
95
- removeEl(element, type);
96
- });
97
- } else {
98
- const oldHasPermission = hasPermission(binding.oldValue);
99
- const newHasPermission = isPermission;
100
- if (oldHasPermission === newHasPermission)
101
- return;
102
- getEl(el, options).then((element) => {
103
- if (newHasPermission) {
104
- addEl(element, type);
105
- } else {
106
- removeEl(element, type);
107
- }
108
- });
109
- }
110
- }
111
- return isPermission;
112
- };
113
-
114
- const vClickOutside = {
115
- mounted: async (el, binding) => {
116
- const options = binding.value;
117
- const targetEl = await getEl(el, options);
118
- function eventHandler(e) {
119
- let flag = true;
120
- if (Array.isArray(targetEl)) {
121
- for (let dom of targetEl) {
122
- dom.__click_outside__ = eventHandler;
123
- if (dom.contains(e.target))
124
- flag = false;
125
- }
126
- } else {
127
- if (targetEl.contains(e.target)) {
128
- flag = false;
129
- }
130
- targetEl.__click_outside__ = eventHandler;
131
- }
132
- if (flag) {
133
- if (options?.fn && typeof options?.fn === "function") {
134
- options?.fn(e);
135
- }
136
- }
137
- }
138
- document.addEventListener("click", eventHandler);
139
- },
140
- beforeUnmount: async (el, binding) => {
141
- const options = binding.value;
142
- const targetEl = await getEl(el, options);
143
- if (Array.isArray(targetEl)) {
144
- for (let dom of targetEl) {
145
- document.removeEventListener("click", dom.__click_outside__);
146
- delete dom.__click_outside__;
147
- }
148
- } else {
149
- document.removeEventListener("click", targetEl.__click_outside__);
150
- delete targetEl.__click_outside__;
151
- }
152
- }
153
- };
154
-
155
- const vHoverInside = {
156
- mounted: async (el, binding) => {
157
- const options = binding.value;
158
- const targetEl = await getEl(el, options);
159
- function eventHandler(flag, e) {
160
- targetEl._inside_event = eventHandler;
161
- if (typeof options === "function") {
162
- options(flag, e);
163
- } else if (options?.fn && typeof options?.fn === "function") {
164
- options?.fn(flag, e);
165
- }
166
- }
167
- targetEl.addEventListener("mouseenter", (e) => {
168
- eventHandler(true, e);
169
- });
170
- targetEl.addEventListener("mouseleave", (e) => {
171
- eventHandler(false, e);
172
- });
173
- },
174
- beforeUnmount: async (el, binding) => {
175
- const options = binding.value;
176
- const targetEl = await getEl(el, options);
177
- targetEl.addEventListener("mouseenter", targetEl._inside_event);
178
- targetEl.addEventListener("mouseleave", targetEl._inside_event);
179
- delete targetEl._inside_event;
180
- }
181
- };
182
-
183
- export { vAuth, vClickOutside, vHoverInside };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 获取指定dom
3
+ * @param el
4
+ * @param options
5
+ * @returns
6
+ */
7
+ export declare const getEl: (el: HTMLElement, options: any) => Promise<HTMLElement>;
@@ -1,12 +1,7 @@
1
- const getEl = async (el, options) => {
2
- let res = el;
3
- if (options?.target) {
4
- if (typeof options.target === "string")
5
- res = options.target;
6
- if (typeof options.target === "function")
7
- res = await options.target(el);
8
- }
9
- return res;
1
+ const a = async (r, t) => {
2
+ let e = r;
3
+ return t != null && t.target && (typeof t.target == "string" && (e = t.target), typeof t.target == "function" && (e = await t.target(r))), e;
4
+ };
5
+ export {
6
+ a as getEl
10
7
  };
11
-
12
- export { getEl };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断鼠标是否落在一个块级元素内部
3
+ * @param {*} dom 块级元素
4
+ * @returns
5
+ */
6
+ export declare const domCheckIn: (dom: HTMLElement) => boolean;
@@ -1,16 +1,8 @@
1
- const domCheckIn = (dom) => {
2
- const event = window.event;
3
- let x = Number(event.clientX);
4
- let y = Number(event.clientY);
5
- let div_x = Number(dom.getBoundingClientRect().left);
6
- let div_x_width = Number(dom.getBoundingClientRect().left + dom.clientWidth);
7
- let div_y = Number(dom.getBoundingClientRect().top);
8
- let div_y_height = Number(dom.getBoundingClientRect().top + dom.clientHeight);
9
- if (x > div_x && x < div_x_width && y > div_y && y < div_y_height) {
10
- return true;
11
- } else {
12
- return false;
13
- }
1
+ const g = (e) => {
2
+ const t = window.event;
3
+ let n = Number(t.clientX), i = Number(t.clientY), l = Number(e.getBoundingClientRect().left), u = Number(e.getBoundingClientRect().left + e.clientWidth), r = Number(e.getBoundingClientRect().top), c = Number(e.getBoundingClientRect().top + e.clientHeight);
4
+ return n > l && n < u && i > r && i < c;
5
+ };
6
+ export {
7
+ g as domCheckIn
14
8
  };
15
-
16
- export { domCheckIn };
@@ -0,0 +1,25 @@
1
+ interface Config {
2
+ /** 观察目标节点的子节点的新增和删除;*/
3
+ childList?: boolean;
4
+ /** 观察目标节点的属性节点(新增或删除了某个属性,以及某个属性的属性值发生了变化); */
5
+ attributes?: boolean;
6
+ /** 要监视的特定属性名称的数组,如果未包含此属性,则对所有属性的更改都会触发变动通知; */
7
+ attributeFilter?: any[];
8
+ /** 在attributes属性已经设为true的前提下, 将发生变化的属性节点之前的属性值记录下来(记录在MutationRecord对象的oldValue属性中); */
9
+ attributeOldValue?: boolean;
10
+ /** 在characterData属性已经设为true的前提下,将发生变化characterData节点之前的文本内容记录下来(记录在MutationRecord对象的oldValue属性中); */
11
+ characterDataOldValue?: boolean;
12
+ /** 如果目标节点为characterData节点(一种抽象接口,具体可以为文本节点、注释节点,以及处理指令节点)时,也要观察该节点的文本内容是否发生变化; */
13
+ characterData?: boolean;
14
+ /** 观察目标节点的所有后代节点(观察目标节点所包含的整棵DOM树上的上述三种节点变化); */
15
+ subtree?: boolean;
16
+ }
17
+ /**
18
+ * dom监听器
19
+ * @param cb 回调函数
20
+ * @param dom 目标dom
21
+ * @param config 配置
22
+ * @returns
23
+ */
24
+ declare const DomWatcher: (cb: (list: MutationRecord[]) => void, dom: HTMLElement, config?: Config) => MutationObserver;
25
+ export { DomWatcher };
@@ -1,10 +1,9 @@
1
- const DomWatcher = (cb, dom, config = { attributes: true, childList: true, subtree: true }) => {
2
- const watchDom = dom || document.body;
3
- const domObserver = new MutationObserver((mutationsList) => {
4
- cb(mutationsList);
1
+ const c = (e, r, o = { attributes: !0, childList: !0, subtree: !0 }) => {
2
+ const s = r || document.body, t = new MutationObserver((u) => {
3
+ e(u);
5
4
  });
6
- domObserver.observe(watchDom, config);
7
- return domObserver;
5
+ return t.observe(s, o), t;
6
+ };
7
+ export {
8
+ c as DomWatcher
8
9
  };
9
-
10
- export { DomWatcher };
@@ -0,0 +1,5 @@
1
+ export declare const useZIndex: () => {
2
+ initialZIndex: any;
3
+ currentZIndex: any;
4
+ nextZIndex: () => any;
5
+ };