@jnrs/vue-core 1.2.15 → 1.2.16
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/dist/composables/index.js +42 -45
- package/package.json +1 -1
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { ref as p, onDeactivated as
|
|
1
|
+
import { c as _, u as j } from "../useMouseSelection-DU3qQWIm.js";
|
|
2
|
+
import { ref as p, onDeactivated as J, onActivated as x, onUnmounted as D } from "vue";
|
|
3
3
|
import { ElMessage as v } from "element-plus";
|
|
4
|
-
|
|
5
|
-
const { useMockServe: A } = _();
|
|
6
|
-
function j(O) {
|
|
4
|
+
function H(w) {
|
|
7
5
|
const {
|
|
8
|
-
url:
|
|
9
|
-
token:
|
|
10
|
-
connectionTimeoutDuration:
|
|
11
|
-
heartbeat:
|
|
6
|
+
url: W,
|
|
7
|
+
token: S,
|
|
8
|
+
connectionTimeoutDuration: O = 6e4,
|
|
9
|
+
heartbeat: b = !1,
|
|
12
10
|
heartbeatInterval: y = 3e4,
|
|
13
|
-
heartbeatTimeout:
|
|
11
|
+
heartbeatTimeout: C = 1e4,
|
|
14
12
|
showLog: i = !1,
|
|
15
13
|
showMessage: c = !0,
|
|
16
|
-
onOpen:
|
|
17
|
-
onMessage:
|
|
14
|
+
onOpen: N,
|
|
15
|
+
onMessage: E,
|
|
18
16
|
onClose: I,
|
|
19
17
|
onError: T
|
|
20
|
-
} =
|
|
21
|
-
let
|
|
22
|
-
A && (h = S.startsWith("/mock") ? S : "/mock" + S);
|
|
18
|
+
} = w, e = p(null), f = p(!0), u = p(!1), n = p("未连接");
|
|
19
|
+
let o = "", r = null, l = null, t = null;
|
|
23
20
|
const g = () => {
|
|
24
21
|
r && clearTimeout(r), l && clearTimeout(l), r = null, l = null;
|
|
25
|
-
},
|
|
22
|
+
}, h = () => {
|
|
26
23
|
if (!(!e.value || e.value.readyState !== WebSocket.OPEN))
|
|
27
24
|
try {
|
|
28
25
|
e.value.send(JSON.stringify({ type: "ping" })), l = setTimeout(() => {
|
|
@@ -32,35 +29,35 @@ function j(O) {
|
|
|
32
29
|
grouping: !0,
|
|
33
30
|
showClose: !0,
|
|
34
31
|
duration: 3e3
|
|
35
|
-
}),
|
|
36
|
-
},
|
|
37
|
-
} catch (
|
|
38
|
-
console.error("发送 WebSocket ping 失败:",
|
|
32
|
+
}), M();
|
|
33
|
+
}, C);
|
|
34
|
+
} catch (s) {
|
|
35
|
+
console.error("发送 WebSocket ping 失败:", s);
|
|
39
36
|
}
|
|
40
|
-
},
|
|
41
|
-
d(), setTimeout(
|
|
42
|
-
},
|
|
37
|
+
}, M = () => {
|
|
38
|
+
d(), setTimeout(k, 2e3);
|
|
39
|
+
}, k = () => {
|
|
43
40
|
if (e.value?.readyState === WebSocket.OPEN) return;
|
|
44
41
|
e.value && e.value.close(), g(), t && clearTimeout(t);
|
|
45
|
-
const
|
|
46
|
-
e.value = new WebSocket(
|
|
47
|
-
e.value && e.value.readyState !== WebSocket.OPEN && (o = "WebSocket 连接超时", f.value = !1,
|
|
42
|
+
const s = S ? [S] : void 0;
|
|
43
|
+
e.value = new WebSocket(W, s), t = setTimeout(() => {
|
|
44
|
+
e.value && e.value.readyState !== WebSocket.OPEN && (o = "WebSocket 连接超时", f.value = !1, u.value = !1, n.value = "连接超时", i && console.error(o), c && v({
|
|
48
45
|
message: o,
|
|
49
46
|
type: "error",
|
|
50
47
|
grouping: !0,
|
|
51
48
|
showClose: !0,
|
|
52
49
|
duration: 0
|
|
53
50
|
}), e.value?.close(), e.value = null, T?.(new Event("timeout")));
|
|
54
|
-
},
|
|
55
|
-
t && (clearTimeout(t), t = null), f.value = !1,
|
|
51
|
+
}, O), e.value.onopen = () => {
|
|
52
|
+
t && (clearTimeout(t), t = null), f.value = !1, u.value = !0, n.value = "连接成功", o = "WebSocket 连接成功", i && console.log(o), c && v({
|
|
56
53
|
message: o,
|
|
57
54
|
type: "success",
|
|
58
55
|
grouping: !0,
|
|
59
56
|
showClose: !0,
|
|
60
57
|
duration: 3e3
|
|
61
|
-
}),
|
|
58
|
+
}), N?.(), b && (g(), r = setInterval(h, y));
|
|
62
59
|
}, e.value.onmessage = (a) => {
|
|
63
|
-
if (
|
|
60
|
+
if (n.value = "数据接收中", typeof a.data == "string")
|
|
64
61
|
try {
|
|
65
62
|
if (JSON.parse(a.data).type === "pong") {
|
|
66
63
|
l && (clearTimeout(l), l = null);
|
|
@@ -70,12 +67,12 @@ function j(O) {
|
|
|
70
67
|
}
|
|
71
68
|
try {
|
|
72
69
|
const m = JSON.parse(a.data);
|
|
73
|
-
|
|
70
|
+
E?.(m);
|
|
74
71
|
} catch (m) {
|
|
75
72
|
console.error("WebSocket 消息解析失败:", a.data, m);
|
|
76
73
|
}
|
|
77
74
|
}, e.value.onclose = () => {
|
|
78
|
-
f.value = !1,
|
|
75
|
+
f.value = !1, u.value = !1, n.value = "连接已关闭", g(), t && (clearTimeout(t), t = null), o = "WebSocket 连接已关闭", i && console.log(o), c && v({
|
|
79
76
|
message: o,
|
|
80
77
|
type: "warning",
|
|
81
78
|
grouping: !0,
|
|
@@ -83,7 +80,7 @@ function j(O) {
|
|
|
83
80
|
duration: 3e3
|
|
84
81
|
}), I?.();
|
|
85
82
|
}, e.value.onerror = (a) => {
|
|
86
|
-
f.value = !1,
|
|
83
|
+
f.value = !1, u.value = !1, n.value = "连接失败", t && (clearTimeout(t), t = null), o = "WebSocket 连接失败", i && console.error(o, a), c && v({
|
|
87
84
|
message: o,
|
|
88
85
|
type: "error",
|
|
89
86
|
grouping: !0,
|
|
@@ -91,7 +88,7 @@ function j(O) {
|
|
|
91
88
|
duration: 3e3
|
|
92
89
|
}), T?.(a);
|
|
93
90
|
};
|
|
94
|
-
},
|
|
91
|
+
}, P = (s) => {
|
|
95
92
|
if (!e.value || e.value.readyState !== WebSocket.OPEN) {
|
|
96
93
|
o = "WebSocket 未连接,无法发送消息", i && console.error(o), c && v({
|
|
97
94
|
message: o,
|
|
@@ -102,28 +99,28 @@ function j(O) {
|
|
|
102
99
|
});
|
|
103
100
|
return;
|
|
104
101
|
}
|
|
105
|
-
const a = typeof
|
|
102
|
+
const a = typeof s == "string" ? s : JSON.stringify(s);
|
|
106
103
|
e.value.send(a);
|
|
107
104
|
}, d = () => {
|
|
108
|
-
e.value && (e.value.close(), e.value = null), f.value = !1,
|
|
105
|
+
e.value && (e.value.close(), e.value = null), f.value = !1, u.value = !1, n.value = "手动关闭连接", g(), t && (clearTimeout(t), t = null);
|
|
109
106
|
};
|
|
110
|
-
return
|
|
107
|
+
return k(), J(() => {
|
|
111
108
|
r && (clearInterval(r), r = null), l && (clearTimeout(l), l = null);
|
|
109
|
+
}), x(() => {
|
|
110
|
+
u.value && b && (r = setInterval(h, y));
|
|
112
111
|
}), D(() => {
|
|
113
|
-
s.value && k && (r = setInterval(W, y));
|
|
114
|
-
}), L(() => {
|
|
115
112
|
d();
|
|
116
113
|
}), {
|
|
117
114
|
ws: e,
|
|
118
115
|
isLoading: f,
|
|
119
|
-
isConnected:
|
|
120
|
-
wsStateInfo:
|
|
121
|
-
sendMessage:
|
|
116
|
+
isConnected: u,
|
|
117
|
+
wsStateInfo: n,
|
|
118
|
+
sendMessage: P,
|
|
122
119
|
closeWebSocket: d
|
|
123
120
|
};
|
|
124
121
|
}
|
|
125
122
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
_ as useMouseSelection,
|
|
124
|
+
j as useReactivityTableHeight,
|
|
125
|
+
H as useWebSocket
|
|
129
126
|
};
|