@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
@@ -1,11 +1,10 @@
1
- import { ref, watchEffect } from 'vue';
2
-
3
- const useModelValue = (props, propKey) => {
4
- const modelValue = ref(props[propKey]);
5
- watchEffect(() => {
6
- modelValue.value = props[propKey];
7
- });
8
- return modelValue;
1
+ import { ref as o, watchEffect as u } from "vue";
2
+ const c = (e, t) => {
3
+ const l = o(e[t]);
4
+ return u(() => {
5
+ l.value = e[t];
6
+ }), l;
7
+ };
8
+ export {
9
+ c as useModelValue
9
10
  };
10
-
11
- export { useModelValue };
package/vue/index.js CHANGED
@@ -1,11 +1,10 @@
1
- import { ref, watchEffect } from 'vue';
2
-
3
- const useModelValue = (props, propKey) => {
4
- const modelValue = ref(props[propKey]);
5
- watchEffect(() => {
6
- modelValue.value = props[propKey];
7
- });
8
- return modelValue;
1
+ import { ref as o, watchEffect as u } from "vue";
2
+ const c = (e, t) => {
3
+ const l = o(e[t]);
4
+ return u(() => {
5
+ l.value = e[t];
6
+ }), l;
7
+ };
8
+ export {
9
+ c as useModelValue
9
10
  };
10
-
11
- export { useModelValue };
@@ -1,170 +1,197 @@
1
- import { getConfig } from '@das-fed/utils/config';
2
- import { getToken } from '@das-fed/utils/common-info';
3
- import { objectToUrlparams } from '@das-fed/utils/common-tools';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __publicField = (obj, key, value) => {
8
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
- return value;
1
+ import { ref as k } from "vue";
2
+ const m = () => {
3
+ let e = { ...(window == null ? void 0 : window.config) || {} };
4
+ e.rootContainer || (e.rootContainer = "#app"), e.baseURL || (e.baseURL = location.origin), e.ossBaseURL || (e.ossBaseURL = "/oss"), e.ossBaseURL.startsWith("/") && (e.ossBaseURL = `${e.baseURL}/oss`), e.ssoBaseURL || (e.ssoBaseURL = e.baseURL);
5
+ let { microAppName: s, publicPath: o, mainAppName: n } = e;
6
+ return s && !0 && !o && (o = `/${s}/`.replace(/\/\//g, "/")), o || (o = "/"), e.publicPath = o, e.autoOssBucket || (e.autoOssBucket = n || s), e;
10
7
  };
11
- const config = getConfig();
12
- const getBaseUrl = () => {
13
- let baseUrl = "";
14
- if (config.baseURL) {
15
- baseUrl = config.baseURL;
16
- } else {
17
- baseUrl = location.origin;
18
- }
19
- return baseUrl.replace("https://", "wss://").replace("http://", "ws://") || "";
20
- };
21
- const getUrl = (url, params = {}) => {
22
- const query = objectToUrlparams(params);
23
- const result = query ? getBaseUrl() + url + `?${query}` : getBaseUrl() + url;
24
- return result;
8
+ /*! js-cookie v3.0.5 | MIT */
9
+ function h(t) {
10
+ for (var e = 1; e < arguments.length; e++) {
11
+ var s = arguments[e];
12
+ for (var o in s)
13
+ t[o] = s[o];
14
+ }
15
+ return t;
16
+ }
17
+ var R = {
18
+ read: function(t) {
19
+ return t[0] === '"' && (t = t.slice(1, -1)), t.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
20
+ },
21
+ write: function(t) {
22
+ return encodeURIComponent(t).replace(
23
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
24
+ decodeURIComponent
25
+ );
26
+ }
25
27
  };
26
- const getRandomInterval = (min, max) => {
27
- return Math.floor(Math.random() * (max - min + 1)) + min;
28
+ function f(t, e) {
29
+ function s(n, c, r) {
30
+ if (!(typeof document > "u")) {
31
+ r = h({}, e, r), typeof r.expires == "number" && (r.expires = new Date(Date.now() + r.expires * 864e5)), r.expires && (r.expires = r.expires.toUTCString()), n = encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
32
+ var i = "";
33
+ for (var a in r)
34
+ r[a] && (i += "; " + a, r[a] !== !0 && (i += "=" + r[a].split(";")[0]));
35
+ return document.cookie = n + "=" + t.write(c, n) + i;
36
+ }
37
+ }
38
+ function o(n) {
39
+ if (!(typeof document > "u" || arguments.length && !n)) {
40
+ for (var c = document.cookie ? document.cookie.split("; ") : [], r = {}, i = 0; i < c.length; i++) {
41
+ var a = c[i].split("="), l = a.slice(1).join("=");
42
+ try {
43
+ var u = decodeURIComponent(a[0]);
44
+ if (r[u] = t.read(l, u), n === u)
45
+ break;
46
+ } catch {
47
+ }
48
+ }
49
+ return n ? r[n] : r;
50
+ }
51
+ }
52
+ return Object.create(
53
+ {
54
+ set: s,
55
+ get: o,
56
+ remove: function(n, c) {
57
+ s(
58
+ n,
59
+ "",
60
+ h({}, c, {
61
+ expires: -1
62
+ })
63
+ );
64
+ },
65
+ withAttributes: function(n) {
66
+ return f(this.converter, h({}, this.attributes, n));
67
+ },
68
+ withConverter: function(n) {
69
+ return f(h({}, this.converter, n), this.attributes);
70
+ }
71
+ },
72
+ {
73
+ attributes: { value: Object.freeze(e) },
74
+ converter: { value: Object.freeze(t) }
75
+ }
76
+ );
77
+ }
78
+ var g = f(R, { path: "/" });
79
+ const I = (t) => {
80
+ var e = encodeURIComponent(t);
81
+ return e = btoa(e), e;
82
+ }, b = (t) => {
83
+ let e = "";
84
+ const s = Object.keys(t);
85
+ return s && s.length && s.forEach((o, n) => {
86
+ n === s.length - 1 ? e += `${o}=${t[o]}` : e += `${o}=${t[o]}&`;
87
+ }), e;
28
88
  };
29
- class socketService {
89
+ k(!1);
90
+ m();
91
+ I("das123"), +/* @__PURE__ */ new Date();
92
+ const U = () => {
93
+ const t = new URL(location.href).searchParams, e = t.get("token") || t.get("accessToken") || t.get("accesstoken") || "";
94
+ if (e) {
95
+ const s = JSON.stringify({ access_token: e });
96
+ sessionStorage.setItem("accessToken", e), sessionStorage.setItem("tokenInfo", s), g.set("accessToken", e), g.set("accessTokenInfo", s);
97
+ }
98
+ }, v = () => {
99
+ const t = JSON.parse(sessionStorage.getItem("projectInfo") || "{}"), e = new URL(location.href).searchParams, s = e.get("project") || e.get("projectId") || "";
100
+ if (!s)
101
+ return;
102
+ const o = e.get("projectParent") || e.get("projectParentId") || (t == null ? void 0 : t.parentId) || "", n = e.get("projectName") || (t == null ? void 0 : t.name) || "";
103
+ sessionStorage.setItem("project", s), sessionStorage.setItem("projectInfo", JSON.stringify({ ...t, id: s, name: n, parentId: o }));
104
+ }, w = () => g.get("accessToken") ?? "";
105
+ w() || U();
106
+ v();
107
+ const p = m(), d = () => {
108
+ let t = "";
109
+ return p.baseURL ? t = p.baseURL : t = location.origin, t.replace("https://", "wss://").replace("http://", "ws://") || "";
110
+ }, C = (t, e = {}) => {
111
+ const s = b(e);
112
+ return s ? d() + t + `?${s}` : d() + t;
113
+ }, S = (t, e) => Math.floor(Math.random() * (e - t + 1)) + t;
114
+ class L {
30
115
  constructor({
31
- url,
32
- params = {},
33
- opened,
34
- close,
35
- error,
36
- message,
37
- ifReconnect,
38
- reconnectNum,
39
- reconnectWhenClose
116
+ url: e,
117
+ params: s = {},
118
+ opened: o,
119
+ close: n,
120
+ error: c,
121
+ message: r,
122
+ ifReconnect: i,
123
+ reconnectNum: a,
124
+ reconnectWhenClose: l
40
125
  }) {
41
- /** websocket实例 */
42
- __publicField(this, "$ws", null);
43
- /** websocket地址 */
44
- __publicField(this, "url", "");
45
- /** 请求参数 */
46
- __publicField(this, "params", {});
47
- /** 是否正在重连,避免ws重复连接 */
48
- __publicField(this, "lockReturn", false);
49
- /** websocket开启时间 */
50
- __publicField(this, "startTime", 0);
51
- /** 心跳检测 */
52
- __publicField(this, "heartbeatInterval", null);
53
- /** 发生错误时是否重连,默认开启 */
54
- __publicField(this, "ifReconnect", true);
55
- /** 重连定时器 */
56
- __publicField(this, "reconnectId", null);
57
- /** 重连次数,默认为3,-1 表示一直重连 */
58
- __publicField(this, "reconnectNum", 3);
59
- /** 连接close关闭时是否重连,默认关闭 */
60
- __publicField(this, "reconnectWhenClose", false);
61
- /** 当前重连次数 */
62
- __publicField(this, "currentReconnectNum", 0);
63
- this.$ws = null;
64
- this.startTime = 0;
65
- this.heartbeatInterval = null;
66
- this.ifReconnect = ifReconnect ?? true;
67
- this.reconnectNum = reconnectNum ?? 3;
68
- this.reconnectWhenClose = reconnectWhenClose ?? false;
69
- this.lockReturn = false;
70
- this.currentReconnectNum = 0;
71
- this.reconnectId = null;
72
- this.params = { ...params, access_token: getToken() };
73
- if (!url) {
126
+ if (this.$ws = null, this.url = "", this.params = {}, this.lockReturn = !1, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = !0, this.reconnectId = null, this.reconnectNum = 3, this.reconnectWhenClose = !1, this.currentReconnectNum = 0, this.$ws = null, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = i ?? !0, this.reconnectNum = a ?? 3, this.reconnectWhenClose = l ?? !1, this.lockReturn = !1, this.currentReconnectNum = 0, this.reconnectId = null, this.params = { ...s, access_token: w() }, e)
127
+ this.url = e;
128
+ else
74
129
  throw new Error("url is required");
75
- } else {
76
- this.url = url;
77
- }
78
- opened && (this.opened = opened);
79
- close && (this.close = close);
80
- error && (this.error = error);
81
- message && (this.afterMsg = message);
82
- this.initWebSocket();
130
+ o && (this.opened = o), n && (this.close = n), c && (this.error = c), r && (this.afterMsg = r), this.initWebSocket();
83
131
  }
84
132
  initWebSocket() {
85
- if (typeof WebSocket === "undefined")
86
- throw new Error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301websocket");
87
- const url = getUrl(this.url, this.params);
88
- this.$ws = new WebSocket(url);
89
- this.$ws.onopen = () => {
133
+ if (typeof WebSocket > "u")
134
+ throw new Error("您的浏览器不支持websocket");
135
+ const e = C(this.url, this.params);
136
+ this.$ws = new WebSocket(e), this.$ws.onopen = () => {
90
137
  this.open();
91
- };
92
- this.$ws.onclose = (event) => {
93
- this.close(event);
94
- };
95
- this.$ws.onmessage = (event) => {
96
- this.message(event);
97
- };
98
- this.$ws.onerror = (event) => {
99
- this.error(event);
138
+ }, this.$ws.onclose = (s) => {
139
+ this.close(s);
140
+ }, this.$ws.onmessage = (s) => {
141
+ this.message(s);
142
+ }, this.$ws.onerror = (s) => {
143
+ this.error(s);
100
144
  };
101
145
  }
102
146
  open() {
103
- this.currentReconnectNum = 0;
104
- this.startTime = (/* @__PURE__ */ new Date()).getTime();
105
- this.opened(this.$ws);
106
- this.startHeartbeat();
107
- console.log(this.url + " =>websocket\u8FDE\u63A5\u6210\u529F,\u53EF\u4EE5\u5F00\u59CB\u901A\u8BAF");
147
+ this.currentReconnectNum = 0, this.startTime = (/* @__PURE__ */ new Date()).getTime(), this.opened(this.$ws), this.startHeartbeat(), console.log(this.url + " =>websocket连接成功,可以开始通讯");
108
148
  }
109
- opened(ws) {
110
- console.log(this.url + " =>websocket\u8FDE\u63A5\u5DF2\u6253\u5F00:", ws);
149
+ opened(e) {
150
+ console.log(this.url + " =>websocket连接已打开:", e);
111
151
  }
112
- close(event) {
152
+ close(e) {
113
153
  if (this.$ws.readyState === WebSocket.CLOSED) {
114
- const endTime = (/* @__PURE__ */ new Date()).getTime();
115
- if (this.reconnectWhenClose)
116
- this.reconnect();
117
- clearInterval(this.heartbeatInterval);
118
- console.log(`${this.url}=>WebSocket\u8FDE\u63A5\u5DF2\u7ECF\u5173\u95ED,\u8FDE\u63A5\u603B\u65F6\u957F: ${endTime - this.startTime}ms`);
154
+ const s = (/* @__PURE__ */ new Date()).getTime();
155
+ this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval), console.log(`${this.url}=>WebSocket连接已经关闭,连接总时长: ${s - this.startTime}ms`);
119
156
  }
120
157
  }
121
- message(event) {
122
- const msgContent = typeof event.data == "object" ? event.data : JSON.parse(event.data);
123
- this.afterMsg(msgContent);
158
+ message(e) {
159
+ const s = typeof e.data == "object" ? e.data : JSON.parse(e.data);
160
+ this.afterMsg(s);
124
161
  }
125
- afterMsg(msg) {
126
- console.log(this.url + " =>\u63A5\u6536\u5230websocket\u7684\u6D88\u606F:", msg);
162
+ afterMsg(e) {
163
+ console.log(this.url + " =>接收到websocket的消息:", e);
127
164
  }
128
- error(err) {
129
- if (this.ifReconnect)
130
- this.reconnect();
131
- return err;
165
+ error(e) {
166
+ return this.ifReconnect && this.reconnect(), e;
132
167
  }
133
168
  /** websocket重连 */
134
169
  reconnect() {
135
- if (this.lockReturn)
136
- return;
137
- this.lockReturn = true;
138
- this.currentReconnectNum++;
139
- if (this.currentReconnectNum > this.reconnectNum)
140
- return;
141
- this.reconnectId && clearTimeout(this.reconnectId);
142
- this.reconnectId = setTimeout(() => {
143
- this.initWebSocket();
144
- this.lockReturn = false;
145
- }, 3e3);
170
+ this.lockReturn || (this.lockReturn = !0, this.currentReconnectNum++, !(this.currentReconnectNum > this.reconnectNum) && (this.reconnectId && clearTimeout(this.reconnectId), this.reconnectId = setTimeout(() => {
171
+ this.initWebSocket(), this.lockReturn = !1;
172
+ }, 3e3)));
146
173
  }
147
174
  /** 发送消息给服务器 */
148
- send(message) {
149
- if (this.$ws?.readyState !== WebSocket.OPEN) {
150
- console.log(this.url + "=>websocket\u8FDE\u63A5\u672A\u5EFA\u7ACB\uFF0C\u8FD8\u4E0D\u80FD\u53D1\u9001\u6D88\u606F");
175
+ send(e) {
176
+ var s;
177
+ if (((s = this.$ws) == null ? void 0 : s.readyState) !== WebSocket.OPEN) {
178
+ console.log(this.url + "=>websocket连接未建立,还不能发送消息");
151
179
  return;
152
180
  }
153
- this.$ws.send(message);
181
+ this.$ws.send(e);
154
182
  }
155
183
  // 启动心跳检测==>30s-5分钟内随机发一次心跳保持会话(时间区间内随机是为了降低突增流量的概率)
156
184
  startHeartbeat() {
157
185
  this.heartbeatInterval = setInterval(() => {
158
- const randomMessage = "";
159
- this.send(randomMessage);
160
- console.log(this.url + "=>\u5FC3\u8DF3\u68C0\u6D4B\u53D1\u9001\u6D88\u606F:", randomMessage);
161
- }, getRandomInterval(3e4, 3e5));
186
+ const e = "";
187
+ this.send(e), console.log(this.url + "=>心跳检测发送消息:", e);
188
+ }, S(3e4, 3e5));
162
189
  }
163
190
  /** 断开连接 */
164
191
  disconnect() {
165
- this.$ws.close();
166
- console.log(this.url + " =>\u4E3B\u52A8\u65AD\u5F00websocket\u8FDE\u63A5");
192
+ this.$ws.close(), console.log(this.url + " =>主动断开websocket连接");
167
193
  }
168
194
  }
169
-
170
- export { socketService };
195
+ export {
196
+ L as socketService
197
+ };
@@ -1,8 +1,6 @@
1
- const withInstall = (comp) => {
2
- comp.install = function(app) {
3
- app.component(comp.name, comp);
4
- };
5
- return comp;
1
+ const e = (n) => (n.install = function(t) {
2
+ t.component(n.name, n);
3
+ }, n);
4
+ export {
5
+ e as withInstall
6
6
  };
7
-
8
- export { withInstall };