@das-fed/utils 1.0.0 → 1.0.2

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 (66) hide show
  1. package/api-services/index.js +6840 -19720
  2. package/api-services/modules/app-manage.js +6966 -6
  3. package/api-services/modules/authentication.js +6966 -6
  4. package/api-services/modules/bems.js +6970 -11
  5. package/api-services/modules/contract.js +6966 -6
  6. package/api-services/modules/duty-manage.js +6970 -10
  7. package/api-services/modules/enterpriseright.js +6966 -6
  8. package/api-services/modules/file.js +7108 -353
  9. package/api-services/modules/gateway-edge.js +6966 -6
  10. package/api-services/modules/index.js +7163 -437
  11. package/api-services/modules/iot.js +6979 -19
  12. package/api-services/modules/justauth.js +6967 -7
  13. package/api-services/modules/knowledge.js +6966 -6
  14. package/api-services/modules/link.js +6966 -6
  15. package/api-services/modules/permission.js +6966 -6
  16. package/api-services/modules/platformManage.js +6974 -14
  17. package/api-services/modules/portal.js +6966 -6
  18. package/api-services/modules/space-manage.js +6966 -6
  19. package/api-services/modules/super-admin.js +6969 -9
  20. package/api-services/modules/supplier.js +6968 -8
  21. package/api-services/modules/supplychain-manage.js +6966 -6
  22. package/api-services/modules/systemConfiguration.js +6966 -6
  23. package/api-services/modules/tool.js +6966 -6
  24. package/api-services/src/create-service.js +6840 -19720
  25. package/api-services/src/sso.js +1711 -157
  26. package/api-services/src/util.js +1466 -19
  27. package/atob/index.js +9 -10
  28. package/common-info/getIframeUrl.js +14 -11
  29. package/common-info/index.js +194 -269
  30. package/common-info/setInfoFromUrl.js +60 -128
  31. package/common-tools/arr-tools.js +6 -13
  32. package/common-tools/date-format.js +18 -21
  33. package/common-tools/get-url-params.js +47 -88
  34. package/common-tools/handle-data.js +3 -4
  35. package/common-tools/index.js +108 -204
  36. package/common-tools/nest-tree-format.js +22 -49
  37. package/common-tools/obj-tools.js +17 -18
  38. package/common-tools/setHtmlMinWH.js +6 -10
  39. package/common-tools/throttled.js +7 -16
  40. package/config/index.js +8 -25
  41. package/curring-http/index.js +5150 -17289
  42. package/directive/auth.js +205 -97
  43. package/directive/clickOutside.js +25 -49
  44. package/directive/hoverInside.js +18 -35
  45. package/directive/index.js +238 -159
  46. package/directive/utils.js +6 -11
  47. package/dom-check-in/index.js +7 -15
  48. package/dom-watcher/index.js +7 -8
  49. package/hooks/popup-manager/use-zindex.js +17 -36
  50. package/index.js +242 -191
  51. package/load-js/index.js +14 -20
  52. package/oss/index.js +15 -15
  53. package/package.json +7 -11
  54. package/pinyin-first-character/index.js +25011 -12217
  55. package/process-engine-info/index.js +8 -10
  56. package/pure-image-src/index.js +3 -29
  57. package/set-personal-info/index.js +1566 -16
  58. package/size-watcher/index.js +17 -24
  59. package/style/index.js +62 -103
  60. package/style/math.js +16 -31
  61. package/style/style.js +49 -72
  62. package/token-tools/index.js +1594 -152
  63. package/vue/hooks/use-model-value.js +9 -10
  64. package/vue/index.js +9 -10
  65. package/webSocket-service/index.js +162 -135
  66. package/with-install/index.js +5 -7
package/directive/auth.js CHANGED
@@ -1,114 +1,222 @@
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);
1
+ import { ref as S } from "vue";
2
+ const p = (e, t) => {
3
+ let r = window.location.search || "";
4
+ if (e && e !== location.href) {
5
+ const n = e.indexOf("?");
6
+ n !== -1 ? r = e.slice(n) : r = "";
7
+ }
8
+ const s = new URLSearchParams(r);
9
+ if (t)
10
+ return s.get(t);
11
+ {
12
+ let n = {};
13
+ for (let [c, o] of s.entries())
14
+ n[c] = o;
15
+ return n;
16
+ }
17
+ }, C = (e, t = "children", r = !0) => Array.isArray(e) && e.length ? e.reduce((s, n) => {
18
+ let c = n[t], o = { ...n };
19
+ return r && delete o[t], c && c.length ? s.concat(o, C(c, t, r)) : s.concat(o);
20
+ }, []) : [];
21
+ /*! js-cookie v3.0.5 | MIT */
22
+ function d(e) {
23
+ for (var t = 1; t < arguments.length; t++) {
24
+ var r = arguments[t];
25
+ for (var s in r)
26
+ e[s] = r[s];
27
+ }
28
+ return e;
29
+ }
30
+ var w = {
31
+ read: function(e) {
32
+ return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
33
+ },
34
+ write: function(e) {
35
+ return encodeURIComponent(e).replace(
36
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
37
+ decodeURIComponent
38
+ );
11
39
  }
12
- return res;
13
40
  };
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
- }
41
+ function g(e, t) {
42
+ function r(n, c, o) {
43
+ if (!(typeof document > "u")) {
44
+ o = d({}, t, o), typeof o.expires == "number" && (o.expires = new Date(Date.now() + o.expires * 864e5)), o.expires && (o.expires = o.expires.toUTCString()), n = encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
45
+ var a = "";
46
+ for (var i in o)
47
+ o[i] && (a += "; " + i, o[i] !== !0 && (a += "=" + o[i].split(";")[0]));
48
+ return document.cookie = n + "=" + e.write(c, n) + a;
29
49
  }
30
- return flag;
31
50
  }
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;
51
+ function s(n) {
52
+ if (!(typeof document > "u" || arguments.length && !n)) {
53
+ for (var c = document.cookie ? document.cookie.split("; ") : [], o = {}, a = 0; a < c.length; a++) {
54
+ var i = c[a].split("="), u = i.slice(1).join("=");
55
+ try {
56
+ var f = decodeURIComponent(i[0]);
57
+ if (o[f] = e.read(u, f), n === f)
58
+ break;
59
+ } catch {
60
+ }
61
+ }
62
+ return n ? o[n] : o;
63
+ }
42
64
  }
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 ?? "";
65
+ return Object.create(
66
+ {
67
+ set: r,
68
+ get: s,
69
+ remove: function(n, c) {
70
+ r(
71
+ n,
72
+ "",
73
+ d({}, c, {
74
+ expires: -1
75
+ })
76
+ );
77
+ },
78
+ withAttributes: function(n) {
79
+ return g(this.converter, d({}, this.attributes, n));
80
+ },
81
+ withConverter: function(n) {
82
+ return g(d({}, this.converter, n), this.attributes);
57
83
  }
84
+ },
85
+ {
86
+ attributes: { value: Object.freeze(t) },
87
+ converter: { value: Object.freeze(e) }
58
88
  }
89
+ );
90
+ }
91
+ var h = g(w, { path: "/" });
92
+ const y = (e) => {
93
+ var t = encodeURIComponent(e);
94
+ return t = btoa(t), t;
95
+ }, I = () => {
96
+ let t = { ...(window == null ? void 0 : window.config) || {} };
97
+ t.rootContainer || (t.rootContainer = "#app"), t.baseURL || (t.baseURL = location.origin), t.ossBaseURL || (t.ossBaseURL = "/oss"), t.ossBaseURL.startsWith("/") && (t.ossBaseURL = `${t.baseURL}/oss`), t.ssoBaseURL || (t.ssoBaseURL = t.baseURL);
98
+ let { microAppName: r, publicPath: s, mainAppName: n } = t;
99
+ return r && !0 && !s && (s = `/${r}/`.replace(/\/\//g, "/")), s || (s = "/"), t.publicPath = s, t.autoOssBucket || (t.autoOssBucket = n || r), t;
100
+ };
101
+ S(!1);
102
+ I();
103
+ y("das123"), +/* @__PURE__ */ new Date();
104
+ const P = () => {
105
+ const e = new URL(location.href).searchParams, t = e.get("token") || e.get("accessToken") || e.get("accesstoken") || "";
106
+ if (t) {
107
+ const r = JSON.stringify({ access_token: t });
108
+ sessionStorage.setItem("accessToken", t), sessionStorage.setItem("tokenInfo", r), h.set("accessToken", t), h.set("accessTokenInfo", r);
59
109
  }
60
- let flag = false;
61
- if (code) {
62
- const btnList = getPageAuth(menuCode, applicationCode) ?? [];
63
- flag = hasBtnAuth(btnList, code);
110
+ }, R = () => {
111
+ const e = JSON.parse(sessionStorage.getItem("projectInfo") || "{}"), t = new URL(location.href).searchParams, r = t.get("project") || t.get("projectId") || "";
112
+ if (!r)
113
+ return;
114
+ const s = t.get("projectParent") || t.get("projectParentId") || (e == null ? void 0 : e.parentId) || "", n = t.get("projectName") || (e == null ? void 0 : e.name) || "";
115
+ sessionStorage.setItem("project", r), sessionStorage.setItem("projectInfo", JSON.stringify({ ...e, id: r, name: n, parentId: s }));
116
+ }, U = () => h.get("accessToken") ?? "", m = (e, t) => {
117
+ const r = "permission-btn", s = I(), n = v(), c = p(location.href, "app") || "", o = t || c || (window.__IN_MICRO_APP__ ? n.currentSubAppCode : s.title);
118
+ if (!o)
119
+ return;
120
+ const a = p(location.href, "menu") || "", i = e || a || (window.__IN_MICRO_APP__ ? n.currentSubApp.currentMenuCode : JSON.parse(sessionStorage.getItem(`${s.title}-tabs`) || "{}").currentTab.code), u = JSON.parse(sessionStorage.getItem(r) || "{}");
121
+ if (!u || JSON.stringify(u) === "{}")
122
+ return;
123
+ const f = u[o][i];
124
+ return f && f.length ? f : u[o]["origin-auth"] ? u[o]["origin-auth"][i] ?? [] : [];
125
+ }, v = () => {
126
+ var s;
127
+ if (!window.__IN_MICRO_APP__)
128
+ return {};
129
+ const e = JSON.parse(sessionStorage.getItem("subApps") || "{}"), t = ((s = e.appcategorys) == null ? void 0 : s.map((n) => n.apps).flat()) ?? [];
130
+ return {
131
+ appcategorys: e.appcategorys ?? [],
132
+ currentSubApp: e.currentSubApp ?? {},
133
+ currentSubAppCode: e.currentSubAppCode ?? "",
134
+ flatSubAppList: t,
135
+ subAppList: e.subAppList ?? []
136
+ };
137
+ }, L = () => {
138
+ const e = I();
139
+ let t = {};
140
+ if (window.__IN_MICRO_APP__) {
141
+ const r = JSON.parse(sessionStorage.getItem("tabs") || "{}");
142
+ t = {
143
+ activeKey: r.activeKey ?? "",
144
+ currentTab: r.currentTab ?? {},
145
+ tabMap: r.tabMap ?? {}
146
+ };
64
147
  } else {
65
- flag = !!getPageAuth(menuCode, applicationCode);
148
+ const r = JSON.parse(sessionStorage.getItem(`${e.title}-tabs`) || "{}");
149
+ t = {
150
+ activeKey: r.activeKey ?? "",
151
+ currentTab: r.currentTab ?? {},
152
+ tabList: r.tabList ?? []
153
+ };
66
154
  }
67
- return flag;
155
+ return t;
68
156
  };
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");
157
+ U() || P();
158
+ R();
159
+ const b = async (e, t) => {
160
+ let r = e;
161
+ return t != null && t.target && (typeof t.target == "string" && (r = t.target), typeof t.target == "function" && (r = await t.target(e))), r;
162
+ }, k = (e, t) => {
163
+ if (!e || !t)
164
+ return !1;
165
+ if (typeof t == "string")
166
+ return !!e.find((s) => s.code === t);
167
+ {
168
+ let r = !1;
169
+ for (let s of t)
170
+ if (e.find((c) => c.code === s)) {
171
+ r = !0;
172
+ break;
173
+ }
174
+ return r;
75
175
  }
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");
176
+ }, A = (e) => {
177
+ var o, a;
178
+ const t = (e == null ? void 0 : e.code) ?? "", r = (e == null ? void 0 : e.path) ?? location.pathname, s = (e == null ? void 0 : e.applicationCode) ?? "";
179
+ let n = "";
180
+ if (window.__IN_MICRO_APP__ ? n = e != null && e.menuCode ? e.menuCode : p(location.href, "menu") : n = e != null && e.menuCode ? e.menuCode : (o = L().currentTab) == null ? void 0 : o.code, !n) {
181
+ const i = ((a = v().currentSubApp) == null ? void 0 : a.menus) ?? [];
182
+ if (i && i.length) {
183
+ const u = C(i).filter((f) => f == null ? void 0 : f.routeUrl);
184
+ if (u && u.length) {
185
+ const f = u.find((l) => l != null && l.applicationPath ? r == null ? void 0 : r.includes("/" + l.applicationPath + l.routeUrl) : r == null ? void 0 : r.includes(l.routeUrl));
186
+ f && (n = (f == null ? void 0 : f.code) ?? "");
187
+ }
188
+ }
83
189
  }
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)
190
+ let c = !1;
191
+ if (t) {
192
+ const i = m(n, s) ?? [];
193
+ c = k(i, t);
194
+ } else
195
+ c = !!m(n, s);
196
+ return c;
197
+ }, _ = (e, t) => {
198
+ t === "hide" ? e.classList.add("is-hide") : (e.setAttribute("disabled", ""), e.classList.add("is-disabled"));
199
+ }, O = (e, t) => {
200
+ t === "hide" ? e.classList.remove("is-hide") : (e.removeAttribute("disabled"), e.classList.remove("is-disabled"));
201
+ }, N = (e, t) => {
202
+ let r = (e ? t.value : t) || {};
203
+ typeof r == "string" && (r = { code: r });
204
+ const s = (r == null ? void 0 : r.type) ?? "hide", n = A(r);
205
+ if (e)
206
+ if (!t.oldValue)
207
+ n || b(e, r).then((c) => {
208
+ _(c, s);
209
+ });
210
+ else {
211
+ const c = A(t.oldValue), o = n;
212
+ if (c === o)
101
213
  return;
102
- getEl(el, options).then((element) => {
103
- if (newHasPermission) {
104
- addEl(element, type);
105
- } else {
106
- removeEl(element, type);
107
- }
214
+ b(e, r).then((a) => {
215
+ o ? O(a, s) : _(a, s);
108
216
  });
109
217
  }
110
- }
111
- return isPermission;
218
+ return n;
219
+ };
220
+ export {
221
+ N as vAuth
112
222
  };
113
-
114
- export { vAuth };
@@ -1,53 +1,29 @@
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
+ const l = 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
+ }, n = {
5
+ mounted: async (r, t) => {
6
+ const e = t.value, c = await l(r, e);
7
+ function a(_) {
8
+ let i = !0;
9
+ if (Array.isArray(c))
10
+ for (let f of c)
11
+ f.__click_outside__ = a, f.contains(_.target) && (i = !1);
12
+ else
13
+ c.contains(_.target) && (i = !1), c.__click_outside__ = a;
14
+ i && e != null && e.fn && typeof (e == null ? void 0 : e.fn) == "function" && (e == null || e.fn(_));
35
15
  }
36
- document.addEventListener("click", eventHandler);
16
+ document.addEventListener("click", a);
37
17
  },
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
- }
18
+ beforeUnmount: async (r, t) => {
19
+ const e = t.value, c = await l(r, e);
20
+ if (Array.isArray(c))
21
+ for (let a of c)
22
+ document.removeEventListener("click", a.__click_outside__), delete a.__click_outside__;
23
+ else
24
+ document.removeEventListener("click", c.__click_outside__), delete c.__click_outside__;
50
25
  }
51
26
  };
52
-
53
- export { vClickOutside };
27
+ export {
28
+ n as vClickOutside
29
+ };
@@ -1,40 +1,23 @@
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
+ const v = async (a, t) => {
2
+ let e = a;
3
+ return t != null && t.target && (typeof t.target == "string" && (e = t.target), typeof t.target == "function" && (e = await t.target(a))), e;
4
+ }, i = {
5
+ mounted: async (a, t) => {
6
+ const e = t.value, n = await v(a, e);
7
+ function f(r, d) {
8
+ n._inside_event = f, typeof e == "function" ? e(r, d) : e != null && e.fn && typeof (e == null ? void 0 : e.fn) == "function" && (e == null || e.fn(r, d));
23
9
  }
24
- targetEl.addEventListener("mouseenter", (e) => {
25
- eventHandler(true, e);
26
- });
27
- targetEl.addEventListener("mouseleave", (e) => {
28
- eventHandler(false, e);
10
+ n.addEventListener("mouseenter", (r) => {
11
+ f(!0, r);
12
+ }), n.addEventListener("mouseleave", (r) => {
13
+ f(!1, r);
29
14
  });
30
15
  },
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;
16
+ beforeUnmount: async (a, t) => {
17
+ const e = t.value, n = await v(a, e);
18
+ n.addEventListener("mouseenter", n._inside_event), n.addEventListener("mouseleave", n._inside_event), delete n._inside_event;
37
19
  }
38
20
  };
39
-
40
- export { vHoverInside };
21
+ export {
22
+ i as vHoverInside
23
+ };