@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.
- package/api-services/index.d.ts +1 -0
- package/api-services/index.js +2 -6964
- package/api-services/modules/app-manage.d.ts +2 -0
- package/api-services/modules/app-manage.js +3 -6964
- package/api-services/modules/authentication.d.ts +2 -0
- package/api-services/modules/authentication.js +3 -6964
- package/api-services/modules/bems.d.ts +6 -0
- package/api-services/modules/bems.js +6 -6967
- package/api-services/modules/contract.d.ts +2 -0
- package/api-services/modules/contract.js +3 -6964
- package/api-services/modules/duty-manage.d.ts +7 -0
- package/api-services/modules/duty-manage.js +7 -6968
- package/api-services/modules/enterpriseright.d.ts +2 -0
- package/api-services/modules/enterpriseright.js +3 -6964
- package/api-services/modules/file.d.ts +36 -0
- package/api-services/modules/file.js +380 -7040
- package/api-services/modules/gateway-edge.d.ts +2 -0
- package/api-services/modules/gateway-edge.js +3 -6964
- package/api-services/modules/index.d.ts +21 -0
- package/api-services/modules/index.js +445 -7105
- package/api-services/modules/iot.d.ts +15 -0
- package/api-services/modules/iot.js +16 -6977
- package/api-services/modules/justauth.d.ts +3 -0
- package/api-services/modules/justauth.js +4 -6965
- package/api-services/modules/knowledge.d.ts +2 -0
- package/api-services/modules/knowledge.js +3 -6964
- package/api-services/modules/link.d.ts +2 -0
- package/api-services/modules/link.js +3 -6964
- package/api-services/modules/permission.d.ts +2 -0
- package/api-services/modules/permission.js +3 -6964
- package/api-services/modules/platformManage.d.ts +14 -0
- package/api-services/modules/platformManage.js +10 -6971
- package/api-services/modules/portal.d.ts +2 -0
- package/api-services/modules/portal.js +3 -6964
- package/api-services/modules/space-manage.d.ts +2 -0
- package/api-services/modules/space-manage.js +3 -6964
- package/api-services/modules/super-admin.d.ts +8 -0
- package/api-services/modules/super-admin.js +6 -6967
- package/api-services/modules/supplier.d.ts +6 -0
- package/api-services/modules/supplier.js +5 -6966
- package/api-services/modules/supplychain-manage.d.ts +2 -0
- package/api-services/modules/supplychain-manage.js +3 -6964
- package/api-services/modules/systemConfiguration.d.ts +2 -0
- package/api-services/modules/systemConfiguration.js +3 -6964
- package/api-services/modules/tool.d.ts +2 -0
- package/api-services/modules/tool.js +3 -6964
- package/api-services/src/create-service.d.ts +2 -0
- package/api-services/src/create-service.js +2286 -6013
- package/api-services/src/sso.d.ts +29 -0
- package/api-services/src/sso.js +506 -669
- package/api-services/src/util.d.ts +1 -0
- package/api-services/src/util.js +243 -247
- package/atob/index.d.ts +2 -0
- package/common-info/getIframeUrl.d.ts +9 -0
- package/common-info/getIframeUrl.js +6 -11
- package/common-info/index.d.ts +42 -0
- package/common-info/index.js +104 -163
- package/common-info/setInfoFromUrl.d.ts +8 -0
- package/common-tools/arr-tools.d.ts +15 -0
- package/common-tools/date-format.d.ts +7 -0
- package/common-tools/get-url-params.d.ts +33 -0
- package/common-tools/get-url-params.js +1 -0
- package/common-tools/handle-data.d.ts +6 -0
- package/common-tools/index.d.ts +7 -0
- package/common-tools/index.js +7 -117
- package/common-tools/nest-tree-format.d.ts +30 -0
- package/common-tools/obj-tools.d.ts +7 -0
- package/common-tools/setHtmlMinWH.d.ts +5 -0
- package/common-tools/throttled.d.ts +7 -0
- package/config/index.d.ts +2 -0
- package/curring-http/index.d.ts +11 -0
- package/directive/auth.d.ts +8 -0
- package/directive/auth.js +32 -190
- package/directive/clickOutside.d.ts +5 -0
- package/directive/clickOutside.js +19 -21
- package/directive/hoverInside.d.ts +5 -0
- package/directive/hoverInside.js +13 -15
- package/directive/index.d.ts +3 -0
- package/directive/index.js +6 -260
- package/directive/utils.d.ts +7 -0
- package/dom-check-in/index.d.ts +6 -0
- package/dom-watcher/index.d.ts +25 -0
- package/hooks/popup-manager/use-zindex.d.ts +5 -0
- package/index.d.ts +2 -0
- package/index.js +2 -266
- package/load-js/index.d.ts +3 -0
- package/load-js/index.js +8 -12
- package/oss/index.d.ts +2 -0
- package/oss/index.js +8 -12
- package/package.json +5 -6
- package/pinyin-first-character/index.d.ts +2 -0
- package/process-engine-info/index.d.ts +10 -0
- package/pure-image-src/index.d.ts +2 -0
- package/set-personal-info/index.d.ts +5 -0
- package/set-personal-info/index.js +516 -622
- package/size-watcher/index.d.ts +6 -0
- package/style/index.d.ts +2 -0
- package/style/math.d.ts +9 -0
- package/style/style.d.ts +30 -0
- package/token-tools/index.d.ts +18 -0
- package/token-tools/index.js +60 -1579
- package/vue/hooks/use-model-value.d.ts +3 -0
- package/vue/index.d.ts +1 -0
- package/vue/index.js +2 -8
- package/webSocket-service/index.d.ts +40 -0
- package/webSocket-service/index.js +35 -138
- package/with-install/index.d.ts +10 -0
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 {
|
|
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
|
-
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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:
|
|
118
|
-
opened:
|
|
119
|
-
close:
|
|
120
|
-
error:
|
|
121
|
-
message:
|
|
122
|
-
ifReconnect:
|
|
14
|
+
params: t = {},
|
|
15
|
+
opened: n,
|
|
16
|
+
close: r,
|
|
17
|
+
error: o,
|
|
18
|
+
message: i,
|
|
19
|
+
ifReconnect: l,
|
|
123
20
|
reconnectNum: a,
|
|
124
|
-
reconnectWhenClose:
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
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 = (
|
|
139
|
-
this.close(
|
|
140
|
-
}, this.$ws.onmessage = (
|
|
141
|
-
this.message(
|
|
142
|
-
}, this.$ws.onerror = (
|
|
143
|
-
this.error(
|
|
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
|
|
155
|
-
this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval), console.log(`${this.url}=>WebSocket连接已经关闭,连接总时长: ${
|
|
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
|
|
160
|
-
this.afterMsg(
|
|
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
|
|
177
|
-
if (((
|
|
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
|
-
},
|
|
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
|
-
|
|
93
|
+
R as socketService
|
|
197
94
|
};
|