@somecat/ai-assist-sdk 1.3.2 → 1.3.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/dist/ai-assist-sdk.css +1 -1
- package/dist/react/index.mjs +442 -440
- package/dist/vue/index.mjs +771 -762
- package/package.json +1 -1
package/dist/vue/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as Ee, ref as g, watch as ve, nextTick as me, onUnmounted as Pe, openBlock as v, createElementBlock as m, normalizeClass as se, createElementVNode as o, toDisplayString as z, createVNode as ie, Transition as yn, withCtx as wn, unref as O, createCommentVNode as J, computed as B, Fragment as we, renderList as xe, reactive as ye, createStaticVNode as kn, withModifiers as fe, createBlock as pe, Teleport as Yt, onMounted as be, onBeforeUnmount as Nt, withDirectives as Me, withKeys as ct, vModelText as Vt, normalizeStyle as it, vShow as Ve, createApp as Cn } from "vue";
|
|
2
2
|
import { a as Xt, r as vt, p as dt, u as _n, V as Qe, c as Mt, g as bn, o as An, s as Sn, b as Rt, e as En, d as Tn, f as qe, h as xn, i as Dn, j as Mn, k as Rn, l as Hn, m as ht, w as $n, n as Ln, q as Pn, t as Ft } from "../chunks/index-5fjEwBkV.mjs";
|
|
3
3
|
import { t as Ht, r as On, f as Bn, i as Wn, s as Yn, a as Nn, b as Vn, c as Te, d as Xn, e as Qt, g as Fn, h as Qn, m as Jn } from "../chunks/index-2loQl224.mjs";
|
|
4
4
|
import { BulbOutlined as qn, SearchOutlined as $t, CheckOutlined as zn, CopyOutlined as Kn, RedoOutlined as Gn, CloseOutlined as jn } from "@ant-design/icons-vue";
|
|
5
|
-
import { Icon as
|
|
6
|
-
const Un = "data:image/png;base64,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", Zn = { class: "thinking-block__title" }, In = ["innerHTML"], eo = /* @__PURE__ */
|
|
5
|
+
import { Icon as ce } from "@iconify/vue";
|
|
6
|
+
const Un = "data:image/png;base64,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", Zn = { class: "thinking-block__title" }, In = ["innerHTML"], eo = /* @__PURE__ */ Ee({
|
|
7
7
|
__name: "ThinkingBlock",
|
|
8
8
|
props: {
|
|
9
9
|
content: {},
|
|
@@ -13,10 +13,10 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
13
13
|
setup(t) {
|
|
14
14
|
const w = t, i = g(!!w.isStreaming || !!w.messageDone);
|
|
15
15
|
let u = 0;
|
|
16
|
-
function l(
|
|
16
|
+
function l(p = 600) {
|
|
17
17
|
clearTimeout(u), u = window.setTimeout(() => {
|
|
18
18
|
u = 0, i.value = !1;
|
|
19
|
-
},
|
|
19
|
+
}, p);
|
|
20
20
|
}
|
|
21
21
|
function h() {
|
|
22
22
|
u && (clearTimeout(u), u = 0);
|
|
@@ -24,41 +24,41 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
24
24
|
function s() {
|
|
25
25
|
h(), i.value = !i.value;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
ve(
|
|
28
28
|
() => w.isStreaming,
|
|
29
|
-
(
|
|
30
|
-
|
|
29
|
+
(p) => {
|
|
30
|
+
p ? (h(), i.value = !0) : w.messageDone || l();
|
|
31
31
|
},
|
|
32
32
|
{ immediate: !0 }
|
|
33
|
-
),
|
|
33
|
+
), ve(
|
|
34
34
|
() => w.messageDone,
|
|
35
|
-
(
|
|
36
|
-
|
|
35
|
+
(p) => {
|
|
36
|
+
p && (h(), i.value = !0);
|
|
37
37
|
},
|
|
38
38
|
{ immediate: !0 }
|
|
39
39
|
);
|
|
40
40
|
const a = g(null);
|
|
41
41
|
let r = !1;
|
|
42
42
|
function f() {
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
r =
|
|
43
|
+
const p = a.value;
|
|
44
|
+
if (!p) return;
|
|
45
|
+
r = p.scrollHeight - p.scrollTop - p.clientHeight > 12;
|
|
46
46
|
}
|
|
47
47
|
function k() {
|
|
48
|
-
const
|
|
49
|
-
!
|
|
48
|
+
const p = a.value;
|
|
49
|
+
!p || !i.value || r || (p.scrollTop = p.scrollHeight);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function V() {
|
|
52
52
|
w.isStreaming && k();
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return ve(
|
|
55
55
|
() => w.content,
|
|
56
56
|
() => {
|
|
57
57
|
w.isStreaming && me(k);
|
|
58
58
|
}
|
|
59
59
|
), Pe(() => {
|
|
60
60
|
h();
|
|
61
|
-
}), (
|
|
61
|
+
}), (p, R) => (v(), m("div", {
|
|
62
62
|
class: se(["thinking-block", {
|
|
63
63
|
"thinking-block--expanded": i.value,
|
|
64
64
|
"thinking-block--active": t.isStreaming
|
|
@@ -68,8 +68,8 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
68
68
|
class: "thinking-block__header",
|
|
69
69
|
onClick: s
|
|
70
70
|
}, [
|
|
71
|
-
|
|
72
|
-
o("span", Zn,
|
|
71
|
+
R[1] || (R[1] = o("span", { class: "thinking-block__indicator" }, null, -1)),
|
|
72
|
+
o("span", Zn, z(t.isStreaming ? "深度思考中" : "深度思考"), 1),
|
|
73
73
|
(v(), m("svg", {
|
|
74
74
|
class: se(["thinking-block__arrow", { "thinking-block__arrow--down": i.value }]),
|
|
75
75
|
viewBox: "0 0 24 24",
|
|
@@ -80,13 +80,13 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
80
80
|
"stroke-width": "2.5",
|
|
81
81
|
"stroke-linecap": "round",
|
|
82
82
|
"stroke-linejoin": "round"
|
|
83
|
-
}, [...
|
|
83
|
+
}, [...R[0] || (R[0] = [
|
|
84
84
|
o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
|
|
85
85
|
])], 2))
|
|
86
86
|
]),
|
|
87
87
|
ie(yn, {
|
|
88
88
|
name: "thinking-expand",
|
|
89
|
-
onAfterEnter:
|
|
89
|
+
onAfterEnter: V
|
|
90
90
|
}, {
|
|
91
91
|
default: wn(() => [
|
|
92
92
|
i.value ? (v(), m("div", {
|
|
@@ -98,9 +98,9 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
98
98
|
}, [
|
|
99
99
|
o("div", {
|
|
100
100
|
class: "thinking-block__markdown",
|
|
101
|
-
innerHTML:
|
|
101
|
+
innerHTML: O(Xt)(O(vt)(O(dt)(w.content)), t.isStreaming)
|
|
102
102
|
}, null, 8, In)
|
|
103
|
-
], 544)) :
|
|
103
|
+
], 544)) : J("", !0)
|
|
104
104
|
]),
|
|
105
105
|
_: 1
|
|
106
106
|
})
|
|
@@ -144,13 +144,13 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
144
144
|
}, po = {
|
|
145
145
|
key: 0,
|
|
146
146
|
class: "step-item__content"
|
|
147
|
-
}, mo = /* @__PURE__ */
|
|
147
|
+
}, mo = /* @__PURE__ */ Ee({
|
|
148
148
|
__name: "StepBlock",
|
|
149
149
|
props: {
|
|
150
150
|
steps: {}
|
|
151
151
|
},
|
|
152
152
|
setup(t) {
|
|
153
|
-
const w = t, i =
|
|
153
|
+
const w = t, i = B(() => w.steps.some((h) => h.state !== "done")), u = B(
|
|
154
154
|
() => w.steps.reduce((h, s) => h + (s.duration ?? 0), 0)
|
|
155
155
|
);
|
|
156
156
|
function l(h) {
|
|
@@ -162,11 +162,11 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
162
162
|
t.steps.length > 1 ? (v(), m("div", to, [
|
|
163
163
|
s[0] || (s[0] = o("span", { class: "step-block__indicator" }, null, -1)),
|
|
164
164
|
s[1] || (s[1] = o("span", { class: "step-block__title" }, "执行步骤", -1)),
|
|
165
|
-
i.value ?
|
|
166
|
-
!i.value && u.value > 0 ? (v(), m("span", oo,
|
|
167
|
-
])) :
|
|
165
|
+
i.value ? J("", !0) : (v(), m("span", no, z(t.steps.length) + " 步", 1)),
|
|
166
|
+
!i.value && u.value > 0 ? (v(), m("span", oo, z(l(u.value)), 1)) : J("", !0)
|
|
167
|
+
])) : J("", !0),
|
|
168
168
|
o("ul", so, [
|
|
169
|
-
(v(!0), m(
|
|
169
|
+
(v(!0), m(we, null, xe(t.steps, (a, r) => (v(), m("li", {
|
|
170
170
|
key: r,
|
|
171
171
|
class: se(["step-item", `step-item--${a.state}`])
|
|
172
172
|
}, [
|
|
@@ -185,10 +185,10 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
185
185
|
]),
|
|
186
186
|
o("div", ro, [
|
|
187
187
|
o("div", co, [
|
|
188
|
-
o("span", vo,
|
|
189
|
-
a.state === "done" && a.duration != null && a.duration > 0 ? (v(), m("span", ho,
|
|
188
|
+
o("span", vo, z(a.title || "处理中"), 1),
|
|
189
|
+
a.state === "done" && a.duration != null && a.duration > 0 ? (v(), m("span", ho, z(l(a.duration)), 1)) : J("", !0)
|
|
190
190
|
]),
|
|
191
|
-
a.content ? (v(), m("div", po,
|
|
191
|
+
a.content ? (v(), m("div", po, z(a.content), 1)) : J("", !0)
|
|
192
192
|
])
|
|
193
193
|
], 2))), 128))
|
|
194
194
|
])
|
|
@@ -196,7 +196,7 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
196
196
|
}
|
|
197
197
|
});
|
|
198
198
|
function fo(t, w) {
|
|
199
|
-
const i =
|
|
199
|
+
const i = B(() => t().segments), u = B(() => Ht(i.value)), l = B(() => !!t().streamed), h = B(() => {
|
|
200
200
|
const _ = t().status;
|
|
201
201
|
return _ === "stop" || _ === "error";
|
|
202
202
|
}), s = g(t().streamed ? 0 : Ht(t().segments)), a = g(0);
|
|
@@ -204,16 +204,16 @@ function fo(t, w) {
|
|
|
204
204
|
function k(_) {
|
|
205
205
|
s.value !== _ && (s.value = _);
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function V() {
|
|
208
208
|
if (r) return;
|
|
209
|
-
const _ = (
|
|
209
|
+
const _ = (E) => {
|
|
210
210
|
if (f === 0) {
|
|
211
|
-
f =
|
|
211
|
+
f = E, r = requestAnimationFrame(_);
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
f =
|
|
216
|
-
const n = u.value,
|
|
214
|
+
const te = Math.min(E - f, 100);
|
|
215
|
+
f = E;
|
|
216
|
+
const n = u.value, d = Yn(i.value, s.value), C = Nn(s.value, n, a.value, te, d);
|
|
217
217
|
if (a.value = C.frac, C.reveal !== s.value && (s.value = C.reveal, w == null || w()), s.value >= n) {
|
|
218
218
|
r = 0, f = 0;
|
|
219
219
|
return;
|
|
@@ -222,34 +222,34 @@ function fo(t, w) {
|
|
|
222
222
|
};
|
|
223
223
|
f = 0, r = requestAnimationFrame(_);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function p() {
|
|
226
226
|
r && (cancelAnimationFrame(r), r = 0);
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
ve(
|
|
229
229
|
[l, u],
|
|
230
230
|
() => {
|
|
231
231
|
if (!l.value || h.value) {
|
|
232
232
|
k(u.value);
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
s.value < u.value &&
|
|
235
|
+
s.value < u.value && V();
|
|
236
236
|
},
|
|
237
237
|
{ immediate: !0 }
|
|
238
|
-
),
|
|
238
|
+
), ve(h, (_) => {
|
|
239
239
|
_ && l.value && k(u.value);
|
|
240
|
-
}),
|
|
240
|
+
}), ve(
|
|
241
241
|
() => t().status,
|
|
242
|
-
(_,
|
|
243
|
-
_ === "rethinking" &&
|
|
242
|
+
(_, E) => {
|
|
243
|
+
_ === "rethinking" && E !== "rethinking" && (a.value = 0, k(0), u.value > 0 && V());
|
|
244
244
|
}
|
|
245
|
-
), Pe(
|
|
246
|
-
const
|
|
245
|
+
), Pe(p);
|
|
246
|
+
const R = B(() => On(i.value, s.value)), X = B(
|
|
247
247
|
() => l.value ? Bn(i.value, s.value) : -1
|
|
248
|
-
), K =
|
|
249
|
-
function
|
|
248
|
+
), K = B(() => !l.value || s.value >= u.value);
|
|
249
|
+
function G(_) {
|
|
250
250
|
return Wn(i.value, _, s.value);
|
|
251
251
|
}
|
|
252
|
-
return { reveal: s, segmentContents:
|
|
252
|
+
return { reveal: s, segmentContents: R, frontier: X, revealDone: K, isSegRevealed: G, stopLoop: p };
|
|
253
253
|
}
|
|
254
254
|
const go = {
|
|
255
255
|
key: 0,
|
|
@@ -275,7 +275,7 @@ const go = {
|
|
|
275
275
|
}, Ho = {
|
|
276
276
|
key: 1,
|
|
277
277
|
class: "message-content"
|
|
278
|
-
}, $o = ["src"], Lo = /* @__PURE__ */
|
|
278
|
+
}, $o = ["src"], Lo = /* @__PURE__ */ Ee({
|
|
279
279
|
__name: "MessageItem",
|
|
280
280
|
props: {
|
|
281
281
|
msg: {},
|
|
@@ -289,80 +289,80 @@ const go = {
|
|
|
289
289
|
const i = t, { reveal: u, segmentContents: l, frontier: h, revealDone: s } = fo(
|
|
290
290
|
() => i.msg,
|
|
291
291
|
() => i.scrollToBottom()
|
|
292
|
-
), a =
|
|
292
|
+
), a = B(
|
|
293
293
|
() => i.msg.status === i.STATUS.COMPLETED || i.msg.status === i.STATUS.STOP
|
|
294
|
-
), r =
|
|
295
|
-
|
|
294
|
+
), r = B(() => a.value && s.value), f = g(!1);
|
|
295
|
+
ve(r, (y) => {
|
|
296
296
|
y && (f.value = !1);
|
|
297
297
|
});
|
|
298
|
-
const k =
|
|
298
|
+
const k = B(() => Vn(i.msg.segments, u.value)), V = B(() => k.value.length > 0), p = B(() => k.value.some((y) => y.kind === "thinking")), R = B(() => k.value.some((y) => y.kind === "tools")), X = B(() => k.value.some((y) => y.kind === "steps")), K = B(() => {
|
|
299
299
|
const y = [];
|
|
300
|
-
return
|
|
301
|
-
}),
|
|
300
|
+
return p.value && y.push("深度思考"), R.value && y.push("工具调用"), X.value && y.push("执行步骤"), y.join(" · ") || "思考过程";
|
|
301
|
+
}), G = B(() => !r.value || f.value), _ = B(
|
|
302
302
|
() => (i.msg.segments ?? []).reduce(
|
|
303
|
-
(y,
|
|
303
|
+
(y, L) => L.type === "thinking" || L.type === "agent_thought" || L.type === "step" ? y + (L.duration ?? 0) : y,
|
|
304
304
|
0
|
|
305
305
|
)
|
|
306
|
-
),
|
|
306
|
+
), E = B(
|
|
307
307
|
() => (i.msg.segments ?? []).some(
|
|
308
|
-
(y,
|
|
308
|
+
(y, L) => y.type === "answer" && (l.value[L] || "").length > 0
|
|
309
309
|
)
|
|
310
|
-
),
|
|
311
|
-
() => !r.value && i.msg.status !== i.STATUS.ERROR && i.msg.status !== i.STATUS.PAUSED && k.value.length === 0 && !
|
|
310
|
+
), te = B(
|
|
311
|
+
() => !r.value && i.msg.status !== i.STATUS.ERROR && i.msg.status !== i.STATUS.PAUSED && k.value.length === 0 && !E.value
|
|
312
312
|
);
|
|
313
313
|
function n(y) {
|
|
314
314
|
return y == null || y <= 0 ? "" : y < 1 ? `${Math.round(y * 1e3)}ms` : y < 60 ? `${y.toFixed(1)}s` : `${Math.floor(y / 60)}m${Math.round(y % 60)}s`;
|
|
315
315
|
}
|
|
316
|
-
const
|
|
317
|
-
function
|
|
318
|
-
const
|
|
319
|
-
|
|
316
|
+
const d = ye(/* @__PURE__ */ new Map()), C = g("");
|
|
317
|
+
function D(y) {
|
|
318
|
+
const L = y.target;
|
|
319
|
+
L.tagName === "IMG" && (C.value = L.src);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function T() {
|
|
322
322
|
C.value = "";
|
|
323
323
|
}
|
|
324
|
-
function W(y,
|
|
324
|
+
function W(y, L) {
|
|
325
325
|
var ne;
|
|
326
326
|
try {
|
|
327
327
|
let S = y.content;
|
|
328
|
-
if (!S && ((ne = y.segments) != null && ne.length) && (S = y.segments.filter((
|
|
328
|
+
if (!S && ((ne = y.segments) != null && ne.length) && (S = y.segments.filter((q) => q.type === "answer").map((q) => q.content).join(`
|
|
329
329
|
`)), S) {
|
|
330
|
-
const { copy:
|
|
331
|
-
|
|
330
|
+
const { copy: q } = _n();
|
|
331
|
+
q(S), d.set(L, !0), setTimeout(() => d.set(L, !1), 2e3);
|
|
332
332
|
}
|
|
333
333
|
} catch {
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
return (y,
|
|
336
|
+
return (y, L) => {
|
|
337
337
|
var ne;
|
|
338
338
|
return v(), m("div", {
|
|
339
339
|
class: se(["message", `${t.msg.type}-message`])
|
|
340
340
|
}, [
|
|
341
|
-
t.msg.type === "ai" ? (v(), m(
|
|
342
|
-
|
|
341
|
+
t.msg.type === "ai" ? (v(), m(we, { key: 0 }, [
|
|
342
|
+
te.value ? (v(), m("div", go, [...L[4] || (L[4] = [
|
|
343
343
|
kn('<div class="scale-animation-container"><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span></div>', 1)
|
|
344
|
-
])])) :
|
|
344
|
+
])])) : J("", !0),
|
|
345
345
|
t.msg.segments && t.msg.segments.length ? (v(), m("div", {
|
|
346
346
|
key: 1,
|
|
347
347
|
class: "message-content ba-markdown",
|
|
348
348
|
ref: (S) => t.setMessageRef(S, t.index),
|
|
349
|
-
onClick:
|
|
349
|
+
onClick: D
|
|
350
350
|
}, [
|
|
351
|
-
r.value &&
|
|
351
|
+
r.value && V.value ? (v(), m("div", {
|
|
352
352
|
key: 0,
|
|
353
353
|
class: se(["thought-collapse-bar", { "thought-collapse-bar--expanded": f.value }]),
|
|
354
|
-
onClick:
|
|
354
|
+
onClick: L[0] || (L[0] = fe((S) => f.value = !f.value, ["stop"]))
|
|
355
355
|
}, [
|
|
356
|
-
|
|
356
|
+
p.value ? (v(), pe(O(qn), {
|
|
357
357
|
key: 0,
|
|
358
358
|
class: "thought-collapse-bar__icon"
|
|
359
|
-
})) : (v(), pe(
|
|
359
|
+
})) : (v(), pe(O($t), {
|
|
360
360
|
key: 1,
|
|
361
361
|
class: "thought-collapse-bar__icon"
|
|
362
362
|
})),
|
|
363
|
-
o("span", yo,
|
|
364
|
-
_.value > 0 ? (v(), m("span", wo,
|
|
365
|
-
o("span", ko,
|
|
363
|
+
o("span", yo, z(K.value), 1),
|
|
364
|
+
_.value > 0 ? (v(), m("span", wo, z(n(_.value)), 1)) : J("", !0),
|
|
365
|
+
o("span", ko, z(f.value ? "收起" : "查看"), 1),
|
|
366
366
|
(v(), m("svg", {
|
|
367
367
|
class: se(["thought-collapse-bar__arrow", { "thought-collapse-bar__arrow--down": f.value }]),
|
|
368
368
|
viewBox: "0 0 24 24",
|
|
@@ -373,11 +373,11 @@ const go = {
|
|
|
373
373
|
"stroke-width": "2.5",
|
|
374
374
|
"stroke-linecap": "round",
|
|
375
375
|
"stroke-linejoin": "round"
|
|
376
|
-
}, [
|
|
376
|
+
}, [...L[5] || (L[5] = [
|
|
377
377
|
o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
|
|
378
378
|
])], 2))
|
|
379
|
-
], 2)) :
|
|
380
|
-
|
|
379
|
+
], 2)) : J("", !0),
|
|
380
|
+
G.value ? (v(!0), m(we, { key: 1 }, xe(k.value, (S, q) => (v(), m(we, { key: q }, [
|
|
381
381
|
S.kind === "steps" ? (v(), pe(mo, {
|
|
382
382
|
key: 0,
|
|
383
383
|
steps: S.items
|
|
@@ -391,77 +391,77 @@ const go = {
|
|
|
391
391
|
class: se(["agent-thought", { "agent-thought--done": !S.calling }])
|
|
392
392
|
}, [
|
|
393
393
|
o("span", Co, [
|
|
394
|
-
ie(
|
|
394
|
+
ie(O($t))
|
|
395
395
|
]),
|
|
396
|
-
o("span", _o,
|
|
397
|
-
!S.calling && S.count > 1 ? (v(), m("span", bo, " 已调用 " +
|
|
398
|
-
!S.calling && S.duration > 0 ? (v(), m("span", Ao,
|
|
396
|
+
o("span", _o, z(S.calling ? "工具调用中" : "工具调用"), 1),
|
|
397
|
+
!S.calling && S.count > 1 ? (v(), m("span", bo, " 已调用 " + z(S.count) + " 次 ", 1)) : J("", !0),
|
|
398
|
+
!S.calling && S.duration > 0 ? (v(), m("span", Ao, z(n(S.duration)), 1)) : J("", !0)
|
|
399
399
|
], 2))
|
|
400
|
-
], 64))), 128)) :
|
|
401
|
-
(v(!0), m(
|
|
400
|
+
], 64))), 128)) : J("", !0),
|
|
401
|
+
(v(!0), m(we, null, xe(t.msg.segments, (S, q) => (v(), m(we, { key: q }, [
|
|
402
402
|
S.type === "answer" ? (v(), m("div", So, [
|
|
403
403
|
o("div", {
|
|
404
|
-
innerHTML:
|
|
405
|
-
|
|
406
|
-
!
|
|
404
|
+
innerHTML: O(Xt)(
|
|
405
|
+
O(vt)(O(dt)(O(l)[q] ?? "")),
|
|
406
|
+
!O(s) && O(h) === q && t.msg.status !== t.STATUS.STOP
|
|
407
407
|
)
|
|
408
408
|
}, null, 8, Eo)
|
|
409
|
-
])) :
|
|
409
|
+
])) : J("", !0)
|
|
410
410
|
], 64))), 128))
|
|
411
|
-
], 512)) :
|
|
411
|
+
], 512)) : J("", !0),
|
|
412
412
|
!((ne = t.msg.segments) != null && ne.length) && t.msg.content ? (v(), m("div", {
|
|
413
413
|
key: 2,
|
|
414
414
|
class: "message-content ba-markdown",
|
|
415
415
|
ref: (S) => t.setMessageRef(S, t.index),
|
|
416
|
-
onClick:
|
|
416
|
+
onClick: D
|
|
417
417
|
}, [
|
|
418
418
|
o("div", {
|
|
419
|
-
innerHTML:
|
|
419
|
+
innerHTML: O(vt)(O(dt)(t.msg.content))
|
|
420
420
|
}, null, 8, To)
|
|
421
|
-
], 512)) :
|
|
421
|
+
], 512)) : J("", !0),
|
|
422
422
|
t.msg.errorMessage ? (v(), m("div", xo, [
|
|
423
|
-
|
|
424
|
-
o("span", null,
|
|
425
|
-
])) :
|
|
423
|
+
L[6] || (L[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
|
|
424
|
+
o("span", null, z(t.msg.errorMessage), 1)
|
|
425
|
+
])) : J("", !0),
|
|
426
426
|
r.value ? (v(), m("div", Do, [
|
|
427
427
|
o("div", {
|
|
428
428
|
class: "tooltip-enhanced",
|
|
429
|
-
"data-tooltip":
|
|
429
|
+
"data-tooltip": d.get(t.index) ? "已复制" : "复制回答"
|
|
430
430
|
}, [
|
|
431
|
-
|
|
431
|
+
d.get(t.index) ? (v(), pe(O(zn), {
|
|
432
432
|
key: 0,
|
|
433
433
|
class: "message-toolbar__check"
|
|
434
|
-
})) : (v(), pe(
|
|
434
|
+
})) : (v(), pe(O(Kn), {
|
|
435
435
|
key: 1,
|
|
436
|
-
onClick:
|
|
436
|
+
onClick: L[1] || (L[1] = (S) => W(t.msg, t.index))
|
|
437
437
|
}))
|
|
438
438
|
], 8, Mo),
|
|
439
439
|
o("div", Ro, [
|
|
440
|
-
ie(
|
|
441
|
-
onClick:
|
|
440
|
+
ie(O(Gn), {
|
|
441
|
+
onClick: L[2] || (L[2] = (S) => y.$emit("regenerate"))
|
|
442
442
|
})
|
|
443
443
|
])
|
|
444
|
-
])) :
|
|
445
|
-
], 64)) : (v(), m("div", Ho,
|
|
444
|
+
])) : J("", !0)
|
|
445
|
+
], 64)) : (v(), m("div", Ho, z(t.msg.content), 1)),
|
|
446
446
|
(v(), pe(Yt, { to: "#ai-assist-root" }, [
|
|
447
447
|
C.value ? (v(), m("div", {
|
|
448
448
|
key: 0,
|
|
449
449
|
class: "ai-image-preview-overlay",
|
|
450
|
-
onClick:
|
|
450
|
+
onClick: T
|
|
451
451
|
}, [
|
|
452
452
|
o("img", {
|
|
453
453
|
src: C.value,
|
|
454
454
|
class: "ai-image-preview-overlay__img",
|
|
455
|
-
onClick:
|
|
455
|
+
onClick: L[3] || (L[3] = fe(() => {
|
|
456
456
|
}, ["stop"]))
|
|
457
457
|
}, null, 8, $o),
|
|
458
458
|
o("button", {
|
|
459
459
|
class: "ai-image-preview-overlay__close",
|
|
460
|
-
onClick: fe(
|
|
460
|
+
onClick: fe(T, ["stop"])
|
|
461
461
|
}, [
|
|
462
|
-
ie(
|
|
462
|
+
ie(O(jn))
|
|
463
463
|
])
|
|
464
|
-
])) :
|
|
464
|
+
])) : J("", !0)
|
|
465
465
|
]))
|
|
466
466
|
], 2);
|
|
467
467
|
};
|
|
@@ -481,14 +481,17 @@ const go = {
|
|
|
481
481
|
}, Yo = ["onKeydown"], No = ["data-tooltip"], Vo = {
|
|
482
482
|
key: 2,
|
|
483
483
|
class: "moveTB"
|
|
484
|
-
}, Xo =
|
|
484
|
+
}, Xo = {
|
|
485
|
+
key: 1,
|
|
486
|
+
class: "input-container"
|
|
487
|
+
}, Fo = ["value", "placeholder", "disabled"], Qo = {
|
|
485
488
|
key: 0,
|
|
486
489
|
class: "tooltip-enhanced stop",
|
|
487
490
|
"data-tooltip": "停止生成"
|
|
488
|
-
},
|
|
491
|
+
}, Jo = ["data-tooltip"], qo = {
|
|
489
492
|
key: 3,
|
|
490
493
|
class: "moveTB"
|
|
491
|
-
},
|
|
494
|
+
}, zo = 400, Ko = 10, Go = /* @__PURE__ */ Ee({
|
|
492
495
|
__name: "ChatInput",
|
|
493
496
|
props: {
|
|
494
497
|
modelValue: {},
|
|
@@ -498,196 +501,202 @@ const go = {
|
|
|
498
501
|
},
|
|
499
502
|
emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
|
|
500
503
|
setup(t, { emit: w }) {
|
|
501
|
-
const i = t, u = w, l = g(!1), h = g(""), s = g(""), a = g("idle"), r = g(""), f = g(null), k = g(null),
|
|
502
|
-
let
|
|
503
|
-
const
|
|
504
|
+
const i = t, u = w, l = g(!1), h = g(""), s = g(""), a = g("idle"), r = g(""), f = g(null), k = g(null), V = g(!1), p = g(!1);
|
|
505
|
+
let R = !1, X = null, K = null, G = !1, _ = !1, E = null;
|
|
506
|
+
const te = B(() => a.value === "connecting"), n = B(
|
|
504
507
|
() => a.value === "recording" || a.value === "stopping"
|
|
505
|
-
),
|
|
508
|
+
), d = B(
|
|
506
509
|
() => a.value === "connecting" || a.value === "recording" || a.value === "stopping"
|
|
507
|
-
),
|
|
508
|
-
() =>
|
|
509
|
-
),
|
|
510
|
+
), C = B(() => l.value && !d.value), D = B(
|
|
511
|
+
() => C.value ? !!r.value.trim() : !!(h.value.trim() || s.value.trim())
|
|
512
|
+
), T = B(
|
|
510
513
|
() => Qe.isSupported() && !i.modelValue.trim() && !i.isGenerating
|
|
511
|
-
),
|
|
512
|
-
|
|
514
|
+
), W = g(!1);
|
|
515
|
+
function y(P) {
|
|
516
|
+
P.pointerType === "mouse" && (W.value = !0);
|
|
517
|
+
}
|
|
518
|
+
function L(P) {
|
|
519
|
+
P.pointerType === "mouse" && (W.value = !1);
|
|
520
|
+
}
|
|
521
|
+
const ne = B(() => p.value ? "正在请求麦克风权限…" : W.value && T.value ? "发消息...(按住可语音输入)" : "发消息..."), S = B(
|
|
522
|
+
() => V.value ? "正在聆听…松手结束" : "正在聆听…点击结束"
|
|
513
523
|
);
|
|
514
|
-
function
|
|
515
|
-
|
|
516
|
-
onStatusChange: (
|
|
517
|
-
a.value =
|
|
524
|
+
function q() {
|
|
525
|
+
E = new Qe({}, {
|
|
526
|
+
onStatusChange: (P) => {
|
|
527
|
+
a.value = P;
|
|
518
528
|
},
|
|
519
|
-
onInterim: (
|
|
520
|
-
s.value =
|
|
529
|
+
onInterim: (P) => {
|
|
530
|
+
s.value = P;
|
|
521
531
|
},
|
|
522
|
-
onFinal: (
|
|
523
|
-
h.value +=
|
|
532
|
+
onFinal: (P) => {
|
|
533
|
+
h.value += P, s.value = "";
|
|
524
534
|
},
|
|
525
535
|
onError: () => {
|
|
526
536
|
l.value = !1;
|
|
527
537
|
}
|
|
528
538
|
});
|
|
529
539
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}),
|
|
540
|
+
be(q), Nt(() => {
|
|
541
|
+
x(), E == null || E.destroy(), E = null;
|
|
542
|
+
}), ve([h, s], () => {
|
|
533
543
|
me(() => {
|
|
534
544
|
f.value && (f.value.scrollTop = f.value.scrollHeight);
|
|
535
545
|
});
|
|
536
|
-
}),
|
|
537
|
-
if (
|
|
538
|
-
|
|
546
|
+
}), ve(a, (P) => {
|
|
547
|
+
if (P === "recording" && _) {
|
|
548
|
+
_ = !1, E == null || E.stop();
|
|
539
549
|
return;
|
|
540
550
|
}
|
|
541
|
-
|
|
551
|
+
P === "idle" && l.value && (r.value = (h.value + s.value).trim(), me(() => {
|
|
542
552
|
var Q;
|
|
543
553
|
return (Q = k.value) == null ? void 0 : Q.focus();
|
|
544
554
|
}));
|
|
545
555
|
});
|
|
546
|
-
function
|
|
547
|
-
|
|
556
|
+
function N() {
|
|
557
|
+
d.value && (E == null || E.stop());
|
|
548
558
|
}
|
|
549
|
-
function
|
|
550
|
-
window.removeEventListener("pointerup",
|
|
559
|
+
function b() {
|
|
560
|
+
window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H), window.removeEventListener("pointermove", Y), window.removeEventListener("blur", F);
|
|
551
561
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
562
|
+
function x() {
|
|
563
|
+
X !== null && (clearTimeout(X), X = null), K = null, b();
|
|
554
564
|
}
|
|
555
|
-
function
|
|
556
|
-
a.value === "recording" ?
|
|
565
|
+
function M() {
|
|
566
|
+
a.value === "recording" ? E == null || E.stop() : (a.value === "connecting" || a.value === "stopping") && (_ = !0);
|
|
557
567
|
}
|
|
558
|
-
function
|
|
559
|
-
const
|
|
560
|
-
|
|
568
|
+
function $() {
|
|
569
|
+
const P = G;
|
|
570
|
+
G = !1, x(), P && M();
|
|
561
571
|
}
|
|
562
|
-
function
|
|
563
|
-
if (!
|
|
564
|
-
if (
|
|
565
|
-
|
|
572
|
+
function Y(P) {
|
|
573
|
+
if (!K) return;
|
|
574
|
+
if (G) {
|
|
575
|
+
P.buttons === 0 && $();
|
|
566
576
|
return;
|
|
567
577
|
}
|
|
568
|
-
const Q =
|
|
569
|
-
Math.hypot(Q,
|
|
570
|
-
}
|
|
571
|
-
function
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
function
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
function
|
|
578
|
-
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
const Q =
|
|
582
|
-
Q && typeof Q.blur == "function" && Q.blur(), (
|
|
583
|
-
},
|
|
584
|
-
}
|
|
585
|
-
async function
|
|
586
|
-
if (!
|
|
587
|
-
|
|
588
|
-
const { granted: Q, prompted:
|
|
589
|
-
if (
|
|
578
|
+
const Q = P.clientX - K.x, I = P.clientY - K.y;
|
|
579
|
+
Math.hypot(Q, I) > Ko && x();
|
|
580
|
+
}
|
|
581
|
+
function H() {
|
|
582
|
+
$();
|
|
583
|
+
}
|
|
584
|
+
function F() {
|
|
585
|
+
G && $();
|
|
586
|
+
}
|
|
587
|
+
function oe(P) {
|
|
588
|
+
T.value && (P.pointerType === "mouse" && P.button !== 0 || (K = { x: P.clientX, y: P.clientY }, G = !1, _ = !1, X !== null && clearTimeout(X), X = setTimeout(() => {
|
|
589
|
+
var I, ue, ge;
|
|
590
|
+
X = null, G = !0;
|
|
591
|
+
const Q = P.target;
|
|
592
|
+
Q && typeof Q.blur == "function" && Q.blur(), (ge = (ue = (I = window.getSelection) == null ? void 0 : I.call(window)) == null ? void 0 : ue.removeAllRanges) == null || ge.call(ue), le(!0);
|
|
593
|
+
}, zo), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H), window.addEventListener("pointermove", Y), window.addEventListener("blur", F)));
|
|
594
|
+
}
|
|
595
|
+
async function le(P = !1) {
|
|
596
|
+
if (!E || R) return;
|
|
597
|
+
p.value = !0, R = !0;
|
|
598
|
+
const { granted: Q, prompted: I } = await Qe.ensurePermission();
|
|
599
|
+
if (p.value = !1, R = !1, !Q) {
|
|
590
600
|
Te("麦克风不可用,请允许浏览器使用麦克风后重试");
|
|
591
601
|
return;
|
|
592
602
|
}
|
|
593
|
-
if (
|
|
594
|
-
|
|
603
|
+
if (P && !G) {
|
|
604
|
+
I && Te("麦克风已开启,请重新按住输入框开始说话", "info");
|
|
595
605
|
return;
|
|
596
606
|
}
|
|
597
|
-
|
|
607
|
+
V.value = P, h.value = "", s.value = "", r.value = "", l.value = !0;
|
|
598
608
|
try {
|
|
599
|
-
await
|
|
609
|
+
await E.start();
|
|
600
610
|
} catch {
|
|
601
611
|
l.value = !1;
|
|
602
612
|
}
|
|
603
613
|
}
|
|
604
|
-
function
|
|
605
|
-
|
|
614
|
+
function de() {
|
|
615
|
+
E == null || E.cancel(), l.value = !1, V.value = !1, _ = !1, h.value = "", s.value = "", r.value = "";
|
|
606
616
|
}
|
|
607
|
-
function
|
|
608
|
-
const
|
|
609
|
-
|
|
617
|
+
function ke() {
|
|
618
|
+
const P = (C.value ? r.value : h.value + s.value).trim();
|
|
619
|
+
P && (E == null || E.stop(), l.value = !1, V.value = !1, _ = !1, u("update:modelValue", P), setTimeout(() => u("send"), 0));
|
|
610
620
|
}
|
|
611
|
-
return (
|
|
621
|
+
return (P, Q) => l.value ? (v(), m("div", Po, [
|
|
612
622
|
o("div", {
|
|
613
|
-
class: se(["voice-visual", { recording:
|
|
623
|
+
class: se(["voice-visual", { recording: n.value }])
|
|
614
624
|
}, null, 2),
|
|
615
|
-
|
|
625
|
+
d.value ? (v(), m("div", {
|
|
616
626
|
key: 0,
|
|
617
627
|
class: "voice-text",
|
|
618
628
|
ref_key: "voiceTextEl",
|
|
619
629
|
ref: f,
|
|
620
|
-
onClick:
|
|
630
|
+
onClick: N
|
|
621
631
|
}, [
|
|
622
|
-
h.value ? (v(), m("span", Oo,
|
|
623
|
-
s.value ? (v(), m("span", Bo,
|
|
624
|
-
!h.value && !s.value ? (v(), m("span", Wo,
|
|
632
|
+
h.value ? (v(), m("span", Oo, z(h.value), 1)) : J("", !0),
|
|
633
|
+
s.value ? (v(), m("span", Bo, z(s.value), 1)) : J("", !0),
|
|
634
|
+
!h.value && !s.value ? (v(), m("span", Wo, z(te.value ? "启动中…" : S.value), 1)) : J("", !0)
|
|
625
635
|
], 512)) : Me((v(), m("input", {
|
|
626
636
|
key: 1,
|
|
627
637
|
ref_key: "editorEl",
|
|
628
638
|
ref: k,
|
|
629
|
-
"onUpdate:modelValue": Q[0] || (Q[0] = (
|
|
639
|
+
"onUpdate:modelValue": Q[0] || (Q[0] = (I) => r.value = I),
|
|
630
640
|
type: "text",
|
|
631
641
|
class: "voice-editor",
|
|
632
642
|
placeholder: "识别结果,可点击直接修改…",
|
|
633
|
-
onKeydown: ct(fe(
|
|
634
|
-
onKeyup: Q[1] || (Q[1] = ct((
|
|
643
|
+
onKeydown: ct(fe(de, ["prevent"]), ["esc"]),
|
|
644
|
+
onKeyup: Q[1] || (Q[1] = ct((I) => D.value && ke(), ["enter"]))
|
|
635
645
|
}, null, 40, Yo)), [
|
|
636
646
|
[Vt, r.value]
|
|
637
647
|
]),
|
|
638
648
|
o("div", {
|
|
639
649
|
class: "tooltip-enhanced voice-close",
|
|
640
650
|
"data-tooltip": "关闭",
|
|
641
|
-
onClick:
|
|
651
|
+
onClick: de
|
|
642
652
|
}, [
|
|
643
|
-
ie(
|
|
653
|
+
ie(O(ce), {
|
|
644
654
|
class: "op-icon",
|
|
645
655
|
icon: "heroicons-solid:x-mark"
|
|
646
656
|
})
|
|
647
657
|
]),
|
|
648
658
|
o("div", {
|
|
649
|
-
class: se(["tooltip-enhanced voice-send", { disabled: !
|
|
650
|
-
"data-tooltip":
|
|
651
|
-
onClick: Q[2] || (Q[2] = (
|
|
659
|
+
class: se(["tooltip-enhanced voice-send", { disabled: !D.value }]),
|
|
660
|
+
"data-tooltip": D.value ? "发送" : "未识别到文字",
|
|
661
|
+
onClick: Q[2] || (Q[2] = (I) => D.value && ke())
|
|
652
662
|
}, [
|
|
653
|
-
ie(
|
|
663
|
+
ie(O(ce), {
|
|
654
664
|
class: "op-icon",
|
|
655
665
|
icon: "fluent-color:send-16"
|
|
656
666
|
})
|
|
657
667
|
], 10, No),
|
|
658
668
|
t.hasScroll && !t.isAtBottom ? (v(), m("div", Vo, [
|
|
659
|
-
ie(
|
|
669
|
+
ie(O(ce), {
|
|
660
670
|
class: "op-icon",
|
|
661
671
|
icon: "ep:bottom",
|
|
662
|
-
onClick: Q[3] || (Q[3] = (
|
|
672
|
+
onClick: Q[3] || (Q[3] = (I) => P.$emit("scroll-to-bottom"))
|
|
663
673
|
})
|
|
664
|
-
])) :
|
|
665
|
-
])) : (v(), m("div",
|
|
666
|
-
key: 1,
|
|
667
|
-
class: se(["input-container", { holding: N.value }])
|
|
668
|
-
}, [
|
|
674
|
+
])) : J("", !0)
|
|
675
|
+
])) : (v(), m("div", Xo, [
|
|
669
676
|
o("input", {
|
|
670
677
|
value: t.modelValue,
|
|
671
678
|
type: "text",
|
|
672
|
-
placeholder:
|
|
673
|
-
onInput: Q[4] || (Q[4] = (
|
|
674
|
-
onKeyup: Q[5] || (Q[5] = ct((
|
|
679
|
+
placeholder: ne.value,
|
|
680
|
+
onInput: Q[4] || (Q[4] = (I) => P.$emit("update:modelValue", I.target.value)),
|
|
681
|
+
onKeyup: Q[5] || (Q[5] = ct((I) => t.modelValue.trim() && P.$emit("send"), ["enter"])),
|
|
675
682
|
disabled: t.isGenerating,
|
|
676
|
-
onPointerdown:
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
683
|
+
onPointerdown: oe,
|
|
684
|
+
onPointerenter: y,
|
|
685
|
+
onPointerleave: L
|
|
686
|
+
}, null, 40, Fo),
|
|
687
|
+
t.isGenerating ? (v(), m("div", Qo, [
|
|
688
|
+
ie(O(ce), {
|
|
680
689
|
class: "op-icon stop-icon",
|
|
681
690
|
icon: "heroicons-solid:stop",
|
|
682
|
-
onClick: Q[6] || (Q[6] = (
|
|
691
|
+
onClick: Q[6] || (Q[6] = (I) => P.$emit("stop"))
|
|
683
692
|
})
|
|
684
|
-
])) :
|
|
693
|
+
])) : T.value ? (v(), m("div", {
|
|
685
694
|
key: 1,
|
|
686
695
|
class: "tooltip-enhanced send voice",
|
|
687
696
|
"data-tooltip": "语音输入(也可按住输入框说话)",
|
|
688
|
-
onClick: Q[7] || (Q[7] = (
|
|
697
|
+
onClick: Q[7] || (Q[7] = (I) => le())
|
|
689
698
|
}, [
|
|
690
|
-
ie(
|
|
699
|
+
ie(O(ce), {
|
|
691
700
|
class: "op-icon",
|
|
692
701
|
icon: "mingcute:voice-line"
|
|
693
702
|
})
|
|
@@ -696,23 +705,23 @@ const go = {
|
|
|
696
705
|
class: se(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
|
|
697
706
|
"data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
|
|
698
707
|
}, [
|
|
699
|
-
ie(
|
|
708
|
+
ie(O(ce), {
|
|
700
709
|
class: "op-icon",
|
|
701
710
|
icon: "fluent-color:send-16",
|
|
702
|
-
onClick: Q[8] || (Q[8] = (
|
|
711
|
+
onClick: Q[8] || (Q[8] = (I) => t.modelValue.trim() && P.$emit("send"))
|
|
703
712
|
})
|
|
704
|
-
], 10,
|
|
705
|
-
t.hasScroll && !t.isAtBottom ? (v(), m("div",
|
|
706
|
-
ie(
|
|
713
|
+
], 10, Jo)),
|
|
714
|
+
t.hasScroll && !t.isAtBottom ? (v(), m("div", qo, [
|
|
715
|
+
ie(O(ce), {
|
|
707
716
|
class: "op-icon",
|
|
708
717
|
icon: "ep:bottom",
|
|
709
|
-
onClick: Q[9] || (Q[9] = (
|
|
718
|
+
onClick: Q[9] || (Q[9] = (I) => P.$emit("scroll-to-bottom"))
|
|
710
719
|
})
|
|
711
|
-
])) :
|
|
712
|
-
]
|
|
720
|
+
])) : J("", !0)
|
|
721
|
+
]));
|
|
713
722
|
}
|
|
714
723
|
});
|
|
715
|
-
function
|
|
724
|
+
function jo(t) {
|
|
716
725
|
const w = g(!0), i = g(!1);
|
|
717
726
|
function u(s) {
|
|
718
727
|
const a = s.closest(".chat-wrap") || s, r = s.scrollHeight, f = s.clientHeight;
|
|
@@ -720,8 +729,8 @@ function Go(t) {
|
|
|
720
729
|
a.style.setProperty("--ai-thumb-height", "0px"), a.style.setProperty("--ai-thumb-top", "0px");
|
|
721
730
|
return;
|
|
722
731
|
}
|
|
723
|
-
const k = Math.max(f * f / r, 32),
|
|
724
|
-
a.style.setProperty("--ai-thumb-height", `${k}px`), a.style.setProperty("--ai-thumb-top", `${
|
|
732
|
+
const k = Math.max(f * f / r, 32), V = f - k, p = s.scrollTop / (r - f);
|
|
733
|
+
a.style.setProperty("--ai-thumb-height", `${k}px`), a.style.setProperty("--ai-thumb-top", `${p * V}px`);
|
|
725
734
|
}
|
|
726
735
|
function l() {
|
|
727
736
|
me(() => {
|
|
@@ -735,7 +744,7 @@ function Go(t) {
|
|
|
735
744
|
}
|
|
736
745
|
return { isAtBottom: w, hasScroll: i, scrollToBottom: l, checkScrollStatus: h };
|
|
737
746
|
}
|
|
738
|
-
function
|
|
747
|
+
function Uo() {
|
|
739
748
|
function t(w) {
|
|
740
749
|
w.querySelectorAll("pre").forEach((u) => {
|
|
741
750
|
if (u.querySelector(".copy-button")) return;
|
|
@@ -758,7 +767,7 @@ function jo() {
|
|
|
758
767
|
}
|
|
759
768
|
return { enhanceCodeBlocks: t };
|
|
760
769
|
}
|
|
761
|
-
function
|
|
770
|
+
function Zo(t) {
|
|
762
771
|
let w = null, i = 0;
|
|
763
772
|
function u(h) {
|
|
764
773
|
w = h(w || [...t.value]), i || (i = requestAnimationFrame(() => {
|
|
@@ -770,7 +779,7 @@ function Uo(t) {
|
|
|
770
779
|
}
|
|
771
780
|
return { batchMessagesUpdate: u, flushMessagesBatch: l };
|
|
772
781
|
}
|
|
773
|
-
function
|
|
782
|
+
function Io({
|
|
774
783
|
messages: t,
|
|
775
784
|
isGenerating: w,
|
|
776
785
|
lastUserMessage: i,
|
|
@@ -779,73 +788,73 @@ function Zo({
|
|
|
779
788
|
STATUS: h,
|
|
780
789
|
cfg: s
|
|
781
790
|
}) {
|
|
782
|
-
const a = g(/* @__PURE__ */ new Map()), r = g(/* @__PURE__ */ new Map()), f = g(/* @__PURE__ */ new Map()), k = g(/* @__PURE__ */ new Map()),
|
|
783
|
-
function K(
|
|
784
|
-
const
|
|
791
|
+
const a = g(/* @__PURE__ */ new Map()), r = g(/* @__PURE__ */ new Map()), f = g(/* @__PURE__ */ new Map()), k = g(/* @__PURE__ */ new Map()), V = g(!1), p = g(/* @__PURE__ */ new Map()), R = g(/* @__PURE__ */ new Map()), X = g(!1);
|
|
792
|
+
function K(E) {
|
|
793
|
+
const te = a.value.get(E) || [];
|
|
785
794
|
u((n) => {
|
|
786
|
-
if (n[
|
|
787
|
-
const
|
|
788
|
-
return
|
|
795
|
+
if (n[E]) {
|
|
796
|
+
const d = [...n];
|
|
797
|
+
return d[E] = { ...d[E], segments: te.map((C) => ({ ...C })) }, d;
|
|
789
798
|
}
|
|
790
799
|
return n;
|
|
791
800
|
});
|
|
792
801
|
}
|
|
793
|
-
function
|
|
794
|
-
const
|
|
795
|
-
let C = 0,
|
|
796
|
-
|
|
797
|
-
if ((
|
|
798
|
-
const y = (
|
|
799
|
-
|
|
802
|
+
function G(E) {
|
|
803
|
+
const te = a.value.get(E) || [], n = f.value.get(E), d = R.value.get(E);
|
|
804
|
+
let C = 0, D = !1;
|
|
805
|
+
te.forEach((T) => {
|
|
806
|
+
if ((T.type === "thinking" || T.type === "step") && T.duration == null) {
|
|
807
|
+
const y = (T.id != null ? d == null ? void 0 : d.get(T.id) : void 0) ?? n, L = y ? Math.round((Date.now() - y) / 1e3 * 10) / 10 : 0;
|
|
808
|
+
T.duration = L, T.type === "thinking" && (C += L), D = !0;
|
|
800
809
|
}
|
|
801
|
-
}),
|
|
802
|
-
if (E
|
|
803
|
-
const W = [...
|
|
804
|
-
return W[
|
|
805
|
-
...W[
|
|
806
|
-
segments:
|
|
807
|
-
thinkingDuration: (W[
|
|
810
|
+
}), D && (a.value.set(E, te), u((T) => {
|
|
811
|
+
if (T[E]) {
|
|
812
|
+
const W = [...T];
|
|
813
|
+
return W[E] = {
|
|
814
|
+
...W[E],
|
|
815
|
+
segments: te.map((y) => ({ ...y })),
|
|
816
|
+
thinkingDuration: (W[E].thinkingDuration || 0) + C
|
|
808
817
|
}, W;
|
|
809
818
|
}
|
|
810
|
-
return
|
|
819
|
+
return T;
|
|
811
820
|
}));
|
|
812
821
|
}
|
|
813
|
-
async function _(
|
|
814
|
-
|
|
822
|
+
async function _(E, te, n, d, C = !1) {
|
|
823
|
+
X.value = !1, V.value = !1, a.value.set(n, []), p.value.set(n, /* @__PURE__ */ new Map()), R.value.set(n, /* @__PURE__ */ new Map()), w.value = !0;
|
|
815
824
|
try {
|
|
816
|
-
const
|
|
817
|
-
await Xn(
|
|
825
|
+
const D = s.baseUrl.replace(/\/+$/, "") + "/" + E.replace(/^\/+/, "");
|
|
826
|
+
await Xn(D, {
|
|
818
827
|
method: "POST",
|
|
819
828
|
headers: {
|
|
820
829
|
"Content-Type": "application/json",
|
|
821
830
|
Authorization: `Bearer ${s.token}`
|
|
822
831
|
},
|
|
823
|
-
body: JSON.stringify({ app: s.app ?? 1, data:
|
|
824
|
-
signal:
|
|
832
|
+
body: JSON.stringify({ app: s.app ?? 1, data: te }),
|
|
833
|
+
signal: d,
|
|
825
834
|
openWhenHidden: !0,
|
|
826
|
-
async onopen(
|
|
827
|
-
|
|
835
|
+
async onopen(T) {
|
|
836
|
+
T.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", T.status, T.statusText);
|
|
828
837
|
},
|
|
829
|
-
onmessage(
|
|
830
|
-
var W, y,
|
|
838
|
+
onmessage(T) {
|
|
839
|
+
var W, y, L, ne, S;
|
|
831
840
|
try {
|
|
832
|
-
let
|
|
833
|
-
for (;
|
|
834
|
-
|
|
835
|
-
if (!
|
|
836
|
-
let
|
|
841
|
+
let q = T.data || "";
|
|
842
|
+
for (; q.startsWith("data:"); )
|
|
843
|
+
q = q.replace(/^data:\s*/, "");
|
|
844
|
+
if (!q) return;
|
|
845
|
+
let N;
|
|
837
846
|
try {
|
|
838
|
-
|
|
847
|
+
N = JSON.parse(q);
|
|
839
848
|
} catch {
|
|
840
849
|
return;
|
|
841
850
|
}
|
|
842
|
-
switch (
|
|
851
|
+
switch (N.event) {
|
|
843
852
|
case "message_start":
|
|
844
|
-
C || (i.value =
|
|
853
|
+
C || (i.value = N.id), r.value.set(n, "answer");
|
|
845
854
|
break;
|
|
846
855
|
// ── 对话流型智能体:流程开始,标记进入 flow 协议 ──
|
|
847
856
|
case "flow_start":
|
|
848
|
-
|
|
857
|
+
V.value = !0;
|
|
849
858
|
break;
|
|
850
859
|
case "think_message_output_start": {
|
|
851
860
|
f.value.set(n, Date.now()), r.value.set(n, "thinking");
|
|
@@ -854,46 +863,46 @@ function Zo({
|
|
|
854
863
|
break;
|
|
855
864
|
}
|
|
856
865
|
case "agent_thought": {
|
|
857
|
-
const b =
|
|
858
|
-
|
|
859
|
-
if (
|
|
860
|
-
const Y = [
|
|
866
|
+
const b = N.thought || N.thinking || "", x = a.value.get(n) || [], M = x[x.length - 1];
|
|
867
|
+
M && M.type === "agent_thought" && M.duration == null ? M.content += b : (r.value.set(n, "agent_thought"), x.push({ type: "agent_thought", content: b }), k.value.set(n, Date.now())), a.value.set(n, x), u(($) => {
|
|
868
|
+
if ($[n]) {
|
|
869
|
+
const Y = [...$];
|
|
861
870
|
return Y[n] = {
|
|
862
871
|
...Y[n],
|
|
863
|
-
segments:
|
|
872
|
+
segments: x.map((H) => ({ ...H })),
|
|
864
873
|
thinkingContent: (Y[n].thinkingContent || "") + b,
|
|
865
874
|
status: h.THINKING
|
|
866
875
|
}, Y;
|
|
867
876
|
}
|
|
868
|
-
return
|
|
877
|
+
return $;
|
|
869
878
|
});
|
|
870
879
|
break;
|
|
871
880
|
}
|
|
872
881
|
case "think_message": {
|
|
873
|
-
const b =
|
|
874
|
-
|
|
875
|
-
if (
|
|
876
|
-
const Y = [
|
|
882
|
+
const b = N.thinking || N.answer || N.text || "", x = a.value.get(n) || [], M = x[x.length - 1];
|
|
883
|
+
M && M.type === "thinking" ? M.content += b : (x.push({ type: "thinking", content: b }), f.value.set(n, Date.now())), a.value.set(n, x), u(($) => {
|
|
884
|
+
if ($[n]) {
|
|
885
|
+
const Y = [...$];
|
|
877
886
|
return Y[n] = {
|
|
878
887
|
...Y[n],
|
|
879
|
-
segments:
|
|
888
|
+
segments: x.map((H) => ({ ...H })),
|
|
880
889
|
thinkingContent: (Y[n].thinkingContent || "") + b,
|
|
881
890
|
status: h.THINKING
|
|
882
891
|
}, Y;
|
|
883
892
|
}
|
|
884
|
-
return
|
|
893
|
+
return $;
|
|
885
894
|
});
|
|
886
895
|
break;
|
|
887
896
|
}
|
|
888
897
|
case "agent_thought_end": {
|
|
889
|
-
const b = k.value.get(n),
|
|
890
|
-
|
|
898
|
+
const b = k.value.get(n), x = b ? Math.round((Date.now() - b) / 1e3 * 10) / 10 : 0, M = a.value.get(n) || [], $ = M[M.length - 1];
|
|
899
|
+
$ && $.type === "agent_thought" && ($.duration = x), a.value.set(n, M), u((Y) => {
|
|
891
900
|
if (Y[n]) {
|
|
892
901
|
const H = [...Y];
|
|
893
902
|
return H[n] = {
|
|
894
903
|
...H[n],
|
|
895
|
-
segments:
|
|
896
|
-
thinkingDuration: (H[n].thinkingDuration || 0) +
|
|
904
|
+
segments: M.map((F) => ({ ...F })),
|
|
905
|
+
thinkingDuration: (H[n].thinkingDuration || 0) + x
|
|
897
906
|
}, H;
|
|
898
907
|
}
|
|
899
908
|
return Y;
|
|
@@ -901,14 +910,14 @@ function Zo({
|
|
|
901
910
|
break;
|
|
902
911
|
}
|
|
903
912
|
case "think_message_output_end": {
|
|
904
|
-
const b = f.value.get(n),
|
|
905
|
-
|
|
913
|
+
const b = f.value.get(n), x = b ? Math.round((Date.now() - b) / 1e3 * 10) / 10 : 0, M = a.value.get(n) || [], $ = M[M.length - 1];
|
|
914
|
+
$ && $.type === "thinking" && ($.duration = x), a.value.set(n, M), u((Y) => {
|
|
906
915
|
if (Y[n]) {
|
|
907
916
|
const H = [...Y];
|
|
908
917
|
return H[n] = {
|
|
909
918
|
...H[n],
|
|
910
|
-
segments:
|
|
911
|
-
thinkingDuration: (H[n].thinkingDuration || 0) +
|
|
919
|
+
segments: M.map((F) => ({ ...F })),
|
|
920
|
+
thinkingDuration: (H[n].thinkingDuration || 0) + x
|
|
912
921
|
}, H;
|
|
913
922
|
}
|
|
914
923
|
return Y;
|
|
@@ -919,54 +928,54 @@ function Zo({
|
|
|
919
928
|
// message_config.reasoning === true 的步骤(如「正在思考」)归入深度思考,
|
|
920
929
|
// 其余(執行準備/資料獲取/...)归入流程步骤。
|
|
921
930
|
case "tool_message_output_start": {
|
|
922
|
-
|
|
923
|
-
const b = ((W =
|
|
924
|
-
|
|
931
|
+
V.value = !0;
|
|
932
|
+
const b = ((W = N.message_config) == null ? void 0 : W.reasoning) === !0 || N.reasoning === !0, x = Date.now(), M = a.value.get(n) || [];
|
|
933
|
+
M.push({
|
|
925
934
|
type: b ? "thinking" : "step",
|
|
926
|
-
title:
|
|
927
|
-
id:
|
|
935
|
+
title: N.message_title || "",
|
|
936
|
+
id: N.id,
|
|
928
937
|
content: "",
|
|
929
938
|
reasoning: b
|
|
930
939
|
});
|
|
931
|
-
const
|
|
932
|
-
if (a.value.set(n,
|
|
933
|
-
const Y =
|
|
934
|
-
Y.set(String(
|
|
935
|
-
const H =
|
|
936
|
-
H.set(String(
|
|
940
|
+
const $ = M.length - 1;
|
|
941
|
+
if (a.value.set(n, M), r.value.set(n, b ? "thinking" : "step"), N.id != null) {
|
|
942
|
+
const Y = p.value.get(n) || /* @__PURE__ */ new Map();
|
|
943
|
+
Y.set(String(N.id), $), p.value.set(n, Y);
|
|
944
|
+
const H = R.value.get(n) || /* @__PURE__ */ new Map();
|
|
945
|
+
H.set(String(N.id), x), R.value.set(n, H);
|
|
937
946
|
}
|
|
938
|
-
b && f.value.set(n,
|
|
947
|
+
b && f.value.set(n, x), K(n);
|
|
939
948
|
break;
|
|
940
949
|
}
|
|
941
950
|
case "tool_message": {
|
|
942
|
-
const b =
|
|
951
|
+
const b = N.answer || N.text || N.content || "";
|
|
943
952
|
if (!b) break;
|
|
944
|
-
const
|
|
945
|
-
if (
|
|
946
|
-
const
|
|
947
|
-
let Y =
|
|
948
|
-
if (Y == null || !
|
|
949
|
-
const H = ((y =
|
|
950
|
-
if (
|
|
953
|
+
const x = a.value.get(n) || [];
|
|
954
|
+
if (V.value) {
|
|
955
|
+
const M = N.id != null ? String(N.id) : null, $ = p.value.get(n);
|
|
956
|
+
let Y = M != null ? $ == null ? void 0 : $.get(M) : void 0;
|
|
957
|
+
if (Y == null || !x[Y]) {
|
|
958
|
+
const H = ((y = N.message_config) == null ? void 0 : y.reasoning) === !0 || N.reasoning === !0;
|
|
959
|
+
if (x.push({
|
|
951
960
|
type: H ? "thinking" : "step",
|
|
952
|
-
title:
|
|
953
|
-
id:
|
|
961
|
+
title: N.message_title || "",
|
|
962
|
+
id: N.id,
|
|
954
963
|
content: b,
|
|
955
964
|
reasoning: H
|
|
956
|
-
}), Y =
|
|
957
|
-
const F =
|
|
958
|
-
F.set(
|
|
965
|
+
}), Y = x.length - 1, M != null) {
|
|
966
|
+
const F = $ || /* @__PURE__ */ new Map();
|
|
967
|
+
F.set(M, Y), p.value.set(n, F), H && f.value.set(n, Date.now());
|
|
959
968
|
}
|
|
960
969
|
} else {
|
|
961
|
-
const H =
|
|
962
|
-
|
|
970
|
+
const H = x[Y];
|
|
971
|
+
x[Y] = { ...H, content: H.content + b };
|
|
963
972
|
}
|
|
964
|
-
a.value.set(n,
|
|
973
|
+
a.value.set(n, x), u((H) => {
|
|
965
974
|
if (H[n]) {
|
|
966
975
|
const F = [...H];
|
|
967
976
|
return F[n] = {
|
|
968
977
|
...F[n],
|
|
969
|
-
segments:
|
|
978
|
+
segments: x.map((oe) => ({ ...oe })),
|
|
970
979
|
status: h.THINKING
|
|
971
980
|
}, F;
|
|
972
981
|
}
|
|
@@ -974,23 +983,23 @@ function Zo({
|
|
|
974
983
|
});
|
|
975
984
|
break;
|
|
976
985
|
}
|
|
977
|
-
|
|
986
|
+
x.push({ type: "answer", content: b }), a.value.set(n, x), K(n);
|
|
978
987
|
break;
|
|
979
988
|
}
|
|
980
989
|
// ── 对话流型智能体:步骤/推理消息结束,记录该步骤耗时 ──
|
|
981
990
|
case "tool_message_output_end": {
|
|
982
|
-
const b = a.value.get(n) || [],
|
|
983
|
-
let
|
|
984
|
-
(
|
|
985
|
-
const
|
|
991
|
+
const b = a.value.get(n) || [], x = N.id != null ? String(N.id) : null;
|
|
992
|
+
let M = x != null ? (L = p.value.get(n)) == null ? void 0 : L.get(x) : b.length - 1;
|
|
993
|
+
(M == null || !b[M]) && (M = b.length - 1);
|
|
994
|
+
const $ = (x != null ? (ne = R.value.get(n)) == null ? void 0 : ne.get(x) : void 0) ?? f.value.get(n), Y = $ ? Math.round((Date.now() - $) / 1e3 * 10) / 10 : 0;
|
|
986
995
|
let H = 0;
|
|
987
|
-
const F = b[
|
|
988
|
-
F && F.duration == null && (b[
|
|
996
|
+
const F = b[M];
|
|
997
|
+
F && F.duration == null && (b[M] = { ...F, duration: Y }, F.type === "thinking" && (H = Y)), a.value.set(n, b), u((oe) => {
|
|
989
998
|
if (oe[n]) {
|
|
990
999
|
const le = [...oe];
|
|
991
1000
|
return le[n] = {
|
|
992
1001
|
...le[n],
|
|
993
|
-
segments: b.map((
|
|
1002
|
+
segments: b.map((de) => ({ ...de })),
|
|
994
1003
|
...H ? { thinkingDuration: (le[n].thinkingDuration || 0) + H } : {}
|
|
995
1004
|
}, le;
|
|
996
1005
|
}
|
|
@@ -999,24 +1008,24 @@ function Zo({
|
|
|
999
1008
|
break;
|
|
1000
1009
|
}
|
|
1001
1010
|
case "message_output_start":
|
|
1002
|
-
r.value.set(n, "answer"),
|
|
1011
|
+
r.value.set(n, "answer"), G(n);
|
|
1003
1012
|
break;
|
|
1004
1013
|
// 对话流型智能体:回答输出结束 / 流程结束(状态统一由 message_end 收尾)
|
|
1005
1014
|
case "message_output_end":
|
|
1006
1015
|
case "flow_end":
|
|
1007
1016
|
break;
|
|
1008
1017
|
case "message": {
|
|
1009
|
-
const b =
|
|
1010
|
-
|
|
1011
|
-
const Y =
|
|
1018
|
+
const b = N.answer || "", x = r.value.get(n), M = a.value.get(n) || [], $ = M[M.length - 1];
|
|
1019
|
+
x === "answer" && $ && $.type === "answer" ? $.content += b : (G(n), r.value.set(n, "answer"), M.push({ type: "answer", content: b })), a.value.set(n, M);
|
|
1020
|
+
const Y = M.filter((H) => H.type === "answer").map((H) => H.content).join("");
|
|
1012
1021
|
u((H) => {
|
|
1013
1022
|
if (H[n]) {
|
|
1014
1023
|
const F = [...H];
|
|
1015
1024
|
return F[n] = {
|
|
1016
1025
|
...F[n],
|
|
1017
|
-
segments:
|
|
1026
|
+
segments: M.map((oe) => ({ ...oe })),
|
|
1018
1027
|
content: Y,
|
|
1019
|
-
status:
|
|
1028
|
+
status: X.value ? h.STOP : h.ANSWERING
|
|
1020
1029
|
}, F;
|
|
1021
1030
|
}
|
|
1022
1031
|
return H;
|
|
@@ -1026,7 +1035,7 @@ function Zo({
|
|
|
1026
1035
|
case "message_end": {
|
|
1027
1036
|
l();
|
|
1028
1037
|
const b = [...t.value];
|
|
1029
|
-
b[n] && (b[n] = { ...b[n], status:
|
|
1038
|
+
b[n] && (b[n] = { ...b[n], status: X.value ? h.STOP : h.COMPLETED }), t.value = b, w.value = !1;
|
|
1030
1039
|
break;
|
|
1031
1040
|
}
|
|
1032
1041
|
case "agent_error":
|
|
@@ -1036,73 +1045,73 @@ function Zo({
|
|
|
1036
1045
|
b[n] && (b[n] = {
|
|
1037
1046
|
...b[n],
|
|
1038
1047
|
status: h.ERROR,
|
|
1039
|
-
content:
|
|
1040
|
-
errorMessage:
|
|
1048
|
+
content: N.error_msg || N.message || "请求失败",
|
|
1049
|
+
errorMessage: N.error_msg || N.message || "请求失败"
|
|
1041
1050
|
}, t.value = b), w.value = !1;
|
|
1042
1051
|
break;
|
|
1043
1052
|
}
|
|
1044
1053
|
case "message_replace": {
|
|
1045
|
-
const b =
|
|
1046
|
-
|
|
1047
|
-
if (
|
|
1048
|
-
const Y = [
|
|
1054
|
+
const b = N.answer || "", x = a.value.get(n) || [], M = (S = x.map(($, Y) => ({ s: $, i: Y })).reverse().find(($) => $.s.type === "answer")) == null ? void 0 : S.i;
|
|
1055
|
+
M != null ? x[M] = { ...x[M], content: b } : x.push({ type: "answer", content: b }), a.value.set(n, x), u(($) => {
|
|
1056
|
+
if ($[n]) {
|
|
1057
|
+
const Y = [...$];
|
|
1049
1058
|
return Y[n] = {
|
|
1050
1059
|
...Y[n],
|
|
1051
|
-
segments:
|
|
1060
|
+
segments: x.map((H) => ({ ...H })),
|
|
1052
1061
|
content: b
|
|
1053
1062
|
}, Y;
|
|
1054
1063
|
}
|
|
1055
|
-
return
|
|
1064
|
+
return $;
|
|
1056
1065
|
});
|
|
1057
1066
|
break;
|
|
1058
1067
|
}
|
|
1059
1068
|
case "message_cost": {
|
|
1060
1069
|
const b = {
|
|
1061
|
-
inputTokens:
|
|
1062
|
-
outputTokens:
|
|
1063
|
-
latency:
|
|
1064
|
-
latencyFirstResp:
|
|
1070
|
+
inputTokens: N.input_tokens || 0,
|
|
1071
|
+
outputTokens: N.output_tokens || 0,
|
|
1072
|
+
latency: N.latency || 0,
|
|
1073
|
+
latencyFirstResp: N.latency_first_resp
|
|
1065
1074
|
};
|
|
1066
|
-
u((
|
|
1067
|
-
if (
|
|
1068
|
-
const
|
|
1069
|
-
return
|
|
1075
|
+
u((x) => {
|
|
1076
|
+
if (x[n]) {
|
|
1077
|
+
const M = [...x];
|
|
1078
|
+
return M[n] = { ...M[n], cost: b }, M;
|
|
1070
1079
|
}
|
|
1071
|
-
return
|
|
1080
|
+
return x;
|
|
1072
1081
|
});
|
|
1073
1082
|
break;
|
|
1074
1083
|
}
|
|
1075
1084
|
default:
|
|
1076
1085
|
}
|
|
1077
|
-
} catch (
|
|
1078
|
-
console.error("[ai-assist-sdk] onmessage 解析失败:",
|
|
1086
|
+
} catch (q) {
|
|
1087
|
+
console.error("[ai-assist-sdk] onmessage 解析失败:", q);
|
|
1079
1088
|
}
|
|
1080
1089
|
},
|
|
1081
1090
|
onclose() {
|
|
1082
|
-
l(),
|
|
1083
|
-
const W = (a.value.get(n) || []).filter((
|
|
1091
|
+
l(), G(n), l();
|
|
1092
|
+
const W = (a.value.get(n) || []).filter((L) => L.type === "answer").map((L) => L.content).join(""), y = [...t.value];
|
|
1084
1093
|
y[n] && y[n].status !== h.ERROR && (y[n] = {
|
|
1085
1094
|
...y[n],
|
|
1086
|
-
content:
|
|
1087
|
-
status:
|
|
1095
|
+
content: X.value && !W ? "已停止回答" : W,
|
|
1096
|
+
status: X.value ? h.STOP : h.COMPLETED
|
|
1088
1097
|
}), t.value = y, w.value = !1;
|
|
1089
1098
|
},
|
|
1090
|
-
onerror(
|
|
1091
|
-
console.error("[ai-assist-sdk] ❌ 连接错误:",
|
|
1099
|
+
onerror(T) {
|
|
1100
|
+
console.error("[ai-assist-sdk] ❌ 连接错误:", T), l();
|
|
1092
1101
|
const W = [...t.value];
|
|
1093
1102
|
W[n] && (W[n] = { ...W[n], content: `
|
|
1094
1103
|
⚠️ 请求异常,已终止`, status: h.ERROR }), t.value = W, w.value = !1;
|
|
1095
1104
|
}
|
|
1096
1105
|
});
|
|
1097
|
-
} catch (
|
|
1098
|
-
if (console.error("[ai-assist-sdk] doStreamRequest error:",
|
|
1106
|
+
} catch (D) {
|
|
1107
|
+
if (console.error("[ai-assist-sdk] doStreamRequest error:", D), !X.value) {
|
|
1099
1108
|
l();
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1109
|
+
const T = [...t.value];
|
|
1110
|
+
T[n] && (T[n] = { ...T[n], content: "服务连接失败,请稍后重试", status: h.ERROR }), t.value = T, w.value = !1;
|
|
1102
1111
|
}
|
|
1103
1112
|
}
|
|
1104
1113
|
}
|
|
1105
|
-
return { doStreamRequest: _, issTop:
|
|
1114
|
+
return { doStreamRequest: _, issTop: X };
|
|
1106
1115
|
}
|
|
1107
1116
|
function Lt(t) {
|
|
1108
1117
|
var w;
|
|
@@ -1123,10 +1132,10 @@ function Lt(t) {
|
|
|
1123
1132
|
}
|
|
1124
1133
|
return (t == null ? void 0 : t.answer) || ((w = t == null ? void 0 : t.data) == null ? void 0 : w.answer) || String(t || "");
|
|
1125
1134
|
}
|
|
1126
|
-
function
|
|
1135
|
+
function es(t) {
|
|
1127
1136
|
return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
|
|
1128
1137
|
}
|
|
1129
|
-
function
|
|
1138
|
+
function ts({
|
|
1130
1139
|
messages: t,
|
|
1131
1140
|
userInput: w,
|
|
1132
1141
|
isGenerating: i,
|
|
@@ -1139,136 +1148,136 @@ function es({
|
|
|
1139
1148
|
cfg: f,
|
|
1140
1149
|
onTitleGenerated: k
|
|
1141
1150
|
}) {
|
|
1142
|
-
const
|
|
1151
|
+
const V = f.apis, p = ye({
|
|
1143
1152
|
first: new AbortController(),
|
|
1144
1153
|
again: new AbortController()
|
|
1145
|
-
}),
|
|
1146
|
-
async function
|
|
1147
|
-
var
|
|
1148
|
-
if (!f.titleGenerateApp || !
|
|
1149
|
-
let
|
|
1150
|
-
if (!
|
|
1154
|
+
}), R = g(!1);
|
|
1155
|
+
async function X(d, C) {
|
|
1156
|
+
var T;
|
|
1157
|
+
if (!f.titleGenerateApp || !V.updateConversationApi || R.value) return;
|
|
1158
|
+
let D = l.value;
|
|
1159
|
+
if (!D)
|
|
1151
1160
|
try {
|
|
1152
|
-
const W = await Mt(
|
|
1153
|
-
(
|
|
1161
|
+
const W = await Mt(V);
|
|
1162
|
+
(T = W == null ? void 0 : W.conversation) != null && T.appConversationID && (D = W.conversation.appConversationID, l.value = D);
|
|
1154
1163
|
} catch (W) {
|
|
1155
1164
|
console.error("[ai-assist-sdk] 创建会话失败:", W);
|
|
1156
1165
|
return;
|
|
1157
1166
|
}
|
|
1158
|
-
if (
|
|
1167
|
+
if (D)
|
|
1159
1168
|
try {
|
|
1160
|
-
const W = await En(
|
|
1169
|
+
const W = await En(V, f.titleGenerateApp);
|
|
1161
1170
|
if (!W) return;
|
|
1162
|
-
const y = C.length > 500 ? C.slice(0, 500) : C,
|
|
1163
|
-
AI回答:${y}`, S = await Rt().post(
|
|
1171
|
+
const y = C.length > 500 ? C.slice(0, 500) : C, L = `用户提问:${d}
|
|
1172
|
+
AI回答:${y}`, S = await Rt().post(V.chatQueryApi, {
|
|
1164
1173
|
app: f.titleGenerateApp,
|
|
1165
|
-
data: { Query:
|
|
1166
|
-
}),
|
|
1167
|
-
|
|
1174
|
+
data: { Query: L, AppConversationID: W }
|
|
1175
|
+
}), q = Lt(S.data.data);
|
|
1176
|
+
q && (await Tn(V, D, q), R.value = !0, k == null || k(q));
|
|
1168
1177
|
} catch (W) {
|
|
1169
1178
|
console.error("[ai-assist-sdk] 生成对话标题失败:", W);
|
|
1170
1179
|
}
|
|
1171
1180
|
}
|
|
1172
1181
|
async function K() {
|
|
1173
1182
|
var W;
|
|
1174
|
-
const
|
|
1175
|
-
if (!
|
|
1176
|
-
if (!l.value && (await
|
|
1183
|
+
const d = w.value.trim();
|
|
1184
|
+
if (!d || i.value) return;
|
|
1185
|
+
if (!l.value && (await te(), !l.value)) {
|
|
1177
1186
|
Te("创建会话失败,请重试");
|
|
1178
1187
|
return;
|
|
1179
1188
|
}
|
|
1180
1189
|
const C = t.value.length === 0;
|
|
1181
1190
|
try {
|
|
1182
|
-
(W = f.onMessageSend) == null || W.call(f, { text:
|
|
1191
|
+
(W = f.onMessageSend) == null || W.call(f, { text: d, isFirstMessage: C, conversationId: l.value });
|
|
1183
1192
|
} catch {
|
|
1184
1193
|
}
|
|
1185
|
-
const
|
|
1194
|
+
const D = [
|
|
1186
1195
|
...t.value,
|
|
1187
|
-
{ type: "user", content:
|
|
1196
|
+
{ type: "user", content: d },
|
|
1188
1197
|
// streamed:标记该条由实时流产生,前端按序逐字揭示(后端批量转发,终态可能早于渲染)
|
|
1189
1198
|
{ type: "ai", content: "", status: r.THINKING, streamed: !0 }
|
|
1190
1199
|
];
|
|
1191
|
-
t.value =
|
|
1192
|
-
const
|
|
1193
|
-
if (
|
|
1194
|
-
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:",
|
|
1195
|
-
Query:
|
|
1200
|
+
t.value = D, w.value = "", a();
|
|
1201
|
+
const T = D.length - 1;
|
|
1202
|
+
if (V.chatQueryStreamApi) {
|
|
1203
|
+
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", V.chatQueryStreamApi), await h(V.chatQueryStreamApi, {
|
|
1204
|
+
Query: d,
|
|
1196
1205
|
AppConversationID: l.value,
|
|
1197
1206
|
ResponseMode: "streaming"
|
|
1198
|
-
},
|
|
1199
|
-
const y = t.value[
|
|
1200
|
-
y && y.status !== r.ERROR &&
|
|
1207
|
+
}, T, p.first.signal), C && !R.value) {
|
|
1208
|
+
const y = t.value[T];
|
|
1209
|
+
y && y.status !== r.ERROR && X(d, y.content);
|
|
1201
1210
|
}
|
|
1202
1211
|
return;
|
|
1203
1212
|
}
|
|
1204
1213
|
console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
|
|
1205
1214
|
try {
|
|
1206
|
-
const
|
|
1215
|
+
const L = await Rt().post(V.chatQueryApi, {
|
|
1207
1216
|
app: f.app ?? 1,
|
|
1208
|
-
data: { Query:
|
|
1209
|
-
}), ne = Lt(
|
|
1210
|
-
t.value = [...t.value.slice(0, -1), { type: "ai", content: ne, status: r.COMPLETED }], C && !
|
|
1217
|
+
data: { Query: d, AppConversationID: l.value }
|
|
1218
|
+
}), ne = Lt(L.data);
|
|
1219
|
+
t.value = [...t.value.slice(0, -1), { type: "ai", content: ne, status: r.COMPLETED }], C && !R.value && X(d, ne);
|
|
1211
1220
|
} catch (y) {
|
|
1212
1221
|
t.value = [...t.value.slice(0, -1), { type: "ai", content: (y == null ? void 0 : y.message) || "服务连接失败,请稍后重试", status: r.ERROR }];
|
|
1213
1222
|
}
|
|
1214
1223
|
}
|
|
1215
|
-
async function
|
|
1224
|
+
async function G() {
|
|
1216
1225
|
if (!u.value || i.value) return;
|
|
1217
|
-
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1220
|
-
const C = t.value.length - 1,
|
|
1221
|
-
await h(
|
|
1226
|
+
p.again.abort(), p.again = new AbortController();
|
|
1227
|
+
const d = [...t.value];
|
|
1228
|
+
d.length > 0 && d[d.length - 1].type === "ai" && d.pop(), d.push({ type: "ai", content: "", status: r.RETHINKING, streamed: !0 }), t.value = d, a();
|
|
1229
|
+
const C = t.value.length - 1, D = es(V);
|
|
1230
|
+
await h(D, {
|
|
1222
1231
|
MessageID: u.value,
|
|
1223
1232
|
AppConversationID: l.value,
|
|
1224
1233
|
ResponseMode: "streaming"
|
|
1225
|
-
}, C,
|
|
1234
|
+
}, C, p.again.signal, !0);
|
|
1226
1235
|
}
|
|
1227
1236
|
async function _() {
|
|
1228
1237
|
if (!i.value) return;
|
|
1229
|
-
const
|
|
1230
|
-
if (u.value &&
|
|
1238
|
+
const d = t.value.length - 1 - 1;
|
|
1239
|
+
if (u.value && V.stopMessageApi)
|
|
1231
1240
|
try {
|
|
1232
|
-
await Sn(
|
|
1233
|
-
} catch (
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1241
|
+
await Sn(V, u.value);
|
|
1242
|
+
} catch (D) {
|
|
1243
|
+
const T = [...t.value];
|
|
1244
|
+
T[d] && (T[d] = { ...T[d], content: (D == null ? void 0 : D.message) || "系统繁忙,请稍后再试", status: r.ERROR }), t.value = T;
|
|
1236
1245
|
return;
|
|
1237
1246
|
}
|
|
1238
1247
|
const C = [...t.value];
|
|
1239
|
-
C[
|
|
1248
|
+
C[d] && (C[d] = { ...C[d], content: C[d].content || "已停止回答", status: r.STOP }), t.value = C, i.value = !1, p.first.abort(), p.first = new AbortController(), p.again.abort(), p.again = new AbortController(), s.value = !0;
|
|
1240
1249
|
}
|
|
1241
|
-
async function
|
|
1250
|
+
async function E(d) {
|
|
1242
1251
|
var C;
|
|
1243
|
-
l.value =
|
|
1252
|
+
l.value = d, R.value = !0;
|
|
1244
1253
|
try {
|
|
1245
|
-
const
|
|
1254
|
+
const D = await bn(V, d), T = [], W = An(D == null ? void 0 : D.messages);
|
|
1246
1255
|
for (const y of W)
|
|
1247
|
-
y.query &&
|
|
1248
|
-
t.value =
|
|
1249
|
-
} catch (
|
|
1250
|
-
Te((
|
|
1256
|
+
y.query && T.push({ type: "user", content: y.query }), (C = y.answerInfo) != null && C.answer && T.push({ type: "ai", content: y.answerInfo.answer, status: r.COMPLETED });
|
|
1257
|
+
t.value = T, a();
|
|
1258
|
+
} catch (D) {
|
|
1259
|
+
Te((D == null ? void 0 : D.message) || "加载历史会话失败");
|
|
1251
1260
|
}
|
|
1252
1261
|
}
|
|
1253
|
-
async function
|
|
1254
|
-
var
|
|
1255
|
-
|
|
1262
|
+
async function te() {
|
|
1263
|
+
var d;
|
|
1264
|
+
R.value = !1;
|
|
1256
1265
|
try {
|
|
1257
|
-
const C = await Mt(
|
|
1258
|
-
(
|
|
1266
|
+
const C = await Mt(V);
|
|
1267
|
+
(d = C == null ? void 0 : C.conversation) != null && d.appConversationID && (l.value = C.conversation.appConversationID);
|
|
1259
1268
|
} catch (C) {
|
|
1260
1269
|
Te((C == null ? void 0 : C.message) || "创建会话失败");
|
|
1261
1270
|
}
|
|
1262
1271
|
}
|
|
1263
1272
|
function n() {
|
|
1264
|
-
l.value = "",
|
|
1273
|
+
l.value = "", R.value = !1;
|
|
1265
1274
|
}
|
|
1266
|
-
return { sendMessage: K, regenerateResponse:
|
|
1275
|
+
return { sendMessage: K, regenerateResponse: G, toggleStop: _, goHistoryMessage: E, initConversation: te, resetConversation: n, controllers: p };
|
|
1267
1276
|
}
|
|
1268
|
-
const
|
|
1277
|
+
const ns = { class: "container" }, os = { class: "chat-wrap" }, ss = { class: "message ai-message greet-message" }, as = { class: "ai-greet" }, is = ["src"], ls = {
|
|
1269
1278
|
key: 0,
|
|
1270
1279
|
class: "message ai-message recommend-message"
|
|
1271
|
-
},
|
|
1280
|
+
}, us = { class: "ai-recommend" }, rs = { class: "recommend-header" }, cs = ["src"], vs = ["onClick"], ds = /* @__PURE__ */ Ee({
|
|
1272
1281
|
__name: "Answer",
|
|
1273
1282
|
props: {
|
|
1274
1283
|
defaultSayhello: {},
|
|
@@ -1284,259 +1293,259 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1284
1293
|
COMPLETED: "completed",
|
|
1285
1294
|
STOP: "stop",
|
|
1286
1295
|
ERROR: "error"
|
|
1287
|
-
}, l = t, h = i, s = qe(), a = g([]), r = g(""), f = g(!1), k = g(""),
|
|
1288
|
-
() =>
|
|
1296
|
+
}, l = t, h = i, s = qe(), a = g([]), r = g(""), f = g(!1), k = g(""), V = g(""), p = g(null), R = ye({ text1: "", text2: "" }), X = g([]), K = g(0), G = B(
|
|
1297
|
+
() => X.value[K.value % (X.value.length || 1)]
|
|
1289
1298
|
);
|
|
1290
1299
|
function _() {
|
|
1291
1300
|
K.value++;
|
|
1292
1301
|
}
|
|
1293
|
-
function
|
|
1302
|
+
function E(j) {
|
|
1294
1303
|
r.value = j;
|
|
1295
1304
|
}
|
|
1296
|
-
const { isAtBottom:
|
|
1305
|
+
const { isAtBottom: te, hasScroll: n, scrollToBottom: d, checkScrollStatus: C } = jo(p), { enhanceCodeBlocks: D } = Uo(), { batchMessagesUpdate: T, flushMessagesBatch: W } = Zo(a), { doStreamRequest: y, issTop: L } = Io({
|
|
1297
1306
|
messages: a,
|
|
1298
1307
|
isGenerating: f,
|
|
1299
1308
|
lastUserMessage: k,
|
|
1300
|
-
batchMessagesUpdate:
|
|
1309
|
+
batchMessagesUpdate: T,
|
|
1301
1310
|
flushMessagesBatch: W,
|
|
1302
1311
|
STATUS: u,
|
|
1303
1312
|
cfg: s
|
|
1304
|
-
}), { sendMessage: ne, regenerateResponse: S, toggleStop:
|
|
1313
|
+
}), { sendMessage: ne, regenerateResponse: S, toggleStop: q, goHistoryMessage: N, resetConversation: b } = ts({
|
|
1305
1314
|
messages: a,
|
|
1306
1315
|
userInput: r,
|
|
1307
1316
|
isGenerating: f,
|
|
1308
1317
|
lastUserMessage: k,
|
|
1309
|
-
conversationId:
|
|
1318
|
+
conversationId: V,
|
|
1310
1319
|
doStreamRequest: y,
|
|
1311
|
-
issTop:
|
|
1312
|
-
scrollToBottom:
|
|
1320
|
+
issTop: L,
|
|
1321
|
+
scrollToBottom: d,
|
|
1313
1322
|
STATUS: u,
|
|
1314
1323
|
cfg: s,
|
|
1315
1324
|
onTitleGenerated: (j) => h("title-generated", j)
|
|
1316
1325
|
});
|
|
1317
|
-
function
|
|
1326
|
+
function x() {
|
|
1318
1327
|
a.value = [], k.value = "", b();
|
|
1319
1328
|
}
|
|
1320
|
-
const
|
|
1321
|
-
w({ goHistoryMessage:
|
|
1322
|
-
const
|
|
1329
|
+
const M = B(() => a.value.length === 0);
|
|
1330
|
+
w({ goHistoryMessage: N, createNewConversation: x, isEmptyConversation: M });
|
|
1331
|
+
const $ = g(/* @__PURE__ */ new Map());
|
|
1323
1332
|
function Y(j, Z) {
|
|
1324
|
-
j ?
|
|
1333
|
+
j ? $.value.set(Z, j) : $.value.delete(Z);
|
|
1325
1334
|
}
|
|
1326
|
-
|
|
1335
|
+
ve(a, () => {
|
|
1327
1336
|
me(() => {
|
|
1328
|
-
|
|
1329
|
-
|
|
1337
|
+
$.value.forEach((j) => {
|
|
1338
|
+
D(j);
|
|
1330
1339
|
}), C();
|
|
1331
1340
|
});
|
|
1332
1341
|
}, { deep: !0 });
|
|
1333
1342
|
let H = null;
|
|
1334
|
-
|
|
1335
|
-
l.defaultSayhello && (
|
|
1336
|
-
}),
|
|
1337
|
-
|
|
1343
|
+
be(() => {
|
|
1344
|
+
l.defaultSayhello && (R.text1 = l.defaultSayhello.text1, R.text2 = l.defaultSayhello.text2), l.defaultRecommend && (X.value = xn(l.defaultRecommend));
|
|
1345
|
+
}), be(() => {
|
|
1346
|
+
p.value && (H = () => C(), p.value.addEventListener("scroll", H), C());
|
|
1338
1347
|
});
|
|
1339
1348
|
const F = g(null);
|
|
1340
|
-
let oe = !1, le = 0,
|
|
1341
|
-
function
|
|
1349
|
+
let oe = !1, le = 0, de = 0;
|
|
1350
|
+
function ke(j) {
|
|
1342
1351
|
var ae;
|
|
1343
|
-
const Z = (ae =
|
|
1352
|
+
const Z = (ae = p.value) == null ? void 0 : ae.closest(".chat-wrap");
|
|
1344
1353
|
return parseFloat((Z == null ? void 0 : Z.style.getPropertyValue(j)) ?? "") || 0;
|
|
1345
1354
|
}
|
|
1346
|
-
function
|
|
1355
|
+
function P(j) {
|
|
1347
1356
|
return "touches" in j ? j.touches[0].clientY : j.clientY;
|
|
1348
1357
|
}
|
|
1349
|
-
function
|
|
1350
|
-
const Z =
|
|
1351
|
-
Z && (j.preventDefault(), oe = !0, le =
|
|
1358
|
+
function Q(j) {
|
|
1359
|
+
const Z = p.value;
|
|
1360
|
+
Z && (j.preventDefault(), oe = !0, le = P(j), Z.scrollTop, de = ke("--ai-thumb-top"), window.addEventListener("mousemove", I), window.addEventListener("mouseup", ue), window.addEventListener("touchmove", I, { passive: !1 }), window.addEventListener("touchend", ue));
|
|
1352
1361
|
}
|
|
1353
|
-
function
|
|
1354
|
-
const Z =
|
|
1362
|
+
function I(j) {
|
|
1363
|
+
const Z = p.value;
|
|
1355
1364
|
if (!oe || !Z) return;
|
|
1356
1365
|
j.preventDefault();
|
|
1357
|
-
const ae =
|
|
1358
|
-
Z.scrollTop = lt / ze * (
|
|
1366
|
+
const ae = P(j) - le, ee = Z.clientHeight, Ce = Z.scrollHeight, Re = ke("--ai-thumb-height"), ze = ee - Re, lt = Math.min(Math.max(de + ae, 0), ze);
|
|
1367
|
+
Z.scrollTop = lt / ze * (Ce - ee);
|
|
1359
1368
|
}
|
|
1360
|
-
function
|
|
1361
|
-
oe = !1, window.removeEventListener("mousemove",
|
|
1369
|
+
function ue() {
|
|
1370
|
+
oe = !1, window.removeEventListener("mousemove", I), window.removeEventListener("mouseup", ue), window.removeEventListener("touchmove", I), window.removeEventListener("touchend", ue);
|
|
1362
1371
|
}
|
|
1363
|
-
function
|
|
1364
|
-
const Z =
|
|
1372
|
+
function ge(j) {
|
|
1373
|
+
const Z = p.value, ae = F.value;
|
|
1365
1374
|
if (!Z || !ae) return;
|
|
1366
1375
|
j.preventDefault();
|
|
1367
|
-
const
|
|
1376
|
+
const ee = ae.getBoundingClientRect(), Re = (P(j) - ee.top) / ee.height;
|
|
1368
1377
|
Z.scrollTop = Re * (Z.scrollHeight - Z.clientHeight);
|
|
1369
1378
|
}
|
|
1370
1379
|
return Pe(() => {
|
|
1371
|
-
|
|
1380
|
+
p.value && H && p.value.removeEventListener("scroll", H), ue();
|
|
1372
1381
|
}), (j, Z) => {
|
|
1373
1382
|
var ae;
|
|
1374
|
-
return v(), m("div",
|
|
1375
|
-
o("div",
|
|
1383
|
+
return v(), m("div", ns, [
|
|
1384
|
+
o("div", os, [
|
|
1376
1385
|
o("div", {
|
|
1377
1386
|
class: "chat-box scrollWrap",
|
|
1378
1387
|
ref_key: "chatBoxRef",
|
|
1379
|
-
ref:
|
|
1388
|
+
ref: p
|
|
1380
1389
|
}, [
|
|
1381
|
-
o("div",
|
|
1382
|
-
o("div",
|
|
1383
|
-
o("img", { src:
|
|
1384
|
-
o("h1", null,
|
|
1385
|
-
o("p", null,
|
|
1390
|
+
o("div", ss, [
|
|
1391
|
+
o("div", as, [
|
|
1392
|
+
o("img", { src: O(Qt) }, null, 8, is),
|
|
1393
|
+
o("h1", null, z(R.text1), 1),
|
|
1394
|
+
o("p", null, z(R.text2), 1)
|
|
1386
1395
|
])
|
|
1387
1396
|
]),
|
|
1388
|
-
(ae =
|
|
1389
|
-
o("div",
|
|
1390
|
-
o("div",
|
|
1397
|
+
(ae = G.value) != null && ae.length ? (v(), m("div", ls, [
|
|
1398
|
+
o("div", us, [
|
|
1399
|
+
o("div", rs, [
|
|
1391
1400
|
Z[2] || (Z[2] = o("span", null, "你可以尝试这样问我:", -1)),
|
|
1392
1401
|
o("p", {
|
|
1393
1402
|
class: "refresh-btn",
|
|
1394
1403
|
onClick: _
|
|
1395
1404
|
}, [
|
|
1396
|
-
o("img", { src:
|
|
1405
|
+
o("img", { src: O(Un) }, null, 8, cs),
|
|
1397
1406
|
Z[1] || (Z[1] = o("span", null, "换一换", -1))
|
|
1398
1407
|
])
|
|
1399
1408
|
]),
|
|
1400
1409
|
o("ul", null, [
|
|
1401
|
-
(v(!0), m(
|
|
1402
|
-
key:
|
|
1403
|
-
onClick: (Re) =>
|
|
1404
|
-
},
|
|
1410
|
+
(v(!0), m(we, null, xe(G.value, (ee, Ce) => (v(), m("li", {
|
|
1411
|
+
key: Ce,
|
|
1412
|
+
onClick: (Re) => E(ee)
|
|
1413
|
+
}, z(ee), 9, vs))), 128))
|
|
1405
1414
|
])
|
|
1406
1415
|
])
|
|
1407
|
-
])) :
|
|
1408
|
-
(v(!0), m(
|
|
1409
|
-
key:
|
|
1410
|
-
msg:
|
|
1411
|
-
index:
|
|
1416
|
+
])) : J("", !0),
|
|
1417
|
+
(v(!0), m(we, null, xe(a.value, (ee, Ce) => (v(), pe(Lo, {
|
|
1418
|
+
key: Ce,
|
|
1419
|
+
msg: ee,
|
|
1420
|
+
index: Ce,
|
|
1412
1421
|
STATUS: u,
|
|
1413
1422
|
setMessageRef: Y,
|
|
1414
|
-
scrollToBottom:
|
|
1415
|
-
onRegenerate:
|
|
1423
|
+
scrollToBottom: O(d),
|
|
1424
|
+
onRegenerate: O(S)
|
|
1416
1425
|
}, null, 8, ["msg", "index", "scrollToBottom", "onRegenerate"]))), 128))
|
|
1417
1426
|
], 512),
|
|
1418
1427
|
o("div", {
|
|
1419
1428
|
ref_key: "scrollbarRef",
|
|
1420
1429
|
ref: F,
|
|
1421
1430
|
class: "chat-box__scrollbar",
|
|
1422
|
-
onMousedown: fe(
|
|
1423
|
-
onTouchstart: fe(
|
|
1431
|
+
onMousedown: fe(ge, ["prevent"]),
|
|
1432
|
+
onTouchstart: fe(ge, ["prevent"])
|
|
1424
1433
|
}, [
|
|
1425
1434
|
o("div", {
|
|
1426
1435
|
class: "chat-box__scrollbar-thumb",
|
|
1427
|
-
onMousedown: fe(
|
|
1428
|
-
onTouchstart: fe(
|
|
1436
|
+
onMousedown: fe(Q, ["stop", "prevent"]),
|
|
1437
|
+
onTouchstart: fe(Q, ["stop", "prevent"])
|
|
1429
1438
|
}, null, 32)
|
|
1430
1439
|
], 544)
|
|
1431
1440
|
]),
|
|
1432
|
-
ie(
|
|
1441
|
+
ie(Go, {
|
|
1433
1442
|
modelValue: r.value,
|
|
1434
|
-
"onUpdate:modelValue": Z[0] || (Z[0] = (
|
|
1443
|
+
"onUpdate:modelValue": Z[0] || (Z[0] = (ee) => r.value = ee),
|
|
1435
1444
|
isGenerating: f.value,
|
|
1436
|
-
hasScroll:
|
|
1437
|
-
isAtBottom:
|
|
1438
|
-
onSend:
|
|
1439
|
-
onRegenerate:
|
|
1440
|
-
onStop:
|
|
1441
|
-
onScrollToBottom:
|
|
1445
|
+
hasScroll: O(n),
|
|
1446
|
+
isAtBottom: O(te),
|
|
1447
|
+
onSend: O(ne),
|
|
1448
|
+
onRegenerate: O(S),
|
|
1449
|
+
onStop: O(q),
|
|
1450
|
+
onScrollToBottom: O(d)
|
|
1442
1451
|
}, null, 8, ["modelValue", "isGenerating", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
|
|
1443
1452
|
Z[3] || (Z[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
|
|
1444
1453
|
]);
|
|
1445
1454
|
};
|
|
1446
1455
|
}
|
|
1447
|
-
}),
|
|
1456
|
+
}), hs = { class: "ai-history" }, ps = { class: "content" }, ms = {
|
|
1448
1457
|
key: 0,
|
|
1449
1458
|
class: "ai-history-loading"
|
|
1450
|
-
},
|
|
1459
|
+
}, fs = { class: "ai-history-group-title" }, gs = ["onClick"], ys = { class: "ai-history-item-title" }, ws = ["onClick"], ks = {
|
|
1451
1460
|
key: 2,
|
|
1452
1461
|
class: "ai-history-empty"
|
|
1453
|
-
},
|
|
1462
|
+
}, Cs = ["src"], _s = { class: "ai-modal" }, bs = { class: "ai-modal-footer" }, As = /* @__PURE__ */ Ee({
|
|
1454
1463
|
__name: "History",
|
|
1455
1464
|
emits: ["history-detail", "new-conversation"],
|
|
1456
1465
|
setup(t, { emit: w }) {
|
|
1457
|
-
const u = qe().apis, l = g([]), h = g(!0), s = g(!1), a = g(""), r =
|
|
1466
|
+
const u = qe().apis, l = g([]), h = g(!0), s = g(!1), a = g(""), r = B(() => Dn(l.value));
|
|
1458
1467
|
async function f() {
|
|
1459
1468
|
try {
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
} catch (
|
|
1463
|
-
Te((
|
|
1469
|
+
const p = await Mn(u);
|
|
1470
|
+
p != null && p.conversationList && (l.value = p.conversationList.filter((R) => R !== null).map((R) => ({ ...R, selected: !1 })));
|
|
1471
|
+
} catch (p) {
|
|
1472
|
+
Te((p == null ? void 0 : p.message) || "获取历史记录失败");
|
|
1464
1473
|
} finally {
|
|
1465
1474
|
h.value = !1;
|
|
1466
1475
|
}
|
|
1467
1476
|
}
|
|
1468
|
-
function k(
|
|
1469
|
-
a.value =
|
|
1477
|
+
function k(p) {
|
|
1478
|
+
a.value = p, s.value = !0;
|
|
1470
1479
|
}
|
|
1471
|
-
async function
|
|
1480
|
+
async function V() {
|
|
1472
1481
|
s.value = !1;
|
|
1473
1482
|
try {
|
|
1474
1483
|
await Rn(u, a.value), await f();
|
|
1475
|
-
} catch (
|
|
1476
|
-
Te((
|
|
1484
|
+
} catch (p) {
|
|
1485
|
+
Te((p == null ? void 0 : p.message) || "删除失败"), await f();
|
|
1477
1486
|
}
|
|
1478
1487
|
}
|
|
1479
|
-
return
|
|
1488
|
+
return be(() => {
|
|
1480
1489
|
f();
|
|
1481
|
-
}), (
|
|
1482
|
-
o("div",
|
|
1483
|
-
h.value ? (v(), m("div",
|
|
1490
|
+
}), (p, R) => (v(), m("div", hs, [
|
|
1491
|
+
o("div", ps, [
|
|
1492
|
+
h.value ? (v(), m("div", ms, [...R[3] || (R[3] = [
|
|
1484
1493
|
o("div", { class: "ai-history-spinner" }, null, -1)
|
|
1485
|
-
])])) : r.value.length > 0 ? (v(!0), m(
|
|
1486
|
-
key:
|
|
1494
|
+
])])) : r.value.length > 0 ? (v(!0), m(we, { key: 1 }, xe(r.value, (X) => (v(), m("div", {
|
|
1495
|
+
key: X.label,
|
|
1487
1496
|
class: "ai-history-group"
|
|
1488
1497
|
}, [
|
|
1489
|
-
o("div",
|
|
1490
|
-
(v(!0), m(
|
|
1498
|
+
o("div", fs, z(X.label), 1),
|
|
1499
|
+
(v(!0), m(we, null, xe(X.items, (K, G) => (v(), m("div", {
|
|
1491
1500
|
key: K.appConversationID,
|
|
1492
1501
|
class: "ai-history-item",
|
|
1493
|
-
style: it({ "--i":
|
|
1494
|
-
onClick: (_) =>
|
|
1502
|
+
style: it({ "--i": G }),
|
|
1503
|
+
onClick: (_) => p.$emit("history-detail", K.appConversationID)
|
|
1495
1504
|
}, [
|
|
1496
|
-
o("div",
|
|
1505
|
+
o("div", ys, z(K.conversationName), 1),
|
|
1497
1506
|
o("div", {
|
|
1498
1507
|
class: "ai-history-item-delete",
|
|
1499
1508
|
onClick: fe((_) => k(K.appConversationID), ["stop"])
|
|
1500
|
-
}, "删除", 8,
|
|
1501
|
-
], 12,
|
|
1502
|
-
]))), 128)) : (v(), m("div",
|
|
1509
|
+
}, "删除", 8, ws)
|
|
1510
|
+
], 12, gs))), 128))
|
|
1511
|
+
]))), 128)) : (v(), m("div", ks, "暂无历史记录"))
|
|
1503
1512
|
]),
|
|
1504
1513
|
o("div", {
|
|
1505
1514
|
class: "ai-add",
|
|
1506
|
-
onClick:
|
|
1515
|
+
onClick: R[0] || (R[0] = (X) => p.$emit("new-conversation"))
|
|
1507
1516
|
}, [
|
|
1508
|
-
o("img", { src:
|
|
1509
|
-
|
|
1517
|
+
o("img", { src: O(Fn) }, null, 8, Cs),
|
|
1518
|
+
R[4] || (R[4] = o("span", null, "新建AI对话", -1))
|
|
1510
1519
|
]),
|
|
1511
1520
|
(v(), pe(Yt, { to: "#ai-assist-root" }, [
|
|
1512
1521
|
s.value ? (v(), m("div", {
|
|
1513
1522
|
key: 0,
|
|
1514
1523
|
class: "ai-modal-overlay",
|
|
1515
|
-
onClick:
|
|
1524
|
+
onClick: R[2] || (R[2] = fe((X) => s.value = !1, ["self"]))
|
|
1516
1525
|
}, [
|
|
1517
|
-
o("div",
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
o("div",
|
|
1526
|
+
o("div", _s, [
|
|
1527
|
+
R[5] || (R[5] = o("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
|
|
1528
|
+
R[6] || (R[6] = o("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
|
|
1529
|
+
o("div", bs, [
|
|
1521
1530
|
o("button", {
|
|
1522
1531
|
class: "ai-modal-btn cancel",
|
|
1523
|
-
onClick:
|
|
1532
|
+
onClick: R[1] || (R[1] = (X) => s.value = !1)
|
|
1524
1533
|
}, "取消"),
|
|
1525
1534
|
o("button", {
|
|
1526
1535
|
class: "ai-modal-btn confirm",
|
|
1527
|
-
onClick:
|
|
1536
|
+
onClick: V
|
|
1528
1537
|
}, "确定")
|
|
1529
1538
|
])
|
|
1530
1539
|
])
|
|
1531
|
-
])) :
|
|
1540
|
+
])) : J("", !0)
|
|
1532
1541
|
]))
|
|
1533
1542
|
]));
|
|
1534
1543
|
}
|
|
1535
|
-
}),
|
|
1544
|
+
}), Ss = { class: "container info" }, Es = { class: "info-item" }, Ts = { class: "basic-content" }, xs = { class: "basic-content-text" }, Ds = { class: "basic-content" }, Ms = { class: "basic-content-text" }, Rs = { class: "info-item" }, Hs = { class: "permission-content" }, $s = { class: "info-item" }, Ls = { class: "basic-content" }, Ps = { class: "basic-content-text" }, Os = { class: "basic-content" }, Bs = { class: "basic-content-text" }, Ws = /* @__PURE__ */ Ee({
|
|
1536
1545
|
__name: "Info",
|
|
1537
1546
|
setup(t) {
|
|
1538
1547
|
const w = qe(), i = g(null);
|
|
1539
|
-
return
|
|
1548
|
+
return be(async () => {
|
|
1540
1549
|
try {
|
|
1541
1550
|
i.value = await Hn(w.apis);
|
|
1542
1551
|
} catch (u) {
|
|
@@ -1544,87 +1553,87 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1544
1553
|
}
|
|
1545
1554
|
}), (u, l) => {
|
|
1546
1555
|
var h, s, a, r, f;
|
|
1547
|
-
return v(), m("div",
|
|
1548
|
-
o("div",
|
|
1556
|
+
return v(), m("div", Ss, [
|
|
1557
|
+
o("div", Es, [
|
|
1549
1558
|
l[2] || (l[2] = o("div", { class: "heading" }, [
|
|
1550
1559
|
o("div", { class: "heading-column" }),
|
|
1551
1560
|
o("div", { class: "heading-title" }, "基本信息")
|
|
1552
1561
|
], -1)),
|
|
1553
|
-
o("div",
|
|
1562
|
+
o("div", Ts, [
|
|
1554
1563
|
l[0] || (l[0] = o("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
|
|
1555
|
-
o("div",
|
|
1564
|
+
o("div", xs, z(((h = i.value) == null ? void 0 : h.name) || ""), 1)
|
|
1556
1565
|
]),
|
|
1557
|
-
o("div",
|
|
1566
|
+
o("div", Ds, [
|
|
1558
1567
|
l[1] || (l[1] = o("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
|
|
1559
|
-
o("div",
|
|
1568
|
+
o("div", Ms, z(((s = i.value) == null ? void 0 : s.userName) || ""), 1)
|
|
1560
1569
|
])
|
|
1561
1570
|
]),
|
|
1562
|
-
o("div",
|
|
1571
|
+
o("div", Rs, [
|
|
1563
1572
|
l[3] || (l[3] = o("div", { class: "heading" }, [
|
|
1564
1573
|
o("div", { class: "heading-column" }),
|
|
1565
1574
|
o("div", { class: "heading-title" }, "数据权限")
|
|
1566
1575
|
], -1)),
|
|
1567
|
-
o("div",
|
|
1568
|
-
(v(!0), m(
|
|
1569
|
-
key:
|
|
1576
|
+
o("div", Hs, [
|
|
1577
|
+
(v(!0), m(we, null, xe((a = i.value) == null ? void 0 : a.ptnameList, (k, V) => (v(), m("div", {
|
|
1578
|
+
key: V,
|
|
1570
1579
|
class: "permission-content-text"
|
|
1571
|
-
},
|
|
1580
|
+
}, z(k), 1))), 128))
|
|
1572
1581
|
])
|
|
1573
1582
|
]),
|
|
1574
|
-
o("div",
|
|
1583
|
+
o("div", $s, [
|
|
1575
1584
|
l[6] || (l[6] = o("div", { class: "heading" }, [
|
|
1576
1585
|
o("div", { class: "heading-column" }),
|
|
1577
1586
|
o("div", { class: "heading-title" }, "帮助信息")
|
|
1578
1587
|
], -1)),
|
|
1579
|
-
o("div",
|
|
1588
|
+
o("div", Ls, [
|
|
1580
1589
|
l[4] || (l[4] = o("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
|
|
1581
|
-
o("div",
|
|
1590
|
+
o("div", Ps, z(((r = i.value) == null ? void 0 : r.dept) || ""), 1)
|
|
1582
1591
|
]),
|
|
1583
|
-
o("div",
|
|
1592
|
+
o("div", Os, [
|
|
1584
1593
|
l[5] || (l[5] = o("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
|
|
1585
|
-
o("div",
|
|
1594
|
+
o("div", Bs, z(((f = i.value) == null ? void 0 : f.email) || ""), 1)
|
|
1586
1595
|
])
|
|
1587
1596
|
])
|
|
1588
1597
|
]);
|
|
1589
1598
|
};
|
|
1590
1599
|
}
|
|
1591
|
-
}),
|
|
1600
|
+
}), Ys = { key: 1 }, Ns = ["src"], Vs = { class: "header-title" }, Xs = ["title"], Fs = { class: "ai-history-drawer-panel" }, Qs = { class: "ai-history-drawer-header" }, Js = { class: "setTitle" }, qs = { class: "content" }, zs = { class: "main" }, Ks = { class: "btn" }, Gs = ["src"], js = 78, Xe = 78, he = 8, Fe = 26, Le = 490, Pt = "aiPanelPosition", Ot = "aiPanelDocked", Bt = "aiDockWidth", Us = 60, Zs = 150, Wt = 400, Is = 320, Jt = /* @__PURE__ */ Ee({
|
|
1592
1601
|
__name: "AiAssist",
|
|
1593
1602
|
setup(t) {
|
|
1594
1603
|
var xt;
|
|
1595
|
-
const w =
|
|
1604
|
+
const w = js / 2, i = qe(), u = g(!1), l = g("idle"), h = g(!1), s = ye({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), a = g(!1), r = g(window.innerWidth < 768), f = g(window.innerWidth < 768), k = g("answer"), V = g(!1), p = g(""), R = g(""), X = g(""), K = g(!1), G = g(!1), _ = ye({
|
|
1596
1605
|
x: window.innerWidth - w,
|
|
1597
1606
|
y: window.innerHeight / 2 - Xe / 2
|
|
1598
|
-
}),
|
|
1599
|
-
let
|
|
1600
|
-
const
|
|
1601
|
-
let oe = null, le = !1,
|
|
1602
|
-
const
|
|
1603
|
-
let
|
|
1604
|
-
const j =
|
|
1607
|
+
}), E = g(!1), te = g(!1), n = g("right"), d = g("left"), C = g(null), D = ye({ x: 0, y: 0 }), T = g(!1), W = g(!1), y = ye({ x: 0, y: 0 }), L = g(!1), ne = ye({ x: 0, y: 0 }), S = g(!1), q = g(!1), N = g(!1), b = ye({ x: 0, width: 0 }), x = g(!1);
|
|
1608
|
+
let M = 0;
|
|
1609
|
+
const $ = g("idle"), Y = g(!1), H = g("none"), F = ye({ x: 0, y: 0, w: Le, h: 0, radius: "14px" });
|
|
1610
|
+
let oe = null, le = !1, de = !1;
|
|
1611
|
+
const ke = ye({ x: 0, y: 0 }), P = g(!1), Q = g(null);
|
|
1612
|
+
let I = null, ue = null, ge = null;
|
|
1613
|
+
const j = B(() => {
|
|
1605
1614
|
const e = window.innerWidth / 2;
|
|
1606
1615
|
return _.x + w < e ? 5 : -5;
|
|
1607
|
-
}), Z =
|
|
1616
|
+
}), Z = B(() => f.value || S.value || $.value !== "idle" ? "" : `panel-${n.value}`), ae = B(() => {
|
|
1608
1617
|
var e;
|
|
1609
1618
|
return !!((e = i.dock) != null && e.containerId) && !r.value;
|
|
1610
|
-
}),
|
|
1619
|
+
}), ee = g(((xt = i.dock) == null ? void 0 : xt.width) || Le), Ce = B(() => i.panelDraggable !== !1), Re = B(() => {
|
|
1611
1620
|
var e;
|
|
1612
|
-
return !((e =
|
|
1613
|
-
}), ze =
|
|
1621
|
+
return !((e = Q.value) != null && e.isEmptyConversation);
|
|
1622
|
+
}), ze = B(() => ({
|
|
1614
1623
|
left: `${_.x}px`,
|
|
1615
1624
|
top: `${_.y}px`,
|
|
1616
|
-
transition:
|
|
1625
|
+
transition: E.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
|
|
1617
1626
|
"--direction": String(j.value)
|
|
1618
|
-
})), lt =
|
|
1627
|
+
})), lt = B(() => i.characterImage || Qn), qt = B(() => l.value === "idle" ? {} : {
|
|
1619
1628
|
left: `${s.x}px`,
|
|
1620
1629
|
top: `${s.y}px`,
|
|
1621
1630
|
width: `${s.w}px`,
|
|
1622
1631
|
height: `${s.h}px`,
|
|
1623
1632
|
borderRadius: s.radius
|
|
1624
|
-
}), zt =
|
|
1633
|
+
}), zt = B(() => {
|
|
1625
1634
|
const e = {};
|
|
1626
|
-
return
|
|
1627
|
-
}), Kt =
|
|
1635
|
+
return T.value && !f.value && !r.value && !S.value && (e["--ai-panel-x"] = `${D.x}px`, e["--ai-panel-y"] = `${D.y}px`), S.value && (e["--ai-dock-width"] = `${ee.value}px`), e;
|
|
1636
|
+
}), Kt = B(() => $.value === "idle" ? {} : {
|
|
1628
1637
|
left: `${F.x}px`,
|
|
1629
1638
|
top: `${F.y}px`,
|
|
1630
1639
|
width: `${F.w}px`,
|
|
@@ -1633,22 +1642,22 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1633
1642
|
});
|
|
1634
1643
|
function Ke() {
|
|
1635
1644
|
const e = window.innerWidth / 2;
|
|
1636
|
-
_.x + w < e ? (n.value = "left",
|
|
1645
|
+
_.x + w < e ? (n.value = "left", d.value = "right") : (n.value = "right", d.value = "left");
|
|
1637
1646
|
}
|
|
1638
1647
|
function Gt() {
|
|
1639
1648
|
const e = window.innerWidth, c = Math.max(0, Math.min(_.y, window.innerHeight - Xe));
|
|
1640
1649
|
return { x: _.x + w >= e / 2 ? e - w : -w, y: c };
|
|
1641
1650
|
}
|
|
1642
1651
|
function pt() {
|
|
1643
|
-
|
|
1652
|
+
te.value = !0;
|
|
1644
1653
|
const e = Gt();
|
|
1645
1654
|
_.x = e.x, _.y = e.y, setTimeout(() => {
|
|
1646
|
-
|
|
1655
|
+
te.value = !1, Ke(), jt();
|
|
1647
1656
|
}, 400);
|
|
1648
1657
|
}
|
|
1649
1658
|
function jt() {
|
|
1650
1659
|
try {
|
|
1651
|
-
localStorage.setItem("characterPosition", JSON.stringify({ x: _.x, y: _.y })), localStorage.setItem("panelPosition", n.value), localStorage.setItem("backPosition",
|
|
1660
|
+
localStorage.setItem("characterPosition", JSON.stringify({ x: _.x, y: _.y })), localStorage.setItem("panelPosition", n.value), localStorage.setItem("backPosition", d.value);
|
|
1652
1661
|
} catch {
|
|
1653
1662
|
}
|
|
1654
1663
|
}
|
|
@@ -1660,20 +1669,20 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1660
1669
|
} else
|
|
1661
1670
|
_.x = window.innerWidth - w, _.y = window.innerHeight / 2 - Xe / 2;
|
|
1662
1671
|
const c = localStorage.getItem("panelPosition"), A = localStorage.getItem("backPosition");
|
|
1663
|
-
c && (n.value = c), A && (
|
|
1672
|
+
c && (n.value = c), A && (d.value = A);
|
|
1664
1673
|
}
|
|
1665
1674
|
function Ge(e) {
|
|
1666
|
-
if (!
|
|
1667
|
-
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY, U = c -
|
|
1668
|
-
|
|
1675
|
+
if (!E.value) return;
|
|
1676
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY, U = c - ke.x, re = Math.max(0, Math.min(A - ke.y, window.innerHeight - Xe)), _e = Math.abs(U - _.x), Ae = Math.abs(re - _.y);
|
|
1677
|
+
_e + Ae > 5 && (P.value = !0), _.x = U, _.y = re;
|
|
1669
1678
|
}
|
|
1670
1679
|
function je() {
|
|
1671
|
-
|
|
1680
|
+
E.value && (E.value = !1, P.value && (pt(), P.value = !1));
|
|
1672
1681
|
}
|
|
1673
1682
|
function mt(e) {
|
|
1674
|
-
|
|
1683
|
+
te.value = !1, E.value = !0, P.value = !1;
|
|
1675
1684
|
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
1676
|
-
|
|
1685
|
+
ke.x = c - _.x, ke.y = A - _.y;
|
|
1677
1686
|
}
|
|
1678
1687
|
function Zt() {
|
|
1679
1688
|
const e = C.value, c = (e == null ? void 0 : e.offsetWidth) || Le, A = (e == null ? void 0 : e.offsetHeight) || window.innerHeight - 78;
|
|
@@ -1683,48 +1692,48 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1683
1692
|
};
|
|
1684
1693
|
}
|
|
1685
1694
|
function Ue(e, c) {
|
|
1686
|
-
const A = C.value, U = e ?? (A == null ? void 0 : A.offsetWidth) ?? Le,
|
|
1687
|
-
|
|
1695
|
+
const A = C.value, U = e ?? (A == null ? void 0 : A.offsetWidth) ?? Le, re = c ?? (A == null ? void 0 : A.offsetHeight) ?? window.innerHeight - 78, _e = Math.max(he, window.innerWidth - U - he), Ae = Math.max(Fe, window.innerHeight - re - he);
|
|
1696
|
+
D.x = Math.min(Math.max(D.x, he), _e), D.y = Math.min(Math.max(D.y, Fe), Ae);
|
|
1688
1697
|
}
|
|
1689
1698
|
function ft(e) {
|
|
1690
|
-
if (!
|
|
1691
|
-
if (
|
|
1699
|
+
if (!Ce.value || f.value || r.value || S.value || l.value !== "idle") return;
|
|
1700
|
+
if (de = !1, W.value = !0, L.value = !1, !T.value) {
|
|
1692
1701
|
const U = C.value;
|
|
1693
1702
|
if (U) {
|
|
1694
|
-
const
|
|
1695
|
-
|
|
1703
|
+
const re = U.getBoundingClientRect();
|
|
1704
|
+
D.x = re.left, D.y = re.top, T.value = !0;
|
|
1696
1705
|
}
|
|
1697
1706
|
}
|
|
1698
1707
|
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
1699
|
-
ne.x = c, ne.y = A, y.x = c -
|
|
1708
|
+
ne.x = c, ne.y = A, y.x = c - D.x, y.y = A - D.y;
|
|
1700
1709
|
}
|
|
1701
1710
|
function Ze(e) {
|
|
1702
|
-
var
|
|
1711
|
+
var Se, Dt;
|
|
1703
1712
|
if (!W.value) return;
|
|
1704
1713
|
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
1705
|
-
if (
|
|
1714
|
+
if (!L.value) {
|
|
1706
1715
|
const fn = Math.abs(c - ne.x), gn = Math.abs(A - ne.y);
|
|
1707
1716
|
if (fn + gn <= 5) return;
|
|
1708
|
-
|
|
1717
|
+
L.value = !0;
|
|
1709
1718
|
}
|
|
1710
|
-
const { maxX: U, maxY:
|
|
1711
|
-
De !==
|
|
1719
|
+
const { maxX: U, maxY: re } = Zt(), _e = ae.value ? U + Zs : U, Ae = Math.min(Math.max(c - y.x, he), _e), $e = Math.min(Math.max(A - y.y, Fe), re), De = ae.value && Ae > U + Us;
|
|
1720
|
+
De !== de && (de = De, (Dt = (Se = i.dock) == null ? void 0 : Se.onDockChange) == null || Dt.call(Se, De)), q.value = De, D.x = Ae, D.y = $e;
|
|
1712
1721
|
}
|
|
1713
1722
|
function Ie() {
|
|
1714
1723
|
var c, A;
|
|
1715
1724
|
if (!W.value) return;
|
|
1716
1725
|
W.value = !1;
|
|
1717
1726
|
let e = !1;
|
|
1718
|
-
|
|
1727
|
+
L.value && (L.value = !1, le = !0, setTimeout(() => {
|
|
1719
1728
|
le = !1;
|
|
1720
|
-
}, 0),
|
|
1729
|
+
}, 0), q.value && ae.value ? (kt(), e = !0) : (Ue(), It())), de && !e && (de = !1, (A = (c = i.dock) == null ? void 0 : c.onDockChange) == null || A.call(c, !1)), q.value = !1;
|
|
1721
1730
|
}
|
|
1722
1731
|
function gt(e) {
|
|
1723
1732
|
le && (e.preventDefault(), e.stopPropagation(), le = !1);
|
|
1724
1733
|
}
|
|
1725
1734
|
function It() {
|
|
1726
1735
|
try {
|
|
1727
|
-
localStorage.setItem(Pt, JSON.stringify({ x:
|
|
1736
|
+
localStorage.setItem(Pt, JSON.stringify({ x: D.x, y: D.y }));
|
|
1728
1737
|
} catch {
|
|
1729
1738
|
}
|
|
1730
1739
|
}
|
|
@@ -1733,7 +1742,7 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1733
1742
|
const e = localStorage.getItem(Pt);
|
|
1734
1743
|
if (e) {
|
|
1735
1744
|
const c = JSON.parse(e);
|
|
1736
|
-
typeof c.x == "number" && typeof c.y == "number" && (
|
|
1745
|
+
typeof c.x == "number" && typeof c.y == "number" && (D.x = c.x, D.y = c.y, T.value = !0);
|
|
1737
1746
|
}
|
|
1738
1747
|
} catch {
|
|
1739
1748
|
}
|
|
@@ -1756,9 +1765,9 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1756
1765
|
}
|
|
1757
1766
|
function et() {
|
|
1758
1767
|
return {
|
|
1759
|
-
x: window.innerWidth -
|
|
1768
|
+
x: window.innerWidth - ee.value,
|
|
1760
1769
|
y: 0,
|
|
1761
|
-
w:
|
|
1770
|
+
w: ee.value,
|
|
1762
1771
|
h: window.innerHeight,
|
|
1763
1772
|
radius: "0px"
|
|
1764
1773
|
};
|
|
@@ -1786,19 +1795,19 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1786
1795
|
f.value ? (He(wt(), bt()), f.value = !1) : (He(Oe(), wt()), f.value = !0);
|
|
1787
1796
|
}
|
|
1788
1797
|
function He(e, c, A, U = "none") {
|
|
1789
|
-
oe && clearTimeout(oe),
|
|
1798
|
+
oe && clearTimeout(oe), $.value = "switching", Y.value = !0, H.value = U, F.x = e.x, F.y = e.y, F.w = e.w, F.h = e.h, F.radius = e.radius, me(() => {
|
|
1790
1799
|
requestAnimationFrame(() => {
|
|
1791
1800
|
Y.value = !1, F.x = c.x, F.y = c.y, F.w = c.w, F.h = c.h, F.radius = c.radius;
|
|
1792
1801
|
});
|
|
1793
1802
|
}), oe = setTimeout(() => {
|
|
1794
|
-
|
|
1803
|
+
$.value = "idle", H.value = "none", oe = null, A == null || A();
|
|
1795
1804
|
}, 400);
|
|
1796
1805
|
}
|
|
1797
1806
|
function kt() {
|
|
1798
|
-
var
|
|
1807
|
+
var re, _e, Ae, $e, De;
|
|
1799
1808
|
if (!ae.value || S.value) return;
|
|
1800
1809
|
f.value && (f.value = !1);
|
|
1801
|
-
const e = (
|
|
1810
|
+
const e = (re = i.dock) == null ? void 0 : re.containerId;
|
|
1802
1811
|
if (e && !document.getElementById(e)) {
|
|
1803
1812
|
console.warn(`[ai-assist-sdk] dock container "#${e}" not found, dock feature disabled`);
|
|
1804
1813
|
return;
|
|
@@ -1806,21 +1815,21 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1806
1815
|
const c = C.value;
|
|
1807
1816
|
let A = Oe();
|
|
1808
1817
|
if (c) {
|
|
1809
|
-
const
|
|
1810
|
-
A = { x:
|
|
1818
|
+
const Se = c.getBoundingClientRect();
|
|
1819
|
+
A = { x: Se.left, y: Se.top, w: Se.width, h: Se.height, radius: getComputedStyle(c).borderRadius };
|
|
1811
1820
|
}
|
|
1812
1821
|
const U = et();
|
|
1813
|
-
He(A, U), S.value = !0, l.value = "idle",
|
|
1822
|
+
He(A, U), S.value = !0, l.value = "idle", q.value = !1, yt(), (Ae = (_e = i.dock) == null ? void 0 : _e.onDockChange) == null || Ae.call(_e, !0), (De = ($e = i.dock) == null ? void 0 : $e.onDockWidthChange) == null || De.call($e, ee.value);
|
|
1814
1823
|
}
|
|
1815
1824
|
function sn() {
|
|
1816
|
-
return Math.max(Wt, window.innerWidth -
|
|
1825
|
+
return Math.max(Wt, window.innerWidth - Is);
|
|
1817
1826
|
}
|
|
1818
1827
|
function ut(e) {
|
|
1819
1828
|
return Math.min(Math.max(e, Wt), sn());
|
|
1820
1829
|
}
|
|
1821
1830
|
function an() {
|
|
1822
1831
|
try {
|
|
1823
|
-
localStorage.setItem(Bt, String(
|
|
1832
|
+
localStorage.setItem(Bt, String(ee.value));
|
|
1824
1833
|
} catch {
|
|
1825
1834
|
}
|
|
1826
1835
|
}
|
|
@@ -1829,39 +1838,39 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1829
1838
|
const e = localStorage.getItem(Bt);
|
|
1830
1839
|
if (e) {
|
|
1831
1840
|
const c = parseFloat(e);
|
|
1832
|
-
Number.isFinite(c) && (
|
|
1841
|
+
Number.isFinite(c) && (ee.value = ut(c));
|
|
1833
1842
|
}
|
|
1834
1843
|
} catch {
|
|
1835
1844
|
}
|
|
1836
1845
|
}
|
|
1837
1846
|
function Ct(e) {
|
|
1838
1847
|
if (!S.value) return;
|
|
1839
|
-
|
|
1848
|
+
N.value = !0, x.value = !1;
|
|
1840
1849
|
const c = "touches" in e ? e.touches[0].clientX : e.clientX;
|
|
1841
|
-
b.x = c, b.width =
|
|
1850
|
+
b.x = c, b.width = ee.value;
|
|
1842
1851
|
}
|
|
1843
1852
|
function tt(e) {
|
|
1844
|
-
if (!
|
|
1853
|
+
if (!N.value) return;
|
|
1845
1854
|
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = ut(b.width + (b.x - c));
|
|
1846
|
-
Math.abs(A - b.width) > 3 && (
|
|
1847
|
-
var U,
|
|
1848
|
-
|
|
1855
|
+
Math.abs(A - b.width) > 3 && (x.value = !0), ee.value = A, M || (M = requestAnimationFrame(() => {
|
|
1856
|
+
var U, re;
|
|
1857
|
+
M = 0, (re = (U = i.dock) == null ? void 0 : U.onDockWidthChange) == null || re.call(U, ee.value);
|
|
1849
1858
|
}));
|
|
1850
1859
|
}
|
|
1851
1860
|
function nt() {
|
|
1852
1861
|
var e, c;
|
|
1853
|
-
|
|
1862
|
+
N.value && (N.value = !1, x.value && (x.value = !1, an(), (c = (e = i.dock) == null ? void 0 : e.onDockWidthChange) == null || c.call(e, ee.value)));
|
|
1854
1863
|
}
|
|
1855
1864
|
function _t() {
|
|
1856
1865
|
var e, c;
|
|
1857
|
-
S.value && (
|
|
1866
|
+
S.value && (T.value ? Ue(Le, window.innerHeight - 78) : Ke(), He(et(), Oe()), S.value = !1, yt(), (c = (e = i.dock) == null ? void 0 : e.onDockChange) == null || c.call(e, !1));
|
|
1858
1867
|
}
|
|
1859
1868
|
function un() {
|
|
1860
1869
|
var e, c;
|
|
1861
|
-
if (!
|
|
1870
|
+
if (!P.value && !te.value) {
|
|
1862
1871
|
if (S.value) {
|
|
1863
1872
|
He(
|
|
1864
|
-
{ x: window.innerWidth, y: 0, w:
|
|
1873
|
+
{ x: window.innerWidth, y: 0, w: ee.value, h: window.innerHeight, radius: "0px" },
|
|
1865
1874
|
et(),
|
|
1866
1875
|
void 0,
|
|
1867
1876
|
"in"
|
|
@@ -1878,7 +1887,7 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1878
1887
|
l.value = "idle";
|
|
1879
1888
|
}, 400);
|
|
1880
1889
|
} else
|
|
1881
|
-
|
|
1890
|
+
P.value = !1;
|
|
1882
1891
|
}
|
|
1883
1892
|
function Oe() {
|
|
1884
1893
|
if (window.innerWidth < 768)
|
|
@@ -1912,7 +1921,7 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1912
1921
|
function bt() {
|
|
1913
1922
|
const e = Le, c = window.innerHeight - 78;
|
|
1914
1923
|
let A = 54, U;
|
|
1915
|
-
return
|
|
1924
|
+
return T.value ? (U = Math.min(Math.max(D.x, he), Math.max(he, window.innerWidth - e - he)), A = Math.min(Math.max(D.y, Fe), Math.max(he, c - he))) : U = n.value === "left" ? 24 : window.innerWidth - e - 24, { x: U, y: A, w: e, h: c, radius: "14px" };
|
|
1916
1925
|
}
|
|
1917
1926
|
function rn() {
|
|
1918
1927
|
var c, A;
|
|
@@ -1939,36 +1948,36 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
1939
1948
|
function cn(e) {
|
|
1940
1949
|
Be(), k.value = "answer", me(() => {
|
|
1941
1950
|
var c;
|
|
1942
|
-
(c =
|
|
1951
|
+
(c = Q.value) == null || c.goHistoryMessage(e);
|
|
1943
1952
|
});
|
|
1944
1953
|
}
|
|
1945
1954
|
function vn() {
|
|
1946
|
-
|
|
1955
|
+
X.value = "", k.value = "answer", me(() => {
|
|
1947
1956
|
var e;
|
|
1948
|
-
(e =
|
|
1957
|
+
(e = Q.value) == null || e.createNewConversation();
|
|
1949
1958
|
});
|
|
1950
1959
|
}
|
|
1951
1960
|
function dn() {
|
|
1952
|
-
Be(),
|
|
1961
|
+
Be(), X.value = "", me(() => {
|
|
1953
1962
|
var e;
|
|
1954
|
-
(e =
|
|
1963
|
+
(e = Q.value) == null || e.createNewConversation();
|
|
1955
1964
|
});
|
|
1956
1965
|
}
|
|
1957
1966
|
function hn() {
|
|
1958
|
-
|
|
1967
|
+
G.value = !1, K.value = !0;
|
|
1959
1968
|
}
|
|
1960
1969
|
function Be() {
|
|
1961
|
-
|
|
1962
|
-
K.value = !1,
|
|
1970
|
+
G.value = !0, setTimeout(() => {
|
|
1971
|
+
K.value = !1, G.value = !1;
|
|
1963
1972
|
}, 300);
|
|
1964
1973
|
}
|
|
1965
1974
|
function pn() {
|
|
1966
|
-
|
|
1975
|
+
R.value = p.value, V.value = !1;
|
|
1967
1976
|
}
|
|
1968
|
-
|
|
1977
|
+
ve(f, (e) => {
|
|
1969
1978
|
e ? n.value = "center" : Ke();
|
|
1970
|
-
}),
|
|
1971
|
-
e &&
|
|
1979
|
+
}), ve(u, (e) => {
|
|
1980
|
+
e && T.value && me(() => Ue());
|
|
1972
1981
|
});
|
|
1973
1982
|
const mn = Math.max(1e3, Number(i.activityInterval) || 3e4);
|
|
1974
1983
|
let ot = null, We = 0, st = 0, at = 0;
|
|
@@ -2006,31 +2015,31 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2006
2015
|
function Et() {
|
|
2007
2016
|
!u.value || document.visibilityState === "hidden" || (We = Date.now(), rt());
|
|
2008
2017
|
}
|
|
2009
|
-
|
|
2018
|
+
ve(u, (e) => {
|
|
2010
2019
|
e ? (Ye("open"), document.visibilityState !== "hidden" && rt()) : (Ne(), Ye("close"));
|
|
2011
|
-
}),
|
|
2020
|
+
}), be(() => {
|
|
2012
2021
|
document.addEventListener("visibilitychange", At), window.addEventListener("pagehide", St), window.addEventListener("pageshow", Et);
|
|
2013
2022
|
}), Pe(() => {
|
|
2014
2023
|
Ne(), document.removeEventListener("visibilitychange", At), window.removeEventListener("pagehide", St), window.removeEventListener("pageshow", Et);
|
|
2015
|
-
}),
|
|
2024
|
+
}), be(() => {
|
|
2016
2025
|
Ut(), en(), tn(), ln();
|
|
2017
2026
|
const e = i.theme || "light";
|
|
2018
|
-
ht(e), e === "auto" && (
|
|
2027
|
+
ht(e), e === "auto" && (ue = $n(() => ht("auto"))), ge = Jn(() => C.value);
|
|
2019
2028
|
});
|
|
2020
2029
|
function Tt() {
|
|
2021
|
-
|
|
2030
|
+
I && clearTimeout(I), I = setTimeout(() => {
|
|
2022
2031
|
const e = window.innerWidth < 768;
|
|
2023
|
-
r.value = e, e && (f.value = !0, S.value && _t()), pt(),
|
|
2032
|
+
r.value = e, e && (f.value = !0, S.value && _t()), pt(), T.value && Ue(), S.value && (ee.value = ut(ee.value));
|
|
2024
2033
|
}, 100);
|
|
2025
2034
|
}
|
|
2026
|
-
return
|
|
2035
|
+
return be(() => {
|
|
2027
2036
|
window.addEventListener("resize", Tt);
|
|
2028
2037
|
}), Pe(() => {
|
|
2029
|
-
window.removeEventListener("resize", Tt),
|
|
2030
|
-
}),
|
|
2038
|
+
window.removeEventListener("resize", Tt), I && clearTimeout(I), ue == null || ue(), ge == null || ge(), ge = null;
|
|
2039
|
+
}), be(() => {
|
|
2031
2040
|
document.addEventListener("mousemove", Ge), document.addEventListener("touchmove", Ge, { passive: !0 }), document.addEventListener("mouseup", je), document.addEventListener("touchend", je), document.addEventListener("mousemove", Ze), document.addEventListener("touchmove", Ze, { passive: !0 }), document.addEventListener("mouseup", Ie), document.addEventListener("touchend", Ie), document.addEventListener("click", gt, !0), document.addEventListener("mousemove", tt), document.addEventListener("touchmove", tt, { passive: !0 }), document.addEventListener("mouseup", nt), document.addEventListener("touchend", nt);
|
|
2032
2041
|
}), Pe(() => {
|
|
2033
|
-
document.removeEventListener("mousemove", Ge), document.removeEventListener("touchmove", Ge), document.removeEventListener("mouseup", je), document.removeEventListener("touchend", je), document.removeEventListener("mousemove", Ze), document.removeEventListener("touchmove", Ze), document.removeEventListener("mouseup", Ie), document.removeEventListener("touchend", Ie), document.removeEventListener("click", gt, !0), document.removeEventListener("mousemove", tt), document.removeEventListener("touchmove", tt), document.removeEventListener("mouseup", nt), document.removeEventListener("touchend", nt), oe && clearTimeout(oe),
|
|
2042
|
+
document.removeEventListener("mousemove", Ge), document.removeEventListener("touchmove", Ge), document.removeEventListener("mouseup", je), document.removeEventListener("touchend", je), document.removeEventListener("mousemove", Ze), document.removeEventListener("touchmove", Ze), document.removeEventListener("mouseup", Ie), document.removeEventListener("touchend", Ie), document.removeEventListener("click", gt, !0), document.removeEventListener("mousemove", tt), document.removeEventListener("touchmove", tt), document.removeEventListener("mouseup", nt), document.removeEventListener("touchend", nt), oe && clearTimeout(oe), M && cancelAnimationFrame(M);
|
|
2034
2043
|
}), (e, c) => (v(), m("div", null, [
|
|
2035
2044
|
Me(o("div", {
|
|
2036
2045
|
ref_key: "panelRef",
|
|
@@ -2040,16 +2049,16 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2040
2049
|
f.value ? "maxWrap" : "minWrap",
|
|
2041
2050
|
Z.value,
|
|
2042
2051
|
{
|
|
2043
|
-
"panel-custom":
|
|
2052
|
+
"panel-custom": T.value && !f.value && !r.value && !S.value && $.value === "idle",
|
|
2044
2053
|
dragging: W.value,
|
|
2045
|
-
"dock-preview":
|
|
2054
|
+
"dock-preview": q.value,
|
|
2046
2055
|
docked: S.value,
|
|
2047
|
-
"dock-resizing":
|
|
2048
|
-
"dock-switching":
|
|
2056
|
+
"dock-resizing": N.value,
|
|
2057
|
+
"dock-switching": $.value !== "idle",
|
|
2049
2058
|
"dock-switch-instant": Y.value,
|
|
2050
2059
|
"dock-switch-fade-in": H.value === "in",
|
|
2051
2060
|
"dock-switch-fade-out": H.value === "out",
|
|
2052
|
-
"no-drag": !
|
|
2061
|
+
"no-drag": !Ce.value
|
|
2053
2062
|
},
|
|
2054
2063
|
l.value !== "idle" ? l.value : "",
|
|
2055
2064
|
{ morphing: l.value !== "idle", "morph-instant": h.value }
|
|
@@ -2061,7 +2070,7 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2061
2070
|
class: "ai-dock-resizer",
|
|
2062
2071
|
onMousedown: fe(Ct, ["stop"]),
|
|
2063
2072
|
onTouchstart: fe(Ct, ["stop"])
|
|
2064
|
-
}, null, 32)) :
|
|
2073
|
+
}, null, 32)) : J("", !0),
|
|
2065
2074
|
o("div", {
|
|
2066
2075
|
class: "header",
|
|
2067
2076
|
onMousedown: ft,
|
|
@@ -2069,159 +2078,159 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2069
2078
|
}, [
|
|
2070
2079
|
k.value === "info" ? (v(), m("span", {
|
|
2071
2080
|
key: 0,
|
|
2072
|
-
class: se(["back",
|
|
2081
|
+
class: se(["back", d.value]),
|
|
2073
2082
|
onClick: c[0] || (c[0] = (A) => k.value = "answer")
|
|
2074
2083
|
}, [...c[5] || (c[5] = [
|
|
2075
2084
|
o("span", { style: { "font-size": "14px" } }, "←", -1)
|
|
2076
|
-
])], 2)) : (v(), m("p",
|
|
2085
|
+
])], 2)) : (v(), m("p", Ys, [
|
|
2077
2086
|
o("img", {
|
|
2078
|
-
src:
|
|
2087
|
+
src: O(Qt),
|
|
2079
2088
|
draggable: "false"
|
|
2080
|
-
}, null, 8,
|
|
2089
|
+
}, null, 8, Ns)
|
|
2081
2090
|
])),
|
|
2082
|
-
o("div",
|
|
2091
|
+
o("div", Vs, [
|
|
2083
2092
|
o("span", {
|
|
2084
|
-
title: k.value === "info" ? "个人信息" :
|
|
2085
|
-
},
|
|
2093
|
+
title: k.value === "info" ? "个人信息" : X.value || O(i).name
|
|
2094
|
+
}, z(k.value === "info" ? "个人信息" : X.value || O(i).name), 9, Xs)
|
|
2086
2095
|
]),
|
|
2087
2096
|
o("p", null, [
|
|
2088
|
-
Me(ie(
|
|
2097
|
+
Me(ie(O(ce), {
|
|
2089
2098
|
class: "op-icon",
|
|
2090
2099
|
icon: "ic:round-add",
|
|
2091
2100
|
onClick: vn
|
|
2092
2101
|
}, null, 512), [
|
|
2093
2102
|
[Ve, Re.value]
|
|
2094
2103
|
]),
|
|
2095
|
-
ie(
|
|
2104
|
+
ie(O(ce), {
|
|
2096
2105
|
class: se(["mute", { active: K.value }]),
|
|
2097
2106
|
icon: "ic:round-history",
|
|
2098
2107
|
onClick: c[1] || (c[1] = (A) => K.value ? Be() : hn())
|
|
2099
2108
|
}, null, 8, ["class"]),
|
|
2100
|
-
!r.value && !S.value ? (v(), pe(
|
|
2109
|
+
!r.value && !S.value ? (v(), pe(O(ce), {
|
|
2101
2110
|
key: 0,
|
|
2102
2111
|
onClick: on,
|
|
2103
2112
|
icon: f.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
|
|
2104
|
-
}, null, 8, ["icon"])) :
|
|
2105
|
-
S.value ? (v(), pe(
|
|
2113
|
+
}, null, 8, ["icon"])) : J("", !0),
|
|
2114
|
+
S.value ? (v(), pe(O(ce), {
|
|
2106
2115
|
key: 1,
|
|
2107
2116
|
icon: "material-symbols:float-landscape-2-outline-rounded",
|
|
2108
2117
|
onClick: _t
|
|
2109
|
-
})) :
|
|
2110
|
-
ae.value && !S.value ? (v(), pe(
|
|
2118
|
+
})) : J("", !0),
|
|
2119
|
+
ae.value && !S.value ? (v(), pe(O(ce), {
|
|
2111
2120
|
key: 2,
|
|
2112
2121
|
icon: "boxicons:arrow-in-up-right-stroke-square",
|
|
2113
2122
|
onClick: kt,
|
|
2114
2123
|
class: "__minimize"
|
|
2115
|
-
})) :
|
|
2116
|
-
ie(
|
|
2124
|
+
})) : J("", !0),
|
|
2125
|
+
ie(O(ce), {
|
|
2117
2126
|
onClick: rn,
|
|
2118
2127
|
icon: "ic:round-close"
|
|
2119
2128
|
})
|
|
2120
2129
|
])
|
|
2121
2130
|
], 32),
|
|
2122
|
-
Me(ie(
|
|
2131
|
+
Me(ie(ds, {
|
|
2123
2132
|
ref_key: "answerRef",
|
|
2124
|
-
ref:
|
|
2125
|
-
defaultSayhello:
|
|
2126
|
-
defaultRecommend:
|
|
2127
|
-
onTitleGenerated: c[2] || (c[2] = (A) =>
|
|
2133
|
+
ref: Q,
|
|
2134
|
+
defaultSayhello: O(i).defaultSayhello,
|
|
2135
|
+
defaultRecommend: O(i).defaultRecommend,
|
|
2136
|
+
onTitleGenerated: c[2] || (c[2] = (A) => X.value = A)
|
|
2128
2137
|
}, null, 8, ["defaultSayhello", "defaultRecommend"]), [
|
|
2129
2138
|
[Ve, k.value === "answer"]
|
|
2130
2139
|
]),
|
|
2131
|
-
k.value === "info" ? (v(), pe(
|
|
2140
|
+
k.value === "info" ? (v(), pe(Ws, { key: 1 })) : J("", !0),
|
|
2132
2141
|
K.value ? (v(), m("div", {
|
|
2133
2142
|
key: 2,
|
|
2134
|
-
class: se(["ai-history-drawer", { closing:
|
|
2143
|
+
class: se(["ai-history-drawer", { closing: G.value }])
|
|
2135
2144
|
}, [
|
|
2136
2145
|
o("div", {
|
|
2137
2146
|
class: "ai-history-backdrop",
|
|
2138
2147
|
onClick: Be
|
|
2139
2148
|
}),
|
|
2140
|
-
o("div",
|
|
2141
|
-
o("div",
|
|
2149
|
+
o("div", Fs, [
|
|
2150
|
+
o("div", Qs, [
|
|
2142
2151
|
c[6] || (c[6] = o("span", null, "对话记录", -1)),
|
|
2143
|
-
ie(
|
|
2152
|
+
ie(O(ce), {
|
|
2144
2153
|
icon: "ic:round-close",
|
|
2145
2154
|
class: "ai-history-drawer-close",
|
|
2146
2155
|
onClick: Be
|
|
2147
2156
|
})
|
|
2148
2157
|
]),
|
|
2149
|
-
ie(
|
|
2158
|
+
ie(As, {
|
|
2150
2159
|
onHistoryDetail: cn,
|
|
2151
2160
|
onNewConversation: dn
|
|
2152
2161
|
})
|
|
2153
2162
|
])
|
|
2154
|
-
], 2)) :
|
|
2155
|
-
Me(o("div",
|
|
2156
|
-
o("div",
|
|
2157
|
-
o("div",
|
|
2163
|
+
], 2)) : J("", !0),
|
|
2164
|
+
Me(o("div", Js, [
|
|
2165
|
+
o("div", qs, [
|
|
2166
|
+
o("div", zs, [
|
|
2158
2167
|
c[7] || (c[7] = o("p", { class: "title" }, "修改标题", -1)),
|
|
2159
2168
|
Me(o("textarea", {
|
|
2160
|
-
"onUpdate:modelValue": c[3] || (c[3] = (A) =>
|
|
2169
|
+
"onUpdate:modelValue": c[3] || (c[3] = (A) => p.value = A),
|
|
2161
2170
|
placeholder: "请输入新标题"
|
|
2162
2171
|
}, null, 512), [
|
|
2163
|
-
[Vt,
|
|
2172
|
+
[Vt, p.value]
|
|
2164
2173
|
]),
|
|
2165
|
-
o("p",
|
|
2174
|
+
o("p", Ks, [
|
|
2166
2175
|
o("span", {
|
|
2167
|
-
onClick: c[4] || (c[4] = (A) =>
|
|
2176
|
+
onClick: c[4] || (c[4] = (A) => V.value = !1)
|
|
2168
2177
|
}, "取消"),
|
|
2169
2178
|
o("span", { onClick: pn }, "确定")
|
|
2170
2179
|
])
|
|
2171
2180
|
])
|
|
2172
2181
|
])
|
|
2173
2182
|
], 512), [
|
|
2174
|
-
[Ve,
|
|
2183
|
+
[Ve, V.value]
|
|
2175
2184
|
])
|
|
2176
2185
|
], 6), [
|
|
2177
2186
|
[Ve, u.value || l.value !== "idle"]
|
|
2178
2187
|
]),
|
|
2179
|
-
|
|
2188
|
+
q.value && ae.value ? (v(), m("div", {
|
|
2180
2189
|
key: 0,
|
|
2181
2190
|
class: "ai-dock-preview",
|
|
2182
|
-
style: it({ width:
|
|
2191
|
+
style: it({ width: ee.value + "px" })
|
|
2183
2192
|
}, [...c[8] || (c[8] = [
|
|
2184
2193
|
o("span", { class: "ai-dock-preview__text" }, "松开以停靠到右侧", -1)
|
|
2185
|
-
])], 4)) :
|
|
2194
|
+
])], 4)) : J("", !0),
|
|
2186
2195
|
Me(o("div", {
|
|
2187
|
-
class: se(["character", { dragging:
|
|
2196
|
+
class: se(["character", { dragging: E.value, recycling: te.value, "hover-preview": a.value }]),
|
|
2188
2197
|
style: it(ze.value),
|
|
2189
2198
|
onMousedown: mt,
|
|
2190
2199
|
onTouchstart: mt,
|
|
2191
2200
|
onClick: un
|
|
2192
2201
|
}, [
|
|
2193
|
-
o("img", { src: lt.value }, null, 8,
|
|
2202
|
+
o("img", { src: lt.value }, null, 8, Gs)
|
|
2194
2203
|
], 38), [
|
|
2195
2204
|
[Ve, !u.value]
|
|
2196
2205
|
])
|
|
2197
2206
|
]));
|
|
2198
2207
|
}
|
|
2199
|
-
}),
|
|
2208
|
+
}), ea = ["data-theme"], ta = {
|
|
2200
2209
|
key: 0,
|
|
2201
2210
|
class: "ai-voice-input-final"
|
|
2202
|
-
},
|
|
2211
|
+
}, na = {
|
|
2203
2212
|
key: 1,
|
|
2204
2213
|
class: "ai-voice-input-interim"
|
|
2205
|
-
},
|
|
2214
|
+
}, oa = {
|
|
2206
2215
|
key: 2,
|
|
2207
2216
|
class: "ai-voice-input-cursor"
|
|
2208
|
-
},
|
|
2217
|
+
}, sa = {
|
|
2209
2218
|
key: 3,
|
|
2210
2219
|
class: "ai-voice-input-placeholder"
|
|
2211
|
-
},
|
|
2220
|
+
}, aa = ["disabled"], ia = {
|
|
2212
2221
|
key: 0,
|
|
2213
2222
|
class: "ai-voice-input-pulse"
|
|
2214
|
-
},
|
|
2223
|
+
}, la = {
|
|
2215
2224
|
key: 1,
|
|
2216
2225
|
class: "ai-voice-input-wave"
|
|
2217
|
-
},
|
|
2226
|
+
}, ua = {
|
|
2218
2227
|
key: 2,
|
|
2219
2228
|
class: "ai-voice-input-btn-icon",
|
|
2220
2229
|
viewBox: "0 0 24 24",
|
|
2221
2230
|
fill: "currentColor",
|
|
2222
2231
|
width: "16",
|
|
2223
2232
|
height: "16"
|
|
2224
|
-
},
|
|
2233
|
+
}, ra = /* @__PURE__ */ Ee({
|
|
2225
2234
|
__name: "VoiceInput",
|
|
2226
2235
|
props: {
|
|
2227
2236
|
lang: {},
|
|
@@ -2245,34 +2254,34 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2245
2254
|
error: "重试"
|
|
2246
2255
|
}, s = g(""), a = g(""), r = g("idle"), f = Qe.isSupported();
|
|
2247
2256
|
let k = null;
|
|
2248
|
-
const
|
|
2257
|
+
const V = B(() => Ln(u.theme)), p = () => ({
|
|
2249
2258
|
lang: u.lang,
|
|
2250
2259
|
continuous: u.continuous,
|
|
2251
2260
|
interimResults: u.interimResults
|
|
2252
|
-
}),
|
|
2253
|
-
f && (k = new Qe(
|
|
2254
|
-
onStatusChange: (
|
|
2255
|
-
r.value =
|
|
2261
|
+
}), R = () => {
|
|
2262
|
+
f && (k = new Qe(p(), {
|
|
2263
|
+
onStatusChange: (d) => {
|
|
2264
|
+
r.value = d, l("statusChange", d), d === "idle" && l("complete", s.value);
|
|
2256
2265
|
},
|
|
2257
|
-
onInterim: (
|
|
2258
|
-
a.value =
|
|
2266
|
+
onInterim: (d) => {
|
|
2267
|
+
a.value = d;
|
|
2259
2268
|
},
|
|
2260
|
-
onFinal: (
|
|
2261
|
-
s.value +=
|
|
2269
|
+
onFinal: (d, C) => {
|
|
2270
|
+
s.value += d, a.value = "", l("final", d, C);
|
|
2262
2271
|
},
|
|
2263
|
-
onResult: (
|
|
2264
|
-
onError: (
|
|
2272
|
+
onResult: (d) => l("result", d),
|
|
2273
|
+
onError: (d) => l("error", d)
|
|
2265
2274
|
}));
|
|
2266
2275
|
};
|
|
2267
|
-
|
|
2276
|
+
be(R), Nt(() => {
|
|
2268
2277
|
k == null || k.destroy(), k = null;
|
|
2269
|
-
}),
|
|
2278
|
+
}), ve(
|
|
2270
2279
|
() => [u.lang, u.continuous, u.interimResults],
|
|
2271
2280
|
() => {
|
|
2272
|
-
k == null || k.destroy(),
|
|
2281
|
+
k == null || k.destroy(), R();
|
|
2273
2282
|
}
|
|
2274
2283
|
);
|
|
2275
|
-
const
|
|
2284
|
+
const X = async () => {
|
|
2276
2285
|
if (k)
|
|
2277
2286
|
if (r.value === "idle" || r.value === "error")
|
|
2278
2287
|
try {
|
|
@@ -2282,12 +2291,12 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2282
2291
|
else r.value === "recording" && k.stop();
|
|
2283
2292
|
}, K = () => {
|
|
2284
2293
|
s.value = "", a.value = "";
|
|
2285
|
-
},
|
|
2294
|
+
}, G = B(() => !s.value && !a.value), _ = B(
|
|
2286
2295
|
() => f ? u.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
|
|
2287
|
-
),
|
|
2288
|
-
const
|
|
2289
|
-
return r.value === "recording" &&
|
|
2290
|
-
}), n =
|
|
2296
|
+
), E = B(() => f ? r.value === "connecting" ? u.connectingText || h.connecting : r.value === "recording" ? u.stopText || h.recording : r.value === "stopping" ? u.stoppingText || h.stopping : r.value === "error" ? h.error : u.startText || h.idle : "不支持"), te = B(() => {
|
|
2297
|
+
const d = ["ai-voice-input-btn"];
|
|
2298
|
+
return r.value === "recording" && d.push("is-recording"), r.value === "connecting" && d.push("is-connecting"), r.value === "stopping" && d.push("is-stopping"), d.join(" ");
|
|
2299
|
+
}), n = B(
|
|
2291
2300
|
() => !f || r.value === "connecting" || r.value === "stopping"
|
|
2292
2301
|
);
|
|
2293
2302
|
return w({
|
|
@@ -2301,73 +2310,73 @@ const ts = { class: "container" }, ns = { class: "chat-wrap" }, os = { class: "m
|
|
|
2301
2310
|
s.value = "", a.value = "";
|
|
2302
2311
|
},
|
|
2303
2312
|
getStatus: () => (k == null ? void 0 : k.getStatus()) ?? "idle"
|
|
2304
|
-
}), (
|
|
2313
|
+
}), (d, C) => (v(), m("div", {
|
|
2305
2314
|
class: se(["ai-voice-input", t.className]),
|
|
2306
|
-
"data-theme":
|
|
2315
|
+
"data-theme": V.value
|
|
2307
2316
|
}, [
|
|
2308
2317
|
o("div", {
|
|
2309
|
-
class: se(["ai-voice-input-display", { "is-empty":
|
|
2318
|
+
class: se(["ai-voice-input-display", { "is-empty": G.value }])
|
|
2310
2319
|
}, [
|
|
2311
|
-
s.value ? (v(), m("span",
|
|
2312
|
-
a.value ? (v(), m("span",
|
|
2313
|
-
r.value === "recording" && !a.value ? (v(), m("span",
|
|
2314
|
-
|
|
2320
|
+
s.value ? (v(), m("span", ta, z(s.value), 1)) : J("", !0),
|
|
2321
|
+
a.value ? (v(), m("span", na, z(a.value), 1)) : J("", !0),
|
|
2322
|
+
r.value === "recording" && !a.value ? (v(), m("span", oa)) : J("", !0),
|
|
2323
|
+
G.value ? (v(), m("span", sa, z(_.value), 1)) : J("", !0)
|
|
2315
2324
|
], 2),
|
|
2316
2325
|
o("button", {
|
|
2317
2326
|
type: "button",
|
|
2318
|
-
class: se(
|
|
2327
|
+
class: se(te.value),
|
|
2319
2328
|
disabled: n.value,
|
|
2320
|
-
onClick:
|
|
2329
|
+
onClick: X
|
|
2321
2330
|
}, [
|
|
2322
|
-
r.value === "recording" ? (v(), m("span",
|
|
2331
|
+
r.value === "recording" ? (v(), m("span", ia)) : r.value === "connecting" || r.value === "stopping" ? (v(), m("span", la, [...C[0] || (C[0] = [
|
|
2323
2332
|
o("span", null, null, -1),
|
|
2324
2333
|
o("span", null, null, -1),
|
|
2325
2334
|
o("span", null, null, -1),
|
|
2326
2335
|
o("span", null, null, -1),
|
|
2327
2336
|
o("span", null, null, -1)
|
|
2328
|
-
])])) : (v(), m("svg",
|
|
2337
|
+
])])) : (v(), m("svg", ua, [...C[1] || (C[1] = [
|
|
2329
2338
|
o("path", { d: "M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3z" }, null, -1),
|
|
2330
2339
|
o("path", { d: "M19 11a7 7 0 0 1-14 0H3a9 9 0 0 0 8 8.94V23h2v-3.06A9 9 0 0 0 21 11h-2z" }, null, -1)
|
|
2331
2340
|
])])),
|
|
2332
|
-
o("span", null,
|
|
2333
|
-
], 10,
|
|
2334
|
-
|
|
2341
|
+
o("span", null, z(E.value), 1)
|
|
2342
|
+
], 10, aa),
|
|
2343
|
+
G.value ? J("", !0) : (v(), m("button", {
|
|
2335
2344
|
key: 0,
|
|
2336
2345
|
type: "button",
|
|
2337
2346
|
class: "ai-voice-input-btn ai-voice-input-clear-btn",
|
|
2338
2347
|
title: "清空",
|
|
2339
2348
|
onClick: K
|
|
2340
2349
|
}, " 清空 "))
|
|
2341
|
-
], 10,
|
|
2350
|
+
], 10, ea));
|
|
2342
2351
|
}
|
|
2343
|
-
}),
|
|
2352
|
+
}), ca = (t, w) => {
|
|
2344
2353
|
const i = t.__vccOpts || t;
|
|
2345
2354
|
for (const [u, l] of w)
|
|
2346
2355
|
i[u] = l;
|
|
2347
2356
|
return i;
|
|
2348
|
-
},
|
|
2357
|
+
}, va = /* @__PURE__ */ ca(ra, [["__scopeId", "data-v-53d3cc6e"]]);
|
|
2349
2358
|
let Je = null;
|
|
2350
|
-
const
|
|
2359
|
+
const ga = (t) => {
|
|
2351
2360
|
Ft(t);
|
|
2352
|
-
},
|
|
2361
|
+
}, ya = (t) => {
|
|
2353
2362
|
const w = t || document.body, i = document.createElement("div");
|
|
2354
2363
|
i.id = "ai-assist-root";
|
|
2355
2364
|
const u = qe();
|
|
2356
2365
|
ht(u.theme), Pn(), w.appendChild(i), Je = Cn(Jt), Je.mount(i);
|
|
2357
|
-
},
|
|
2366
|
+
}, wa = () => {
|
|
2358
2367
|
Je && (Je.unmount(), Je = null);
|
|
2359
2368
|
const t = document.getElementById("ai-assist-root");
|
|
2360
2369
|
t && t.remove();
|
|
2361
|
-
},
|
|
2370
|
+
}, ka = {
|
|
2362
2371
|
install(t, w) {
|
|
2363
|
-
Ft(w), t.component("AiAssist", Jt), t.component("VoiceInput",
|
|
2372
|
+
Ft(w), t.component("AiAssist", Jt), t.component("VoiceInput", va);
|
|
2364
2373
|
}
|
|
2365
2374
|
};
|
|
2366
2375
|
export {
|
|
2367
2376
|
Jt as AiAssist,
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2377
|
+
va as VoiceInput,
|
|
2378
|
+
ka as default,
|
|
2379
|
+
ga as initAiAssist,
|
|
2380
|
+
ya as mountAiAssist,
|
|
2381
|
+
wa as unmountAiAssist
|
|
2373
2382
|
};
|