@scienjoy/sj-ai-plus 1.0.8 → 1.0.9

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