@das-fed/utils 1.0.2 → 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 (107) hide show
  1. package/api-services/index.d.ts +1 -0
  2. package/api-services/index.js +2 -6964
  3. package/api-services/modules/app-manage.d.ts +2 -0
  4. package/api-services/modules/app-manage.js +3 -6964
  5. package/api-services/modules/authentication.d.ts +2 -0
  6. package/api-services/modules/authentication.js +3 -6964
  7. package/api-services/modules/bems.d.ts +6 -0
  8. package/api-services/modules/bems.js +6 -6967
  9. package/api-services/modules/contract.d.ts +2 -0
  10. package/api-services/modules/contract.js +3 -6964
  11. package/api-services/modules/duty-manage.d.ts +7 -0
  12. package/api-services/modules/duty-manage.js +7 -6968
  13. package/api-services/modules/enterpriseright.d.ts +2 -0
  14. package/api-services/modules/enterpriseright.js +3 -6964
  15. package/api-services/modules/file.d.ts +36 -0
  16. package/api-services/modules/file.js +380 -7040
  17. package/api-services/modules/gateway-edge.d.ts +2 -0
  18. package/api-services/modules/gateway-edge.js +3 -6964
  19. package/api-services/modules/index.d.ts +21 -0
  20. package/api-services/modules/index.js +445 -7105
  21. package/api-services/modules/iot.d.ts +15 -0
  22. package/api-services/modules/iot.js +16 -6977
  23. package/api-services/modules/justauth.d.ts +3 -0
  24. package/api-services/modules/justauth.js +4 -6965
  25. package/api-services/modules/knowledge.d.ts +2 -0
  26. package/api-services/modules/knowledge.js +3 -6964
  27. package/api-services/modules/link.d.ts +2 -0
  28. package/api-services/modules/link.js +3 -6964
  29. package/api-services/modules/permission.d.ts +2 -0
  30. package/api-services/modules/permission.js +3 -6964
  31. package/api-services/modules/platformManage.d.ts +14 -0
  32. package/api-services/modules/platformManage.js +10 -6971
  33. package/api-services/modules/portal.d.ts +2 -0
  34. package/api-services/modules/portal.js +3 -6964
  35. package/api-services/modules/space-manage.d.ts +2 -0
  36. package/api-services/modules/space-manage.js +3 -6964
  37. package/api-services/modules/super-admin.d.ts +8 -0
  38. package/api-services/modules/super-admin.js +6 -6967
  39. package/api-services/modules/supplier.d.ts +6 -0
  40. package/api-services/modules/supplier.js +5 -6966
  41. package/api-services/modules/supplychain-manage.d.ts +2 -0
  42. package/api-services/modules/supplychain-manage.js +3 -6964
  43. package/api-services/modules/systemConfiguration.d.ts +2 -0
  44. package/api-services/modules/systemConfiguration.js +3 -6964
  45. package/api-services/modules/tool.d.ts +2 -0
  46. package/api-services/modules/tool.js +3 -6964
  47. package/api-services/src/create-service.d.ts +2 -0
  48. package/api-services/src/create-service.js +2286 -6013
  49. package/api-services/src/sso.d.ts +29 -0
  50. package/api-services/src/sso.js +506 -669
  51. package/api-services/src/util.d.ts +1 -0
  52. package/api-services/src/util.js +243 -247
  53. package/atob/index.d.ts +2 -0
  54. package/common-info/getIframeUrl.d.ts +9 -0
  55. package/common-info/getIframeUrl.js +6 -11
  56. package/common-info/index.d.ts +42 -0
  57. package/common-info/index.js +104 -163
  58. package/common-info/setInfoFromUrl.d.ts +8 -0
  59. package/common-tools/arr-tools.d.ts +15 -0
  60. package/common-tools/date-format.d.ts +7 -0
  61. package/common-tools/get-url-params.d.ts +33 -0
  62. package/common-tools/get-url-params.js +1 -0
  63. package/common-tools/handle-data.d.ts +6 -0
  64. package/common-tools/index.d.ts +7 -0
  65. package/common-tools/index.js +7 -117
  66. package/common-tools/nest-tree-format.d.ts +30 -0
  67. package/common-tools/obj-tools.d.ts +7 -0
  68. package/common-tools/setHtmlMinWH.d.ts +5 -0
  69. package/common-tools/throttled.d.ts +7 -0
  70. package/config/index.d.ts +2 -0
  71. package/curring-http/index.d.ts +11 -0
  72. package/directive/auth.d.ts +8 -0
  73. package/directive/auth.js +32 -190
  74. package/directive/clickOutside.d.ts +5 -0
  75. package/directive/clickOutside.js +19 -21
  76. package/directive/hoverInside.d.ts +5 -0
  77. package/directive/hoverInside.js +13 -15
  78. package/directive/index.d.ts +3 -0
  79. package/directive/index.js +6 -260
  80. package/directive/utils.d.ts +7 -0
  81. package/dom-check-in/index.d.ts +6 -0
  82. package/dom-watcher/index.d.ts +25 -0
  83. package/hooks/popup-manager/use-zindex.d.ts +5 -0
  84. package/index.d.ts +2 -0
  85. package/index.js +2 -266
  86. package/load-js/index.d.ts +3 -0
  87. package/load-js/index.js +8 -12
  88. package/oss/index.d.ts +2 -0
  89. package/oss/index.js +8 -12
  90. package/package.json +5 -6
  91. package/pinyin-first-character/index.d.ts +2 -0
  92. package/process-engine-info/index.d.ts +10 -0
  93. package/pure-image-src/index.d.ts +2 -0
  94. package/set-personal-info/index.d.ts +5 -0
  95. package/set-personal-info/index.js +516 -622
  96. package/size-watcher/index.d.ts +6 -0
  97. package/style/index.d.ts +2 -0
  98. package/style/math.d.ts +9 -0
  99. package/style/style.d.ts +30 -0
  100. package/token-tools/index.d.ts +18 -0
  101. package/token-tools/index.js +60 -1579
  102. package/vue/hooks/use-model-value.d.ts +3 -0
  103. package/vue/index.d.ts +1 -0
  104. package/vue/index.js +2 -8
  105. package/webSocket-service/index.d.ts +40 -0
  106. package/webSocket-service/index.js +35 -138
  107. package/with-install/index.d.ts +10 -0
@@ -0,0 +1,3 @@
1
+ /** 简化组件内使用modelValue时的watch过程 */
2
+ declare const useModelValue: (props: any, propKey: string) => Ref;
3
+ export { useModelValue };
package/vue/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { useModelValue } from '@das-fed/utils/vue/hooks/use-model-value';
package/vue/index.js CHANGED
@@ -1,10 +1,4 @@
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
- };
1
+ import { useModelValue as l } from "@das-fed/utils/vue/hooks/use-model-value";
8
2
  export {
9
- c as useModelValue
3
+ l as useModelValue
10
4
  };
@@ -0,0 +1,40 @@
1
+ import type { socketConfig } from './type';
2
+ export declare class socketService {
3
+ /** websocket实例 */
4
+ $ws: any;
5
+ /** websocket地址 */
6
+ url: string;
7
+ /** 请求参数 */
8
+ params: Record<string, any>;
9
+ /** 是否正在重连,避免ws重复连接 */
10
+ lockReturn: boolean;
11
+ /** websocket开启时间 */
12
+ startTime: any;
13
+ /** 心跳检测 */
14
+ heartbeatInterval: any;
15
+ /** 发生错误时是否重连,默认开启 */
16
+ ifReconnect: boolean;
17
+ /** 重连定时器 */
18
+ reconnectId: any;
19
+ /** 重连次数,默认为3,-1 表示一直重连 */
20
+ reconnectNum: number;
21
+ /** 连接close关闭时是否重连,默认关闭 */
22
+ reconnectWhenClose: boolean;
23
+ /** 当前重连次数 */
24
+ currentReconnectNum: number;
25
+ constructor({ url, params, opened, close, error, message, ifReconnect, reconnectNum, reconnectWhenClose, }: socketConfig);
26
+ initWebSocket(): void;
27
+ open(): void;
28
+ opened(ws: any): void;
29
+ close(event: CloseEvent): void;
30
+ message(event: any): void;
31
+ afterMsg(msg: any): void;
32
+ error(err: any): any;
33
+ /** websocket重连 */
34
+ reconnect(): void;
35
+ /** 发送消息给服务器 */
36
+ send(message: any): void;
37
+ startHeartbeat(): void;
38
+ /** 断开连接 */
39
+ disconnect(): void;
40
+ }
@@ -1,146 +1,43 @@
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;
7
- };
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
- }
27
- };
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;
88
- };
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 {
1
+ import { getConfig as m } from "@das-fed/utils/config";
2
+ import { getToken as f } from "@das-fed/utils/common-info";
3
+ import { objectToUrlparams as w } from "@das-fed/utils/common-tools";
4
+ const c = m(), h = () => {
5
+ let s = "";
6
+ return c.baseURL ? s = c.baseURL : s = location.origin, s.replace("https://", "wss://").replace("http://", "ws://") || "";
7
+ }, b = (s, e = {}) => {
8
+ const t = w(e);
9
+ return t ? h() + s + `?${t}` : h() + s;
10
+ }, g = (s, e) => Math.floor(Math.random() * (e - s + 1)) + s;
11
+ class R {
115
12
  constructor({
116
13
  url: e,
117
- params: s = {},
118
- opened: o,
119
- close: n,
120
- error: c,
121
- message: r,
122
- ifReconnect: i,
14
+ params: t = {},
15
+ opened: n,
16
+ close: r,
17
+ error: o,
18
+ message: i,
19
+ ifReconnect: l,
123
20
  reconnectNum: a,
124
- reconnectWhenClose: l
21
+ reconnectWhenClose: u
125
22
  }) {
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)
23
+ 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 = l ?? !0, this.reconnectNum = a ?? 3, this.reconnectWhenClose = u ?? !1, this.lockReturn = !1, this.currentReconnectNum = 0, this.reconnectId = null, this.params = { ...t, access_token: f() }, e)
127
24
  this.url = e;
128
25
  else
129
26
  throw new Error("url is required");
130
- o && (this.opened = o), n && (this.close = n), c && (this.error = c), r && (this.afterMsg = r), this.initWebSocket();
27
+ n && (this.opened = n), r && (this.close = r), o && (this.error = o), i && (this.afterMsg = i), this.initWebSocket();
131
28
  }
132
29
  initWebSocket() {
133
30
  if (typeof WebSocket > "u")
134
31
  throw new Error("您的浏览器不支持websocket");
135
- const e = C(this.url, this.params);
32
+ const e = b(this.url, this.params);
136
33
  this.$ws = new WebSocket(e), this.$ws.onopen = () => {
137
34
  this.open();
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);
35
+ }, this.$ws.onclose = (t) => {
36
+ this.close(t);
37
+ }, this.$ws.onmessage = (t) => {
38
+ this.message(t);
39
+ }, this.$ws.onerror = (t) => {
40
+ this.error(t);
144
41
  };
145
42
  }
146
43
  open() {
@@ -151,13 +48,13 @@ class L {
151
48
  }
152
49
  close(e) {
153
50
  if (this.$ws.readyState === WebSocket.CLOSED) {
154
- const s = (/* @__PURE__ */ new Date()).getTime();
155
- this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval), console.log(`${this.url}=>WebSocket连接已经关闭,连接总时长: ${s - this.startTime}ms`);
51
+ const t = (/* @__PURE__ */ new Date()).getTime();
52
+ this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval), console.log(`${this.url}=>WebSocket连接已经关闭,连接总时长: ${t - this.startTime}ms`);
156
53
  }
157
54
  }
158
55
  message(e) {
159
- const s = typeof e.data == "object" ? e.data : JSON.parse(e.data);
160
- this.afterMsg(s);
56
+ const t = typeof e.data == "object" ? e.data : JSON.parse(e.data);
57
+ this.afterMsg(t);
161
58
  }
162
59
  afterMsg(e) {
163
60
  console.log(this.url + " =>接收到websocket的消息:", e);
@@ -173,8 +70,8 @@ class L {
173
70
  }
174
71
  /** 发送消息给服务器 */
175
72
  send(e) {
176
- var s;
177
- if (((s = this.$ws) == null ? void 0 : s.readyState) !== WebSocket.OPEN) {
73
+ var t;
74
+ if (((t = this.$ws) == null ? void 0 : t.readyState) !== WebSocket.OPEN) {
178
75
  console.log(this.url + "=>websocket连接未建立,还不能发送消息");
179
76
  return;
180
77
  }
@@ -185,7 +82,7 @@ class L {
185
82
  this.heartbeatInterval = setInterval(() => {
186
83
  const e = "";
187
84
  this.send(e), console.log(this.url + "=>心跳检测发送消息:", e);
188
- }, S(3e4, 3e5));
85
+ }, g(3e4, 3e5));
189
86
  }
190
87
  /** 断开连接 */
191
88
  disconnect() {
@@ -193,5 +90,5 @@ class L {
193
90
  }
194
91
  }
195
92
  export {
196
- L as socketService
93
+ R as socketService
197
94
  };
@@ -0,0 +1,10 @@
1
+ import type { Plugin } from 'vue';
2
+ /**
3
+ * 组件外部使用use时执行install,然后将组件注册为全局
4
+ */
5
+ export type SFCWithInstall<T> = T & Plugin;
6
+ /**
7
+ * 定义一个withInstall方法处理以下组件类型问题
8
+ * @param comp
9
+ */
10
+ export declare const withInstall: <T>(comp: T) => any;