@scienjoy/sj-ai-plus 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.
- package/README.md +1 -18
- package/package.json +1 -1
- package/ui/es/packages/components/src/sjDigitalHumanAssistant/src/index.vue.ts +2 -2
- package/ui/es/packages/components/src/sjDigitalHumanAssistant/src/index.vue2.ts +233 -212
- package/ui/es/packages/components/src/utils/api.ts +7 -4
- package/ui/es/sj-ai-plus.css +1 -1
- package/ui/lib/packages/components/src/sjDigitalHumanAssistant/src/index.vue.ts +1 -1
- package/ui/lib/packages/components/src/sjDigitalHumanAssistant/src/index.vue2.ts +1 -1
- package/ui/lib/packages/components/src/utils/api.ts +1 -1
- package/ui/lib/sj-ai-plus.css +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import { defineComponent as Se, ref as d, reactive as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { defineComponent as Se, ref as d, reactive as Ye, computed as Te, watch as oe, nextTick as m, onMounted as Be, onUnmounted as Ie, resolveComponent as Oe, resolveDirective as je, openBlock as P, createElementBlock as A, normalizeStyle as ke, withDirectives as f, createElementVNode as n, vShow as w, normalizeClass as xe, toDisplayString as ae, createVNode as L, withModifiers as ie, withCtx as le, renderSlot as se, createCommentVNode as G, createBlock as Ue, Teleport as ze } from "vue";
|
|
3
|
+
import ce from "../../utils/api.ts";
|
|
4
|
+
import Ee from "../../utils/utils.ts";
|
|
5
5
|
import Fe from "../../utils/videoBackgroundRemoval.ts";
|
|
6
|
-
import { ElIcon as
|
|
7
|
-
const Ae = { class: "digital-human-assistant" },
|
|
6
|
+
import { ElIcon as Ne } from "../../../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.27_typescript@5.9.3_/node_modules/element-plus/es/components/icon/index.ts";
|
|
7
|
+
const Ae = { class: "digital-human-assistant" }, Ge = { class: "placeholder left-placeholder" }, Je = { class: "placeholder right-placeholder" }, qe = { class: "window-header-left" }, Ke = { class: "window-title-text" }, Qe = { class: "window-header-btns" }, Ze = { class: "disconnect-btn" }, et = {
|
|
8
8
|
class: "connect-btn",
|
|
9
9
|
disabled: ""
|
|
10
|
-
},
|
|
10
|
+
}, tt = { class: "connect-btn" }, nt = { class: "window-content" }, ot = { class: "main-content-inner" }, at = { class: "window-header-left" }, it = { class: "window-title-text" }, lt = { class: "window-header-btns" }, st = { class: "disconnect-btn" }, ct = {
|
|
11
11
|
class: "connect-btn",
|
|
12
12
|
disabled: ""
|
|
13
|
-
}, dt = { class: "connect-btn" },
|
|
13
|
+
}, dt = { class: "connect-btn" }, ut = { class: "window-content" }, rt = { class: "window-header-left" }, vt = { class: "window-title-text" }, ht = { class: "window-header-btns" }, ft = { class: "disconnect-btn" }, wt = {
|
|
14
14
|
class: "connect-btn",
|
|
15
15
|
disabled: ""
|
|
16
|
-
},
|
|
16
|
+
}, gt = { class: "connect-btn" }, mt = { class: "window-content" }, pt = Se({
|
|
17
17
|
name: "SjDigitalHumanAssistant"
|
|
18
|
-
}),
|
|
19
|
-
...
|
|
18
|
+
}), kt = /* @__PURE__ */ Se({
|
|
19
|
+
...pt,
|
|
20
20
|
props: {
|
|
21
21
|
windowWidth: { default: 320 },
|
|
22
22
|
windowHeight: { default: 467 },
|
|
@@ -32,123 +32,134 @@ const Ae = { class: "digital-human-assistant" }, Ne = { class: "placeholder left
|
|
|
32
32
|
maxReconnectTimes: { default: 10 },
|
|
33
33
|
baseUrl: { default: "" }
|
|
34
34
|
},
|
|
35
|
-
setup(
|
|
36
|
-
const o =
|
|
35
|
+
setup(V, { expose: Le }) {
|
|
36
|
+
const o = V, de = d(null), ue = d(null), u = d(null), a = d(null), p = Fe(), re = d(null), ve = d(null), he = d(null), X = d(null), H = d(!1), s = d(!1), h = d(!1), fe = d(!0), Y = d(!1), r = Ye({
|
|
37
37
|
x: 0,
|
|
38
38
|
y: 0,
|
|
39
39
|
offsetX: 0,
|
|
40
40
|
offsetY: 0
|
|
41
|
-
}), v = d(o.defaultStickSide),
|
|
42
|
-
let
|
|
43
|
-
const
|
|
41
|
+
}), v = d(o.defaultStickSide), B = d(!1), C = d(!1), M = d(!1), J = d(!1), q = d(!1);
|
|
42
|
+
let l = null, b = "";
|
|
43
|
+
const I = d(null), y = d(0), O = d(!1), W = d(!1), He = Te(() => ({
|
|
44
44
|
"--sidebar-width": o.sidebarWidth,
|
|
45
45
|
"--window-width": `${o.windowWidth}px`,
|
|
46
46
|
"--window-height": `${o.windowHeight}px`
|
|
47
|
-
})), Me =
|
|
47
|
+
})), Me = Te(() => ({
|
|
48
48
|
left: `${r.x}px`,
|
|
49
49
|
top: `${r.y}px`,
|
|
50
50
|
width: `${o.windowWidth}px`,
|
|
51
51
|
height: `${o.windowHeight}px`,
|
|
52
|
-
zIndex:
|
|
52
|
+
zIndex: B.value || M.value ? 9999 : 1e3
|
|
53
53
|
})), We = (t) => {
|
|
54
|
-
!t &&
|
|
54
|
+
!t && u.value ? (O.value = !1, y.value = 0, _e()) : t ? (O.value = !0, Ve()) : console.warn("自动连接超时:video元素未挂载"), fe.value = t;
|
|
55
55
|
}, j = (t) => {
|
|
56
|
-
We(!t),
|
|
57
|
-
},
|
|
56
|
+
We(!t), Y.value = t, t && s.value && m(() => g());
|
|
57
|
+
}, De = () => {
|
|
58
58
|
j(!0);
|
|
59
|
-
},
|
|
59
|
+
}, we = () => {
|
|
60
60
|
switch (v.value) {
|
|
61
61
|
case "left":
|
|
62
|
-
return
|
|
62
|
+
return ve.value ?? X.value;
|
|
63
63
|
case "right":
|
|
64
|
-
return
|
|
64
|
+
return he.value ?? X.value;
|
|
65
65
|
default:
|
|
66
|
-
return
|
|
66
|
+
return re.value ?? X.value;
|
|
67
67
|
}
|
|
68
|
-
}, x = () =>
|
|
68
|
+
}, x = () => ue.value?.getBoundingClientRect() || {
|
|
69
69
|
width: 0,
|
|
70
70
|
height: 0,
|
|
71
71
|
left: 0,
|
|
72
72
|
right: 0,
|
|
73
73
|
top: 0,
|
|
74
74
|
bottom: 0
|
|
75
|
-
},
|
|
75
|
+
}, ge = () => de.value?.getBoundingClientRect() || {
|
|
76
76
|
width: 0,
|
|
77
77
|
height: 0,
|
|
78
78
|
left: 0,
|
|
79
79
|
right: 0,
|
|
80
80
|
top: 0,
|
|
81
81
|
bottom: 0
|
|
82
|
-
},
|
|
82
|
+
}, K = (t, e) => {
|
|
83
83
|
const i = x();
|
|
84
84
|
return {
|
|
85
85
|
x: Math.max(0, Math.min(t, i.width - o.windowWidth)),
|
|
86
86
|
y: Math.max(0, Math.min(e, i.height - o.windowHeight))
|
|
87
87
|
};
|
|
88
|
-
}, we = () => {
|
|
89
|
-
const t = x(), e = t.width - o.windowWidth - 10, i = t.height - o.windowHeight - 10;
|
|
90
|
-
return q(e, i);
|
|
91
|
-
}, ge = () => {
|
|
92
|
-
const t = x(), e = he();
|
|
93
|
-
G.value = e.left <= t.left + o.edgeThreshold, J.value = e.right >= t.right - o.edgeThreshold;
|
|
94
88
|
}, me = () => {
|
|
95
|
-
const t = x(), e =
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
89
|
+
const t = x(), e = t.width - o.windowWidth - 10, i = t.height - o.windowHeight - 10;
|
|
90
|
+
return K(e, i);
|
|
91
|
+
}, pe = () => {
|
|
92
|
+
const t = x(), e = ge();
|
|
93
|
+
J.value = e.left <= t.left + o.edgeThreshold, q.value = e.right >= t.right - o.edgeThreshold;
|
|
94
|
+
}, be = () => {
|
|
95
|
+
const t = x(), e = ge(), i = e.left <= t.left + o.edgeThreshold ? "left" : e.right >= t.right - o.edgeThreshold ? "right" : "";
|
|
96
|
+
i !== v.value && (v.value = i, u.value && (u.value.volume = i ? 0.5 : 1), D(), g()), J.value = q.value = !1;
|
|
97
|
+
}, $e = (t) => {
|
|
98
|
+
B.value = !0, r.offsetX = t.clientX - r.x, r.offsetY = t.clientY - r.y, document.addEventListener("mousemove", Q), document.addEventListener("mouseup", Z);
|
|
99
|
+
}, Q = (t) => {
|
|
100
|
+
if (!B.value) return;
|
|
101
|
+
const e = x(), { x: i, y: c } = K(t.clientX - e.left - r.offsetX, t.clientY - e.top - r.offsetY);
|
|
102
|
+
r.x = i, r.y = c, pe();
|
|
103
|
+
}, Z = () => {
|
|
104
|
+
be(), B.value = !1, document.removeEventListener("mousemove", Q), document.removeEventListener("mouseup", Z);
|
|
105
|
+
}, ye = (t, e) => {
|
|
106
|
+
C.value = !0, r.offsetX = e.clientX - (e.clientX - o.windowWidth / 2), r.offsetY = e.clientY - (e.clientY - 20), document.addEventListener("mousemove", U);
|
|
107
|
+
}, U = (t) => {
|
|
108
|
+
if (!C.value) return;
|
|
109
109
|
const e = Math.abs(t.movementX), i = Math.abs(t.movementY);
|
|
110
|
-
(e > o.dragThreshold || i > o.dragThreshold) && (M.value = !0, v.value = "", document.removeEventListener("mousemove",
|
|
111
|
-
},
|
|
110
|
+
(e > o.dragThreshold || i > o.dragThreshold) && (M.value = !0, v.value = "", document.removeEventListener("mousemove", U), document.addEventListener("mousemove", ee), document.addEventListener("mouseup", te));
|
|
111
|
+
}, ee = (t) => {
|
|
112
112
|
if (!M.value) return;
|
|
113
|
-
const e = x(), { x: i, y:
|
|
114
|
-
r.x = i, r.y =
|
|
115
|
-
},
|
|
116
|
-
|
|
113
|
+
const e = x(), { x: i, y: c } = K(t.clientX - e.left - r.offsetX, t.clientY - e.top - r.offsetY);
|
|
114
|
+
r.x = i, r.y = c, pe();
|
|
115
|
+
}, te = () => {
|
|
116
|
+
be(), C.value = M.value = !1, document.removeEventListener("mousemove", ee), document.removeEventListener("mouseup", te);
|
|
117
117
|
}, z = () => {
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
if (!
|
|
118
|
+
C.value && !M.value && (C.value = !1, document.removeEventListener("mousemove", U));
|
|
119
|
+
}, ne = async (t) => {
|
|
120
|
+
if (!s.value || !b)
|
|
121
121
|
return;
|
|
122
|
+
await E(), console.log("已打断当前对话,准备播放新文本:", t);
|
|
122
123
|
const e = {
|
|
123
124
|
text: t,
|
|
124
125
|
type: "echo",
|
|
125
126
|
interrupt: !0,
|
|
126
|
-
sessionid: parseInt(
|
|
127
|
+
sessionid: parseInt(b)
|
|
127
128
|
};
|
|
128
|
-
|
|
129
|
+
ce.digitalHumanChat(o.baseUrl, e).then((i) => {
|
|
129
130
|
i && Number(i.code);
|
|
130
131
|
}).catch((i) => {
|
|
131
132
|
console.log("api.digitalHumanChat:", i);
|
|
132
133
|
});
|
|
134
|
+
}, E = async () => {
|
|
135
|
+
if (!s.value || !b) return;
|
|
136
|
+
const t = {
|
|
137
|
+
sessionid: parseInt(b)
|
|
138
|
+
};
|
|
139
|
+
ce.digitalHumanInterruptTalk(o.baseUrl, t).then((e) => {
|
|
140
|
+
e && Number(e.code) === 0 && console.log("数字人对话已成功打断");
|
|
141
|
+
}).catch((e) => {
|
|
142
|
+
console.log("api.digitalHumanInterruptTalk:", e);
|
|
143
|
+
});
|
|
133
144
|
}, S = () => {
|
|
134
|
-
|
|
135
|
-
},
|
|
145
|
+
I.value && (clearTimeout(I.value), I.value = null, console.log("重连定时器已清除")), W.value = !1;
|
|
146
|
+
}, D = (t = !1) => {
|
|
136
147
|
if (!a.value) return;
|
|
137
148
|
t || p.stopProcessing();
|
|
138
149
|
const e = a.value.getContext("2d");
|
|
139
150
|
if (e && (e.clearRect(0, 0, a.value.width, a.value.height), !t)) {
|
|
140
|
-
const i = a.value.width,
|
|
141
|
-
a.value.width = i, a.value.height =
|
|
151
|
+
const i = a.value.width, c = a.value.height;
|
|
152
|
+
a.value.width = i, a.value.height = c;
|
|
142
153
|
}
|
|
143
154
|
a.value && !t && (a.value.style.width = "", a.value.style.height = "", v.value === "" && (a.value.style.marginLeft = "", a.value.style.marginTop = ""));
|
|
144
155
|
}, g = async (t = !1) => {
|
|
145
|
-
if (!
|
|
156
|
+
if (!u.value || !a.value || !H.value || !s.value) return;
|
|
146
157
|
await m();
|
|
147
|
-
const e =
|
|
148
|
-
console.log("视频原始宽高比:",
|
|
149
|
-
let
|
|
150
|
-
const
|
|
151
|
-
|
|
158
|
+
const e = u.value.videoWidth || o.windowWidth, i = u.value.videoHeight || o.windowHeight, c = e / i;
|
|
159
|
+
console.log("视频原始宽高比:", c, "尺寸:", e, i);
|
|
160
|
+
let _;
|
|
161
|
+
const R = we();
|
|
162
|
+
R ? _ = R.getBoundingClientRect() : _ = {
|
|
152
163
|
width: v.value ? 0 : o.windowWidth,
|
|
153
164
|
height: v.value ? 0 : o.windowHeight,
|
|
154
165
|
left: 0,
|
|
@@ -156,310 +167,320 @@ const Ae = { class: "digital-human-assistant" }, Ne = { class: "placeholder left
|
|
|
156
167
|
right: 0,
|
|
157
168
|
bottom: 0
|
|
158
169
|
};
|
|
159
|
-
const F =
|
|
170
|
+
const F = _.width || (v.value ? 300 : o.windowWidth), N = _.height || (v.value ? window.innerHeight - 40 : o.windowHeight), Xe = F / N;
|
|
160
171
|
let T, k;
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
a.value.width = Math.floor(T *
|
|
172
|
+
Xe > c ? (k = N, T = k * c) : (T = F, k = T / c);
|
|
173
|
+
const Ce = window.devicePixelRatio || 1;
|
|
174
|
+
a.value.width = Math.floor(T * Ce), a.value.height = Math.floor(k * Ce), a.value.style.display = "block", a.value.style.objectFit = "contain", v.value === "" ? (a.value.style.width = `${T}px`, a.value.style.height = `${k}px`, a.value.style.marginLeft = `${(F - T) / 2}px`, a.value.style.marginTop = `${(N - k) / 2}px`) : (a.value.style.width = "100%", a.value.style.height = "100%", a.value.style.marginLeft = "0", a.value.style.marginTop = "0"), console.log("Canvas适配完成:", {
|
|
164
175
|
mode: v.value || "浮动",
|
|
165
|
-
container: { width: F, height:
|
|
176
|
+
container: { width: F, height: N },
|
|
166
177
|
canvas: { drawWidth: T, drawHeight: k, physicalWidth: a.value.width, physicalHeight: a.value.height }
|
|
167
|
-
}), t || (p.videoRef.value =
|
|
168
|
-
},
|
|
169
|
-
if (O.value ||
|
|
178
|
+
}), t || (p.videoRef.value = u.value, p.canvasRef.value = a.value, await p.processVideo());
|
|
179
|
+
}, $ = () => {
|
|
180
|
+
if (O.value || s.value || h.value || W.value) {
|
|
170
181
|
console.log("重连条件不满足:手动断开/已连接/正在连接/正在冷却");
|
|
171
182
|
return;
|
|
172
183
|
}
|
|
173
|
-
if (
|
|
174
|
-
console.
|
|
184
|
+
if (E().then(() => {
|
|
185
|
+
console.log("重连前已打断当前对话");
|
|
186
|
+
}), o.maxReconnectTimes !== -1 && y.value >= o.maxReconnectTimes) {
|
|
187
|
+
console.warn(`数字人重连已达最大次数(${o.maxReconnectTimes}),停止重连`), S(), Ee.funcElMessageShowCtrl(`数字人连接失败,已尝试${o.maxReconnectTimes}次重连,请重试!`), y.value = 0;
|
|
175
188
|
return;
|
|
176
189
|
}
|
|
177
|
-
W.value = !0,
|
|
190
|
+
W.value = !0, I.value = setTimeout(() => {
|
|
178
191
|
try {
|
|
179
|
-
|
|
192
|
+
y.value++, console.log(`数字人第${y.value}次重连... (最大次数:${o.maxReconnectTimes})`), _e();
|
|
180
193
|
} finally {
|
|
181
194
|
W.value = !1;
|
|
182
195
|
}
|
|
183
196
|
}, o.reconnectInterval * 1e3);
|
|
184
|
-
},
|
|
185
|
-
if (
|
|
197
|
+
}, Pe = async () => {
|
|
198
|
+
if (l)
|
|
186
199
|
try {
|
|
187
|
-
|
|
188
|
-
const t = await
|
|
189
|
-
await
|
|
190
|
-
if (
|
|
191
|
-
|
|
200
|
+
l.addTransceiver("video", { direction: "recvonly" }), l.addTransceiver("audio", { direction: "recvonly" });
|
|
201
|
+
const t = await l.createOffer();
|
|
202
|
+
await l.setLocalDescription(t), await new Promise((c) => {
|
|
203
|
+
if (l?.iceGatheringState === "complete")
|
|
204
|
+
c();
|
|
192
205
|
else {
|
|
193
|
-
const
|
|
194
|
-
|
|
206
|
+
const _ = () => {
|
|
207
|
+
l?.iceGatheringState === "complete" && (l?.removeEventListener("icegatheringstatechange", _), c());
|
|
195
208
|
};
|
|
196
|
-
|
|
209
|
+
l?.addEventListener("icegatheringstatechange", _);
|
|
197
210
|
}
|
|
198
211
|
});
|
|
199
|
-
const e =
|
|
212
|
+
const e = l.localDescription, i = {
|
|
200
213
|
sdp: e.sdp,
|
|
201
214
|
type: e.type
|
|
202
215
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}).catch((
|
|
206
|
-
console.error("api.digitalHumanOffer 失败:",
|
|
216
|
+
ce.digitalHumanOffer(o.baseUrl, i).then((c) => {
|
|
217
|
+
c ? (b = c.sessionid, l.setRemoteDescription(new RTCSessionDescription(c)), s.value = !0, y.value = 0, S(), console.log("数字人连接成功,重置重连状态"), m(() => g())) : (s.value = !1, console.log("数字人连接失败:接口返回空"), $()), h.value = !1;
|
|
218
|
+
}).catch((c) => {
|
|
219
|
+
console.error("api.digitalHumanOffer 失败:", c), s.value = !1, h.value = !1, $();
|
|
207
220
|
});
|
|
208
221
|
} catch (t) {
|
|
209
|
-
console.error("negotiate 失败:", t),
|
|
222
|
+
console.error("negotiate 失败:", t), s.value = !1, h.value = !1, $();
|
|
210
223
|
}
|
|
211
|
-
},
|
|
212
|
-
if (
|
|
224
|
+
}, _e = () => {
|
|
225
|
+
if (s.value || h.value) {
|
|
213
226
|
console.log("当前已连接/正在连接,无需重复触发");
|
|
214
227
|
return;
|
|
215
228
|
}
|
|
216
|
-
|
|
229
|
+
h.value = !0, console.log("开始建立数字人连接...");
|
|
217
230
|
const t = {
|
|
218
231
|
sdpSemantics: "unified-plan"
|
|
219
232
|
};
|
|
220
|
-
|
|
221
|
-
e.track.kind === "video" &&
|
|
222
|
-
|
|
223
|
-
},
|
|
233
|
+
l && (l.close(), l = null), l = new RTCPeerConnection(t), l.addEventListener("track", (e) => {
|
|
234
|
+
e.track.kind === "video" && u.value && (u.value.srcObject = e.streams[0], u.value.onloadedmetadata = async () => {
|
|
235
|
+
u.value && a.value && (p.videoRef.value = u.value, p.canvasRef.value = a.value, await g(), await p.processVideo());
|
|
236
|
+
}, u.value.onresize = () => {
|
|
224
237
|
g();
|
|
225
238
|
});
|
|
226
|
-
}),
|
|
227
|
-
switch (console.log("ICE连接状态变化:",
|
|
239
|
+
}), l.addEventListener("iceconnectionstatechange", () => {
|
|
240
|
+
switch (console.log("ICE连接状态变化:", l.iceConnectionState), l.iceConnectionState) {
|
|
228
241
|
case "disconnected":
|
|
229
242
|
case "failed":
|
|
230
243
|
case "closed":
|
|
231
|
-
console.log("WebRTC连接断开/失败,触发重连"),
|
|
244
|
+
console.log("WebRTC连接断开/失败,触发重连"), s.value = !1, h.value = !1, l = null, b = "", u.value && (u.value.srcObject = null), D(), E().then(() => {
|
|
245
|
+
console.log("ICE连接断开,已打断对话");
|
|
246
|
+
}), $();
|
|
232
247
|
break;
|
|
233
248
|
case "connected":
|
|
234
|
-
|
|
249
|
+
y.value = 0, S(), console.log("ICE连接成功,重置重连状态"), m(() => g());
|
|
235
250
|
break;
|
|
236
251
|
}
|
|
237
|
-
}),
|
|
238
|
-
},
|
|
239
|
-
O.value = !0, S(),
|
|
240
|
-
|
|
252
|
+
}), Pe();
|
|
253
|
+
}, Ve = () => {
|
|
254
|
+
O.value = !0, S(), h.value = !1, p.stopProcessing(), D(), E().then(() => {
|
|
255
|
+
console.log("手动断开连接,已打断当前对话");
|
|
256
|
+
}), setTimeout(() => {
|
|
257
|
+
l && (l.close(), l = null), b = "", u.value && (u.value.srcObject = null), s.value = !1, y.value = 0, console.log("手动断开连接,重置所有状态");
|
|
241
258
|
}, 500);
|
|
242
259
|
};
|
|
243
|
-
|
|
244
|
-
digitalHumanChat:
|
|
260
|
+
Le({
|
|
261
|
+
digitalHumanChat: ne,
|
|
245
262
|
// 播放文本的核心方法
|
|
246
|
-
|
|
263
|
+
digitalHumanInterruptTalk: E,
|
|
264
|
+
// 打断方法
|
|
265
|
+
isConnected: s,
|
|
247
266
|
// 连接状态
|
|
248
|
-
isConnecting:
|
|
267
|
+
isConnecting: h,
|
|
249
268
|
// 连接中状态
|
|
250
|
-
reconnect:
|
|
269
|
+
reconnect: $,
|
|
251
270
|
// 手动触发重连
|
|
252
271
|
clearReconnectTimer: S,
|
|
253
272
|
// 手动停止重连
|
|
254
|
-
currentReconnectTimes:
|
|
273
|
+
currentReconnectTimes: y,
|
|
255
274
|
// 暴露当前重连次数,方便调试
|
|
256
275
|
isWaitingReconnect: W,
|
|
257
276
|
adaptCanvasToContainer: g
|
|
258
277
|
// 暴露适配方法,方便父组件调用
|
|
259
|
-
}),
|
|
278
|
+
}), oe(
|
|
260
279
|
v,
|
|
261
280
|
async (t, e) => {
|
|
262
|
-
!
|
|
281
|
+
!H.value || !u.value || (await m(), u.value.volume = t ? 0.5 : 1, s.value && (D(), await g()));
|
|
263
282
|
},
|
|
264
283
|
{ immediate: !0, deep: !0 }
|
|
265
|
-
),
|
|
266
|
-
[() =>
|
|
284
|
+
), oe(
|
|
285
|
+
[() => s.value, () => o.defaultPlayText],
|
|
267
286
|
async ([t, e], [i]) => {
|
|
268
|
-
t && !i && e &&
|
|
287
|
+
t && !i && e && b && (console.log("连接成功,自动播放默认文本:", e), await ne(e), m(() => g()));
|
|
269
288
|
},
|
|
270
289
|
{ immediate: !1 }
|
|
271
|
-
),
|
|
290
|
+
), oe(
|
|
272
291
|
() => o.defaultPlayText,
|
|
273
292
|
async (t) => {
|
|
274
|
-
|
|
293
|
+
s.value && t && b && (console.log("默认文本加载完成,自动播放:", t), await ne(t), m(() => g()));
|
|
275
294
|
},
|
|
276
295
|
{ immediate: !0 }
|
|
277
|
-
),
|
|
278
|
-
await m(), await m(),
|
|
279
|
-
const { x: t, y: e } =
|
|
280
|
-
r.x = t, r.y = e, window.addEventListener("resize",
|
|
296
|
+
), Be(async () => {
|
|
297
|
+
await m(), await m(), H.value = !0;
|
|
298
|
+
const { x: t, y: e } = me();
|
|
299
|
+
r.x = t, r.y = e, window.addEventListener("resize", Re);
|
|
281
300
|
});
|
|
282
|
-
const
|
|
301
|
+
const Re = Ee.debounce(() => {
|
|
283
302
|
if (v.value === "") {
|
|
284
|
-
const { x: t, y: e } =
|
|
303
|
+
const { x: t, y: e } = me();
|
|
285
304
|
r.x = t, r.y = e;
|
|
286
305
|
}
|
|
287
|
-
|
|
306
|
+
s.value && H.value && (D(!0), m(() => g(!0)));
|
|
288
307
|
}, 50);
|
|
289
|
-
return
|
|
290
|
-
|
|
308
|
+
return Ie(() => {
|
|
309
|
+
E().then(() => {
|
|
310
|
+
console.log("组件卸载,已打断当前对话");
|
|
311
|
+
}), document.removeEventListener("mousemove", U), document.removeEventListener("mousemove", ee), document.removeEventListener("mouseup", te), document.removeEventListener("mousemove", Q), document.removeEventListener("mouseup", Z), window.removeEventListener("resize", Re), S(), p.stopProcessing(), u.value && (u.value.srcObject = null), l && l.close();
|
|
291
312
|
}), (t, e) => {
|
|
292
|
-
const i = Oe("CloseBold"),
|
|
293
|
-
return
|
|
313
|
+
const i = Oe("CloseBold"), c = Ne, _ = je("drag");
|
|
314
|
+
return P(), A("div", {
|
|
294
315
|
class: "draggable-window-container",
|
|
295
|
-
style:
|
|
316
|
+
style: ke(He.value)
|
|
296
317
|
}, [
|
|
297
|
-
|
|
298
|
-
[w,
|
|
299
|
-
[
|
|
318
|
+
f(n("div", Ae, null, 512), [
|
|
319
|
+
[w, fe.value],
|
|
320
|
+
[_, ["digital-human-assistant", De, !0]]
|
|
300
321
|
]),
|
|
301
322
|
n("div", {
|
|
302
323
|
ref_key: "teleportFallbackRef",
|
|
303
|
-
ref:
|
|
324
|
+
ref: X,
|
|
304
325
|
class: "teleport-fallback"
|
|
305
326
|
}, null, 512),
|
|
306
|
-
|
|
307
|
-
[w, G.value]
|
|
308
|
-
]),
|
|
309
|
-
h(n("div", Ge, null, 512), [
|
|
327
|
+
f(n("div", Ge, null, 512), [
|
|
310
328
|
[w, J.value]
|
|
311
329
|
]),
|
|
312
|
-
|
|
330
|
+
f(n("div", Je, null, 512), [
|
|
331
|
+
[w, q.value]
|
|
332
|
+
]),
|
|
333
|
+
Y.value && v.value === "left" ? (P(), A("div", {
|
|
313
334
|
key: 0,
|
|
314
|
-
class:
|
|
335
|
+
class: xe(["sidebar left-sidebar", { pressing: C.value }])
|
|
315
336
|
}, [
|
|
316
337
|
n("div", {
|
|
317
338
|
class: "window-header",
|
|
318
|
-
onMousedown: e[2] || (e[2] = (
|
|
339
|
+
onMousedown: e[2] || (e[2] = (R) => ye("left", R)),
|
|
319
340
|
onMouseup: z,
|
|
320
341
|
onMouseleave: z
|
|
321
342
|
}, [
|
|
322
|
-
n("div",
|
|
323
|
-
n("span",
|
|
324
|
-
n("div",
|
|
325
|
-
|
|
326
|
-
[w, !
|
|
343
|
+
n("div", qe, [
|
|
344
|
+
n("span", Ke, ae(V.windowTitle), 1),
|
|
345
|
+
n("div", Qe, [
|
|
346
|
+
f(n("button", Ze, "未连接", 512), [
|
|
347
|
+
[w, !s.value && !h.value]
|
|
327
348
|
]),
|
|
328
|
-
|
|
329
|
-
[w,
|
|
349
|
+
f(n("button", et, "连接中...", 512), [
|
|
350
|
+
[w, h.value]
|
|
330
351
|
]),
|
|
331
|
-
|
|
332
|
-
[w,
|
|
352
|
+
f(n("button", tt, "已连接", 512), [
|
|
353
|
+
[w, s.value]
|
|
333
354
|
])
|
|
334
355
|
])
|
|
335
356
|
]),
|
|
336
|
-
|
|
357
|
+
L(c, {
|
|
337
358
|
class: "drag-window-hide",
|
|
338
|
-
onClick: e[0] || (e[0] = (
|
|
339
|
-
onMousedown: e[1] || (e[1] =
|
|
359
|
+
onClick: e[0] || (e[0] = (R) => j(!1)),
|
|
360
|
+
onMousedown: e[1] || (e[1] = ie(() => {
|
|
340
361
|
}, ["stop"]))
|
|
341
362
|
}, {
|
|
342
|
-
default:
|
|
343
|
-
|
|
363
|
+
default: le(() => [
|
|
364
|
+
L(i)
|
|
344
365
|
]),
|
|
345
366
|
_: 1
|
|
346
367
|
})
|
|
347
368
|
], 32),
|
|
348
|
-
n("div",
|
|
369
|
+
n("div", nt, [
|
|
349
370
|
se(t.$slots, "sidebar-left", {}, void 0, !0),
|
|
350
371
|
n("div", {
|
|
351
372
|
ref_key: "sidebarLeftVideoRef",
|
|
352
|
-
ref:
|
|
373
|
+
ref: ve,
|
|
353
374
|
class: "sidebar-video-container"
|
|
354
375
|
}, null, 512)
|
|
355
376
|
])
|
|
356
|
-
], 2)) :
|
|
377
|
+
], 2)) : G("", !0),
|
|
357
378
|
n("div", {
|
|
358
379
|
class: "main-content-outer",
|
|
359
380
|
ref_key: "containerRef",
|
|
360
|
-
ref:
|
|
381
|
+
ref: ue
|
|
361
382
|
}, [
|
|
362
|
-
n("div",
|
|
383
|
+
n("div", ot, [
|
|
363
384
|
se(t.$slots, "main", {}, void 0, !0)
|
|
364
385
|
]),
|
|
365
|
-
|
|
386
|
+
Y.value && v.value === "" ? (P(), A("div", {
|
|
366
387
|
key: 0,
|
|
367
388
|
ref_key: "dragWindowRef",
|
|
368
|
-
ref:
|
|
389
|
+
ref: de,
|
|
369
390
|
class: "draggable-window",
|
|
370
|
-
style:
|
|
391
|
+
style: ke(Me.value)
|
|
371
392
|
}, [
|
|
372
393
|
n("div", {
|
|
373
394
|
class: "window-header",
|
|
374
|
-
onMousedown:
|
|
395
|
+
onMousedown: $e
|
|
375
396
|
}, [
|
|
376
|
-
n("div",
|
|
377
|
-
n("span",
|
|
378
|
-
n("div",
|
|
379
|
-
|
|
380
|
-
[w, !
|
|
397
|
+
n("div", at, [
|
|
398
|
+
n("span", it, ae(V.windowTitle), 1),
|
|
399
|
+
n("div", lt, [
|
|
400
|
+
f(n("button", st, "未连接", 512), [
|
|
401
|
+
[w, !s.value && !h.value]
|
|
381
402
|
]),
|
|
382
|
-
|
|
383
|
-
[w,
|
|
403
|
+
f(n("button", ct, "连接中...", 512), [
|
|
404
|
+
[w, h.value]
|
|
384
405
|
]),
|
|
385
|
-
|
|
386
|
-
[w,
|
|
406
|
+
f(n("button", dt, "已连接", 512), [
|
|
407
|
+
[w, s.value]
|
|
387
408
|
])
|
|
388
409
|
])
|
|
389
410
|
]),
|
|
390
|
-
|
|
411
|
+
L(c, {
|
|
391
412
|
class: "drag-window-hide",
|
|
392
|
-
onClick: e[3] || (e[3] = (
|
|
393
|
-
onMousedown: e[4] || (e[4] =
|
|
413
|
+
onClick: e[3] || (e[3] = (R) => j(!1)),
|
|
414
|
+
onMousedown: e[4] || (e[4] = ie(() => {
|
|
394
415
|
}, ["stop"]))
|
|
395
416
|
}, {
|
|
396
|
-
default:
|
|
397
|
-
|
|
417
|
+
default: le(() => [
|
|
418
|
+
L(i)
|
|
398
419
|
]),
|
|
399
420
|
_: 1
|
|
400
421
|
})
|
|
401
422
|
], 32),
|
|
402
|
-
n("div",
|
|
423
|
+
n("div", ut, [
|
|
403
424
|
n("div", {
|
|
404
425
|
class: "video-container",
|
|
405
426
|
ref_key: "windowVideoRef",
|
|
406
|
-
ref:
|
|
427
|
+
ref: re
|
|
407
428
|
}, null, 512)
|
|
408
429
|
])
|
|
409
|
-
], 4)) :
|
|
430
|
+
], 4)) : G("", !0)
|
|
410
431
|
], 512),
|
|
411
|
-
|
|
432
|
+
Y.value && v.value === "right" ? (P(), A("div", {
|
|
412
433
|
key: 1,
|
|
413
|
-
class:
|
|
434
|
+
class: xe(["sidebar right-sidebar", { pressing: C.value }])
|
|
414
435
|
}, [
|
|
415
436
|
n("div", {
|
|
416
437
|
class: "window-header",
|
|
417
|
-
onMousedown: e[7] || (e[7] = (
|
|
438
|
+
onMousedown: e[7] || (e[7] = (R) => ye("right", R)),
|
|
418
439
|
onMouseup: z,
|
|
419
440
|
onMouseleave: z
|
|
420
441
|
}, [
|
|
421
|
-
n("div",
|
|
422
|
-
n("span",
|
|
423
|
-
n("div",
|
|
424
|
-
|
|
425
|
-
[w, !
|
|
442
|
+
n("div", rt, [
|
|
443
|
+
n("span", vt, ae(V.windowTitle), 1),
|
|
444
|
+
n("div", ht, [
|
|
445
|
+
f(n("button", ft, "未连接", 512), [
|
|
446
|
+
[w, !s.value && !h.value]
|
|
426
447
|
]),
|
|
427
|
-
|
|
428
|
-
[w,
|
|
448
|
+
f(n("button", wt, "连接中...", 512), [
|
|
449
|
+
[w, h.value]
|
|
429
450
|
]),
|
|
430
|
-
|
|
431
|
-
[w,
|
|
451
|
+
f(n("button", gt, "已连接", 512), [
|
|
452
|
+
[w, s.value]
|
|
432
453
|
])
|
|
433
454
|
])
|
|
434
455
|
]),
|
|
435
|
-
|
|
456
|
+
L(c, {
|
|
436
457
|
class: "drag-window-hide",
|
|
437
|
-
onClick: e[5] || (e[5] = (
|
|
438
|
-
onMousedown: e[6] || (e[6] =
|
|
458
|
+
onClick: e[5] || (e[5] = (R) => j(!1)),
|
|
459
|
+
onMousedown: e[6] || (e[6] = ie(() => {
|
|
439
460
|
}, ["stop"]))
|
|
440
461
|
}, {
|
|
441
|
-
default:
|
|
442
|
-
|
|
462
|
+
default: le(() => [
|
|
463
|
+
L(i)
|
|
443
464
|
]),
|
|
444
465
|
_: 1
|
|
445
466
|
})
|
|
446
467
|
], 32),
|
|
447
|
-
n("div",
|
|
468
|
+
n("div", mt, [
|
|
448
469
|
se(t.$slots, "sidebar-right", {}, void 0, !0),
|
|
449
470
|
n("div", {
|
|
450
471
|
ref_key: "sidebarRightVideoRef",
|
|
451
|
-
ref:
|
|
472
|
+
ref: he,
|
|
452
473
|
class: "sidebar-video-container"
|
|
453
474
|
}, null, 512)
|
|
454
475
|
])
|
|
455
|
-
], 2)) :
|
|
456
|
-
|
|
476
|
+
], 2)) : G("", !0),
|
|
477
|
+
H.value ? (P(), Ue(ze, {
|
|
457
478
|
key: 2,
|
|
458
|
-
to:
|
|
479
|
+
to: we()
|
|
459
480
|
}, [
|
|
460
481
|
n("video", {
|
|
461
482
|
ref_key: "digitalHumanVideo",
|
|
462
|
-
ref:
|
|
483
|
+
ref: u,
|
|
463
484
|
class: "digital-video source-video",
|
|
464
485
|
poster: "",
|
|
465
486
|
playsinline: "",
|
|
@@ -470,11 +491,11 @@ const Ae = { class: "digital-human-assistant" }, Ne = { class: "placeholder left
|
|
|
470
491
|
ref: a,
|
|
471
492
|
class: "digital-video processed-canvas"
|
|
472
493
|
}, null, 512)
|
|
473
|
-
], 8, ["to"])) :
|
|
494
|
+
], 8, ["to"])) : G("", !0)
|
|
474
495
|
], 4);
|
|
475
496
|
};
|
|
476
497
|
}
|
|
477
498
|
});
|
|
478
499
|
export {
|
|
479
|
-
|
|
500
|
+
kt as default
|
|
480
501
|
};
|