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