@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.
- package/api-services/index.d.ts +1 -0
- package/api-services/index.js +3 -19845
- package/api-services/modules/app-manage.d.ts +2 -0
- package/api-services/modules/app-manage.js +5 -6
- package/api-services/modules/authentication.d.ts +2 -0
- package/api-services/modules/authentication.js +5 -6
- package/api-services/modules/bems.d.ts +6 -0
- package/api-services/modules/bems.js +8 -10
- package/api-services/modules/contract.d.ts +2 -0
- package/api-services/modules/contract.js +5 -6
- package/api-services/modules/duty-manage.d.ts +7 -0
- package/api-services/modules/duty-manage.js +9 -10
- package/api-services/modules/enterpriseright.d.ts +2 -0
- package/api-services/modules/enterpriseright.js +5 -6
- package/api-services/modules/file.d.ts +36 -0
- package/api-services/modules/file.js +449 -354
- package/api-services/modules/gateway-edge.d.ts +2 -0
- package/api-services/modules/gateway-edge.js +5 -6
- package/api-services/modules/index.d.ts +21 -0
- package/api-services/modules/index.js +501 -435
- package/api-services/modules/iot.d.ts +15 -0
- package/api-services/modules/iot.js +17 -18
- package/api-services/modules/justauth.d.ts +3 -0
- package/api-services/modules/justauth.js +6 -7
- package/api-services/modules/knowledge.d.ts +2 -0
- package/api-services/modules/knowledge.js +5 -6
- package/api-services/modules/link.d.ts +2 -0
- package/api-services/modules/link.js +5 -6
- package/api-services/modules/permission.d.ts +2 -0
- package/api-services/modules/permission.js +5 -6
- package/api-services/modules/platformManage.d.ts +14 -0
- package/api-services/modules/platformManage.js +12 -13
- package/api-services/modules/portal.d.ts +2 -0
- package/api-services/modules/portal.js +5 -6
- package/api-services/modules/space-manage.d.ts +2 -0
- package/api-services/modules/space-manage.js +5 -6
- package/api-services/modules/super-admin.d.ts +8 -0
- package/api-services/modules/super-admin.js +8 -9
- package/api-services/modules/supplier.d.ts +6 -0
- package/api-services/modules/supplier.js +7 -8
- package/api-services/modules/supplychain-manage.d.ts +2 -0
- package/api-services/modules/supplychain-manage.js +5 -6
- package/api-services/modules/systemConfiguration.d.ts +2 -0
- package/api-services/modules/systemConfiguration.js +5 -6
- package/api-services/modules/tool.d.ts +2 -0
- package/api-services/modules/tool.js +5 -6
- package/api-services/src/create-service.d.ts +2 -0
- package/api-services/src/create-service.js +3119 -19726
- package/api-services/src/sso.d.ts +29 -0
- package/api-services/src/sso.js +1547 -156
- package/api-services/src/util.d.ts +1 -0
- package/api-services/src/util.js +1462 -19
- package/atob/index.d.ts +2 -0
- package/atob/index.js +9 -10
- package/common-info/getIframeUrl.d.ts +9 -0
- package/common-info/getIframeUrl.js +9 -11
- package/common-info/index.d.ts +42 -0
- package/common-info/index.js +138 -272
- package/common-info/setInfoFromUrl.d.ts +8 -0
- package/common-info/setInfoFromUrl.js +60 -128
- package/common-tools/arr-tools.d.ts +15 -0
- package/common-tools/arr-tools.js +6 -13
- package/common-tools/date-format.d.ts +7 -0
- package/common-tools/date-format.js +18 -21
- package/common-tools/get-url-params.d.ts +33 -0
- package/common-tools/get-url-params.js +48 -88
- package/common-tools/handle-data.d.ts +6 -0
- package/common-tools/handle-data.js +3 -4
- package/common-tools/index.d.ts +7 -0
- package/common-tools/index.js +7 -213
- package/common-tools/nest-tree-format.d.ts +30 -0
- package/common-tools/nest-tree-format.js +22 -49
- package/common-tools/obj-tools.d.ts +7 -0
- package/common-tools/obj-tools.js +17 -18
- package/common-tools/setHtmlMinWH.d.ts +5 -0
- package/common-tools/setHtmlMinWH.js +6 -10
- package/common-tools/throttled.d.ts +7 -0
- package/common-tools/throttled.js +7 -16
- package/config/index.d.ts +2 -0
- package/config/index.js +8 -25
- package/curring-http/index.d.ts +11 -0
- package/curring-http/index.js +5150 -17289
- package/directive/auth.d.ts +8 -0
- package/directive/auth.js +54 -104
- package/directive/clickOutside.d.ts +5 -0
- package/directive/clickOutside.js +23 -49
- package/directive/hoverInside.d.ts +5 -0
- package/directive/hoverInside.js +16 -35
- package/directive/index.d.ts +3 -0
- package/directive/index.js +7 -182
- package/directive/utils.d.ts +7 -0
- package/directive/utils.js +6 -11
- package/dom-check-in/index.d.ts +6 -0
- package/dom-check-in/index.js +7 -15
- package/dom-watcher/index.d.ts +25 -0
- package/dom-watcher/index.js +7 -8
- package/hooks/popup-manager/use-zindex.d.ts +5 -0
- package/hooks/popup-manager/use-zindex.js +17 -36
- package/index.d.ts +2 -0
- package/index.js +2 -215
- package/load-js/index.d.ts +3 -0
- package/load-js/index.js +10 -20
- package/oss/index.d.ts +2 -0
- package/oss/index.js +11 -15
- package/package.json +8 -13
- package/pinyin-first-character/index.d.ts +2 -0
- package/pinyin-first-character/index.js +25011 -12217
- package/process-engine-info/index.d.ts +10 -0
- package/process-engine-info/index.js +8 -10
- package/pure-image-src/index.d.ts +2 -0
- package/pure-image-src/index.js +3 -29
- package/set-personal-info/index.d.ts +5 -0
- package/set-personal-info/index.js +1460 -16
- package/size-watcher/index.d.ts +6 -0
- package/size-watcher/index.js +17 -24
- package/style/index.d.ts +2 -0
- package/style/index.js +62 -103
- package/style/math.d.ts +9 -0
- package/style/math.js +16 -31
- package/style/style.d.ts +30 -0
- package/style/style.js +49 -72
- package/token-tools/index.d.ts +18 -0
- package/token-tools/index.js +72 -149
- package/vue/hooks/use-model-value.d.ts +3 -0
- package/vue/hooks/use-model-value.js +9 -10
- package/vue/index.d.ts +1 -0
- package/vue/index.js +3 -10
- package/webSocket-service/index.d.ts +40 -0
- package/webSocket-service/index.js +62 -138
- package/with-install/index.d.ts +10 -0
- package/with-install/index.js +5 -7
package/directive/auth.js
CHANGED
|
@@ -1,114 +1,64 @@
|
|
|
1
|
-
import { getUrlParams, flatTree } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
} else
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
103
|
-
|
|
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
|
-
|
|
60
|
+
return l;
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
U as vAuth
|
|
112
64
|
};
|
|
113
|
-
|
|
114
|
-
export { vAuth };
|
|
@@ -1,53 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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",
|
|
14
|
+
document.addEventListener("click", c);
|
|
37
15
|
},
|
|
38
|
-
beforeUnmount: async (
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
25
|
+
export {
|
|
26
|
+
f as vClickOutside
|
|
27
|
+
};
|
package/directive/hoverInside.js
CHANGED
|
@@ -1,40 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
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 (
|
|
32
|
-
const
|
|
33
|
-
|
|
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
|
-
|
|
19
|
+
export {
|
|
20
|
+
o as vHoverInside
|
|
21
|
+
};
|
package/directive/index.js
CHANGED
|
@@ -1,183 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 };
|
package/directive/utils.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 };
|
package/dom-check-in/index.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 };
|
package/dom-watcher/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
5
|
+
return t.observe(s, o), t;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
c as DomWatcher
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
-
export { DomWatcher };
|