@somecat/ai-assist-sdk 2.0.0 → 2.0.1
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/core/types/index.d.ts +6 -0
- package/dist/vue/index.mjs +1688 -1642
- package/package.json +1 -1
package/dist/vue/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { a as
|
|
1
|
+
import { defineComponent as $e, computed as S, openBlock as i, createElementBlock as h, createElementVNode as o, ref as _, watch as ge, nextTick as Se, onUnmounted as Be, normalizeClass as me, toDisplayString as te, createVNode as ke, Transition as Un, withCtx as es, unref as ie, createCommentVNode as z, Fragment as Ce, renderList as Ae, createTextVNode as fn, onMounted as Pe, onBeforeUnmount as Lt, reactive as He, createBlock as we, createStaticVNode as ts, withModifiers as Le, Teleport as mn, withDirectives as qe, withKeys as St, vModelText as gn, shallowRef as ns, normalizeStyle as kt, vShow as nt, createApp as ss } from "vue";
|
|
2
|
+
import { a as pn, r as Et, p as At, g as Ve, i as yn, s as Tt, u as as, V as ot, c as os, b as en, d as is, o as ls, e as We, f as Rt, h as rs, j as tn, k as nn, l as Ct, m as xt, n as _t, q as us, t as cs, v as ds, w as lt, x as sn, y as vs, z as hs, A as fs, B as ms, C as gs, D as ps, E as an, F as Pt, G as ys, H as on, I as ws, J as ln, K as ks, L as _s, M as wn, N as Cs, O as bs, P as kn } from "../chunks/engine-Cu-2TgJb.mjs";
|
|
3
3
|
import { Q as Ui, R as el, S as tl, T as nl, U as sl } from "../chunks/engine-Cu-2TgJb.mjs";
|
|
4
|
-
import { t as
|
|
5
|
-
import { SearchOutlined as
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
4
|
+
import { t as Dt, r as Ms, f as $s, i as Ss, s as Ts, a as xs, S as Ds, b as Es, c as Fe, d as As, e as _n, g as Rs, h as Ps, m as Ls } from "../chunks/index-BIUOuQxJ.mjs";
|
|
5
|
+
import { SearchOutlined as Cn, BulbOutlined as Hs, CheckOutlined as Ns, CopyOutlined as Vs, RedoOutlined as Os, CloseOutlined as Ws } from "@ant-design/icons-vue";
|
|
6
|
+
import { p as Bs, e as rn } from "../chunks/index-DNWBsXlO.mjs";
|
|
7
|
+
const un = {
|
|
8
8
|
add: {
|
|
9
9
|
body: '<path fill="currentColor" d="M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"/>',
|
|
10
10
|
width: 24,
|
|
@@ -70,17 +70,17 @@ const ln = {
|
|
|
70
70
|
width: 20,
|
|
71
71
|
height: 20
|
|
72
72
|
}
|
|
73
|
-
}, Fs = ["viewBox"],
|
|
73
|
+
}, Fs = ["viewBox"], Is = ["transform", "innerHTML"], Xs = /* @__PURE__ */ $e({
|
|
74
74
|
__name: "SdkIcon",
|
|
75
75
|
props: {
|
|
76
76
|
name: {}
|
|
77
77
|
},
|
|
78
78
|
setup(t) {
|
|
79
|
-
const w = t, e = S(() =>
|
|
80
|
-
const { left: a = 0, top:
|
|
81
|
-
return a ||
|
|
79
|
+
const w = t, e = S(() => un[w.name] || un.close), v = S(() => {
|
|
80
|
+
const { left: a = 0, top: f = 0 } = e.value;
|
|
81
|
+
return a || f ? `translate(${a} ${f})` : void 0;
|
|
82
82
|
});
|
|
83
|
-
return (a,
|
|
83
|
+
return (a, f) => (i(), h("svg", {
|
|
84
84
|
class: "sdk-icon",
|
|
85
85
|
viewBox: `0 0 ${e.value.width} ${e.value.height}`,
|
|
86
86
|
width: "1em",
|
|
@@ -90,17 +90,17 @@ const ln = {
|
|
|
90
90
|
focusable: "false"
|
|
91
91
|
}, [
|
|
92
92
|
o("g", {
|
|
93
|
-
transform:
|
|
93
|
+
transform: v.value,
|
|
94
94
|
innerHTML: e.value.body
|
|
95
|
-
}, null, 8,
|
|
95
|
+
}, null, 8, Is)
|
|
96
96
|
], 8, Fs));
|
|
97
97
|
}
|
|
98
|
-
}),
|
|
98
|
+
}), bn = (t, w) => {
|
|
99
99
|
const e = t.__vccOpts || t;
|
|
100
|
-
for (const [
|
|
101
|
-
e[
|
|
100
|
+
for (const [v, a] of w)
|
|
101
|
+
e[v] = a;
|
|
102
102
|
return e;
|
|
103
|
-
},
|
|
103
|
+
}, Te = /* @__PURE__ */ bn(Xs, [["__scopeId", "data-v-632dda9c"]]), zs = { class: "thinking-block__title" }, qs = ["innerHTML"], Gs = /* @__PURE__ */ $e({
|
|
104
104
|
__name: "ThinkingBlock",
|
|
105
105
|
props: {
|
|
106
106
|
content: {},
|
|
@@ -109,66 +109,66 @@ const ln = {
|
|
|
109
109
|
},
|
|
110
110
|
setup(t) {
|
|
111
111
|
const w = t, e = _(!!w.isStreaming || !!w.messageDone);
|
|
112
|
-
let
|
|
113
|
-
function a(
|
|
114
|
-
clearTimeout(
|
|
115
|
-
|
|
116
|
-
},
|
|
112
|
+
let v = 0;
|
|
113
|
+
function a(T = 600) {
|
|
114
|
+
clearTimeout(v), v = window.setTimeout(() => {
|
|
115
|
+
v = 0, e.value = !1;
|
|
116
|
+
}, T);
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
118
|
+
function f() {
|
|
119
|
+
v && (clearTimeout(v), v = 0);
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
121
|
+
function g() {
|
|
122
|
+
f(), e.value = !e.value;
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
ge(
|
|
125
125
|
() => w.isStreaming,
|
|
126
|
-
(
|
|
127
|
-
|
|
126
|
+
(T) => {
|
|
127
|
+
T ? (f(), e.value = !0) : w.messageDone || a();
|
|
128
128
|
},
|
|
129
129
|
{ immediate: !0 }
|
|
130
|
-
),
|
|
130
|
+
), ge(
|
|
131
131
|
() => w.messageDone,
|
|
132
|
-
(
|
|
133
|
-
|
|
132
|
+
(T) => {
|
|
133
|
+
T && (f(), e.value = !0);
|
|
134
134
|
},
|
|
135
135
|
{ immediate: !0 }
|
|
136
136
|
);
|
|
137
|
-
const
|
|
138
|
-
let
|
|
137
|
+
const l = _(null);
|
|
138
|
+
let r = !1;
|
|
139
139
|
function M() {
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
142
|
-
|
|
140
|
+
const T = l.value;
|
|
141
|
+
if (!T) return;
|
|
142
|
+
r = T.scrollHeight - T.scrollTop - T.clientHeight > 12;
|
|
143
143
|
}
|
|
144
144
|
function C() {
|
|
145
|
-
const
|
|
146
|
-
!
|
|
145
|
+
const T = l.value;
|
|
146
|
+
!T || !e.value || r || (T.scrollTop = T.scrollHeight);
|
|
147
147
|
}
|
|
148
148
|
function E() {
|
|
149
149
|
w.isStreaming && C();
|
|
150
150
|
}
|
|
151
|
-
return
|
|
151
|
+
return ge(
|
|
152
152
|
() => w.content,
|
|
153
153
|
() => {
|
|
154
|
-
w.isStreaming &&
|
|
154
|
+
w.isStreaming && Se(C);
|
|
155
155
|
}
|
|
156
|
-
),
|
|
157
|
-
|
|
158
|
-
}), (
|
|
159
|
-
class:
|
|
156
|
+
), Be(() => {
|
|
157
|
+
f();
|
|
158
|
+
}), (T, I) => (i(), h("div", {
|
|
159
|
+
class: me(["thinking-block", {
|
|
160
160
|
"thinking-block--expanded": e.value,
|
|
161
161
|
"thinking-block--active": t.isStreaming
|
|
162
162
|
}])
|
|
163
163
|
}, [
|
|
164
164
|
o("div", {
|
|
165
165
|
class: "thinking-block__header",
|
|
166
|
-
onClick:
|
|
166
|
+
onClick: g
|
|
167
167
|
}, [
|
|
168
168
|
I[1] || (I[1] = o("span", { class: "thinking-block__indicator" }, null, -1)),
|
|
169
|
-
o("span",
|
|
170
|
-
(i(),
|
|
171
|
-
class:
|
|
169
|
+
o("span", zs, te(t.isStreaming ? "深度思考中" : "深度思考"), 1),
|
|
170
|
+
(i(), h("svg", {
|
|
171
|
+
class: me(["thinking-block__arrow", { "thinking-block__arrow--down": e.value }]),
|
|
172
172
|
viewBox: "0 0 24 24",
|
|
173
173
|
width: "14",
|
|
174
174
|
height: "14",
|
|
@@ -181,23 +181,23 @@ const ln = {
|
|
|
181
181
|
o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
|
|
182
182
|
])], 2))
|
|
183
183
|
]),
|
|
184
|
-
|
|
184
|
+
ke(Un, {
|
|
185
185
|
name: "thinking-expand",
|
|
186
186
|
onAfterEnter: E
|
|
187
187
|
}, {
|
|
188
|
-
default:
|
|
189
|
-
e.value ? (i(),
|
|
188
|
+
default: es(() => [
|
|
189
|
+
e.value ? (i(), h("div", {
|
|
190
190
|
key: 0,
|
|
191
191
|
ref_key: "contentRef",
|
|
192
|
-
ref:
|
|
192
|
+
ref: l,
|
|
193
193
|
class: "thinking-block__content",
|
|
194
194
|
onScroll: M
|
|
195
195
|
}, [
|
|
196
196
|
o("div", {
|
|
197
197
|
class: "thinking-block__markdown",
|
|
198
|
-
innerHTML:
|
|
198
|
+
innerHTML: ie(pn)(ie(Et)(ie(At)(w.content)), t.isStreaming)
|
|
199
199
|
}, null, 8, qs)
|
|
200
|
-
], 544)) :
|
|
200
|
+
], 544)) : z("", !0)
|
|
201
201
|
]),
|
|
202
202
|
_: 1
|
|
203
203
|
})
|
|
@@ -241,36 +241,36 @@ const ln = {
|
|
|
241
241
|
}, oa = {
|
|
242
242
|
key: 0,
|
|
243
243
|
class: "step-item__content"
|
|
244
|
-
}, ia = /* @__PURE__ */
|
|
244
|
+
}, ia = /* @__PURE__ */ $e({
|
|
245
245
|
__name: "StepBlock",
|
|
246
246
|
props: {
|
|
247
247
|
steps: {}
|
|
248
248
|
},
|
|
249
249
|
setup(t) {
|
|
250
|
-
const w = t, e = S(() => w.steps.some((
|
|
251
|
-
() => w.steps.reduce((
|
|
250
|
+
const w = t, e = S(() => w.steps.some((f) => f.state !== "done")), v = S(
|
|
251
|
+
() => w.steps.reduce((f, g) => f + (g.duration ?? 0), 0)
|
|
252
252
|
);
|
|
253
|
-
function a(
|
|
254
|
-
return
|
|
253
|
+
function a(f) {
|
|
254
|
+
return f == null || f <= 0 ? "" : f < 1 ? `${Math.round(f * 1e3)}ms` : f < 60 ? `${f.toFixed(1)}s` : `${Math.floor(f / 60)}m${Math.round(f % 60)}s`;
|
|
255
255
|
}
|
|
256
|
-
return (
|
|
257
|
-
class:
|
|
256
|
+
return (f, g) => (i(), h("div", {
|
|
257
|
+
class: me(["step-block", { "step-block--active": e.value }])
|
|
258
258
|
}, [
|
|
259
|
-
t.steps.length > 1 ? (i(),
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
e.value ?
|
|
263
|
-
!e.value &&
|
|
264
|
-
])) :
|
|
259
|
+
t.steps.length > 1 ? (i(), h("div", Ks, [
|
|
260
|
+
g[0] || (g[0] = o("span", { class: "step-block__indicator" }, null, -1)),
|
|
261
|
+
g[1] || (g[1] = o("span", { class: "step-block__title" }, "执行步骤", -1)),
|
|
262
|
+
e.value ? z("", !0) : (i(), h("span", Ys, te(t.steps.length) + " 步", 1)),
|
|
263
|
+
!e.value && v.value > 0 ? (i(), h("span", Qs, te(a(v.value)), 1)) : z("", !0)
|
|
264
|
+
])) : z("", !0),
|
|
265
265
|
o("ul", js, [
|
|
266
|
-
(i(!0),
|
|
267
|
-
key:
|
|
268
|
-
class:
|
|
266
|
+
(i(!0), h(Ce, null, Ae(t.steps, (l, r) => (i(), h("li", {
|
|
267
|
+
key: r,
|
|
268
|
+
class: me(["step-item", `step-item--${l.state}`])
|
|
269
269
|
}, [
|
|
270
270
|
o("span", Js, [
|
|
271
|
-
|
|
271
|
+
l.state === "done" ? (i(), h("svg", Zs, [...g[2] || (g[2] = [
|
|
272
272
|
o("polyline", { points: "20 6 9 17 4 12" }, null, -1)
|
|
273
|
-
])])) :
|
|
273
|
+
])])) : l.state === "active" ? (i(), h("svg", Us, [...g[3] || (g[3] = [
|
|
274
274
|
o("circle", {
|
|
275
275
|
cx: "12",
|
|
276
276
|
cy: "12",
|
|
@@ -278,14 +278,14 @@ const ln = {
|
|
|
278
278
|
"stroke-dasharray": "42",
|
|
279
279
|
"stroke-dashoffset": "14"
|
|
280
280
|
}, null, -1)
|
|
281
|
-
])])) : (i(),
|
|
281
|
+
])])) : (i(), h("span", ea))
|
|
282
282
|
]),
|
|
283
283
|
o("div", ta, [
|
|
284
284
|
o("div", na, [
|
|
285
|
-
o("span", sa,
|
|
286
|
-
|
|
285
|
+
o("span", sa, te(l.title || "处理中"), 1),
|
|
286
|
+
l.state === "done" && l.duration != null && l.duration > 0 ? (i(), h("span", aa, te(a(l.duration)), 1)) : z("", !0)
|
|
287
287
|
]),
|
|
288
|
-
|
|
288
|
+
l.content ? (i(), h("div", oa, te(l.content), 1)) : z("", !0)
|
|
289
289
|
])
|
|
290
290
|
], 2))), 128))
|
|
291
291
|
])
|
|
@@ -303,7 +303,7 @@ const ln = {
|
|
|
303
303
|
}, da = {
|
|
304
304
|
key: 3,
|
|
305
305
|
class: "agent-thought__duration"
|
|
306
|
-
},
|
|
306
|
+
}, cn = /* @__PURE__ */ $e({
|
|
307
307
|
__name: "AgentThoughtBlock",
|
|
308
308
|
props: {
|
|
309
309
|
isDone: { type: Boolean },
|
|
@@ -314,12 +314,12 @@ const ln = {
|
|
|
314
314
|
function w(e) {
|
|
315
315
|
return e == null || e <= 0 ? "" : e < 1 ? `${Math.round(e * 1e3)}ms` : e < 60 ? `${e.toFixed(1)}s` : `${Math.floor(e / 60)}m${Math.round(e % 60)}s`;
|
|
316
316
|
}
|
|
317
|
-
return (e,
|
|
318
|
-
class:
|
|
317
|
+
return (e, v) => (i(), h("div", {
|
|
318
|
+
class: me(["agent-thought", { "agent-thought--done": t.isDone }])
|
|
319
319
|
}, [
|
|
320
|
-
t.isDone ? (i(),
|
|
321
|
-
|
|
322
|
-
])) : (i(),
|
|
320
|
+
t.isDone ? (i(), h("span", la, [
|
|
321
|
+
ke(ie(Cn))
|
|
322
|
+
])) : (i(), h("span", ra, [...v[0] || (v[0] = [
|
|
323
323
|
o("svg", {
|
|
324
324
|
viewBox: "0 0 24 24",
|
|
325
325
|
width: "14",
|
|
@@ -341,9 +341,9 @@ const ln = {
|
|
|
341
341
|
})
|
|
342
342
|
], -1)
|
|
343
343
|
])])),
|
|
344
|
-
o("span", ua,
|
|
345
|
-
t.isDone && (t.count ?? 0) > 1 ? (i(),
|
|
346
|
-
t.isDone && (t.duration ?? 0) > 0 ? (i(),
|
|
344
|
+
o("span", ua, te(t.isDone ? "工具调用" : "工具调用中"), 1),
|
|
345
|
+
t.isDone && (t.count ?? 0) > 1 ? (i(), h("span", ca, "已调用 " + te(t.count) + " 次", 1)) : z("", !0),
|
|
346
|
+
t.isDone && (t.duration ?? 0) > 0 ? (i(), h("span", da, te(w(t.duration)), 1)) : z("", !0)
|
|
347
347
|
], 2));
|
|
348
348
|
}
|
|
349
349
|
}), va = { class: "ai-action-card__main" }, ha = { class: "ai-action-card__text" }, fa = { class: "ai-action-card__label" }, ma = {
|
|
@@ -355,7 +355,7 @@ const ln = {
|
|
|
355
355
|
}, ya = {
|
|
356
356
|
key: 1,
|
|
357
357
|
class: "ai-action-card__feedback ai-action-card__feedback--error"
|
|
358
|
-
}, wa = /* @__PURE__ */
|
|
358
|
+
}, wa = /* @__PURE__ */ $e({
|
|
359
359
|
__name: "AiActionCard",
|
|
360
360
|
props: {
|
|
361
361
|
action: {},
|
|
@@ -365,43 +365,43 @@ const ln = {
|
|
|
365
365
|
},
|
|
366
366
|
emits: ["run"],
|
|
367
367
|
setup(t, { emit: w }) {
|
|
368
|
-
const e = t,
|
|
368
|
+
const e = t, v = w, a = {
|
|
369
369
|
fillFilters: "应用筛选条件",
|
|
370
370
|
export: "导出当前结果"
|
|
371
|
-
},
|
|
371
|
+
}, f = S(() => e.action.label || a[e.action.type] || "执行操作"), g = S(() => {
|
|
372
372
|
const C = e.action.payload || {};
|
|
373
373
|
if (e.action.type === "fillFilters") {
|
|
374
374
|
const E = [C.platformName, C.companyName, C.year && C.period ? `${C.year}年${C.period}月` : ""].filter(Boolean);
|
|
375
375
|
return E.length ? `将切换为:${E.join(" · ")}` : "";
|
|
376
376
|
}
|
|
377
377
|
return e.action.type === "export" ? "按当前查询条件导出" : "";
|
|
378
|
-
}),
|
|
379
|
-
|
|
378
|
+
}), l = S(() => e.state.status === "applied" ? "已应用" : e.state.status === "pending" ? "执行中" : e.state.status === "failed" ? "重试" : "执行"), r = S(() => e.disabled || e.state.status === "pending" || e.state.status === "applied"), M = () => {
|
|
379
|
+
r.value || v("run", e.action);
|
|
380
380
|
};
|
|
381
|
-
return (C, E) => (i(),
|
|
382
|
-
class:
|
|
381
|
+
return (C, E) => (i(), h("div", {
|
|
382
|
+
class: me(["ai-action-card", `ai-action-card--${t.state.status}`])
|
|
383
383
|
}, [
|
|
384
384
|
o("div", va, [
|
|
385
385
|
o("div", ha, [
|
|
386
|
-
o("p", fa,
|
|
387
|
-
|
|
386
|
+
o("p", fa, te(f.value), 1),
|
|
387
|
+
g.value ? (i(), h("p", ma, te(g.value), 1)) : z("", !0)
|
|
388
388
|
]),
|
|
389
389
|
o("button", {
|
|
390
390
|
type: "button",
|
|
391
391
|
class: "ai-action-card__btn",
|
|
392
|
-
disabled:
|
|
393
|
-
title:
|
|
392
|
+
disabled: r.value,
|
|
393
|
+
title: r.value && t.disabledReason || "",
|
|
394
394
|
onClick: M
|
|
395
|
-
},
|
|
395
|
+
}, te(l.value), 9, ga)
|
|
396
396
|
]),
|
|
397
|
-
t.state.status === "applied" && t.state.message ? (i(),
|
|
398
|
-
t.state.status === "failed" && t.state.message ? (i(),
|
|
397
|
+
t.state.status === "applied" && t.state.message ? (i(), h("p", pa, te(t.state.message), 1)) : z("", !0),
|
|
398
|
+
t.state.status === "failed" && t.state.message ? (i(), h("p", ya, te(t.state.message), 1)) : z("", !0)
|
|
399
399
|
], 2));
|
|
400
400
|
}
|
|
401
401
|
}), ka = { class: "ai-file-card__icon" }, _a = { class: "ai-file-card__text" }, Ca = ["title"], ba = { class: "ai-file-card__meta" }, Ma = {
|
|
402
402
|
key: 0,
|
|
403
403
|
class: "ai-file-card__error"
|
|
404
|
-
}, $a = ["disabled"], Sa = /* @__PURE__ */
|
|
404
|
+
}, $a = ["disabled"], Sa = /* @__PURE__ */ $e({
|
|
405
405
|
__name: "AiFileCard",
|
|
406
406
|
props: {
|
|
407
407
|
file: {},
|
|
@@ -409,7 +409,7 @@ const ln = {
|
|
|
409
409
|
},
|
|
410
410
|
emits: ["download"],
|
|
411
411
|
setup(t, { emit: w }) {
|
|
412
|
-
const e = t,
|
|
412
|
+
const e = t, v = w, a = {
|
|
413
413
|
xlsx: "XLS",
|
|
414
414
|
xls: "XLS",
|
|
415
415
|
csv: "CSV",
|
|
@@ -424,191 +424,191 @@ const ln = {
|
|
|
424
424
|
jpg: "IMG",
|
|
425
425
|
jpeg: "IMG",
|
|
426
426
|
zip: "ZIP"
|
|
427
|
-
},
|
|
427
|
+
}, f = S(() => {
|
|
428
428
|
const M = (e.file.name.split(".").pop() || "").toLowerCase();
|
|
429
429
|
return a[M] || "FILE";
|
|
430
|
-
}),
|
|
430
|
+
}), g = S(() => {
|
|
431
431
|
const M = Number(e.file.size || 0);
|
|
432
432
|
return M ? M < 1024 ? `${M} B` : M < 1024 * 1024 ? `${(M / 1024).toFixed(1)} KB` : `${(M / 1024 / 1024).toFixed(1)} MB` : "—";
|
|
433
|
-
}),
|
|
434
|
-
return (M, C) => (i(),
|
|
435
|
-
class:
|
|
433
|
+
}), l = S(() => e.state.status === "pending" ? "下载中" : e.state.status === "applied" ? "已下载" : e.state.status === "failed" ? "重试" : "下载"), r = S(() => e.state.status === "pending" || e.state.status === "applied");
|
|
434
|
+
return (M, C) => (i(), h("div", {
|
|
435
|
+
class: me(["ai-file-card", `ai-file-card--${t.state.status}`])
|
|
436
436
|
}, [
|
|
437
|
-
o("div", ka,
|
|
437
|
+
o("div", ka, te(f.value), 1),
|
|
438
438
|
o("div", _a, [
|
|
439
439
|
o("p", {
|
|
440
440
|
class: "ai-file-card__name",
|
|
441
441
|
title: t.file.name
|
|
442
|
-
},
|
|
442
|
+
}, te(t.file.name), 9, Ca),
|
|
443
443
|
o("p", ba, [
|
|
444
|
-
|
|
445
|
-
t.state.status === "failed" && t.state.message ? (i(),
|
|
444
|
+
fn(te(g.value) + " ", 1),
|
|
445
|
+
t.state.status === "failed" && t.state.message ? (i(), h("span", Ma, te(t.state.message), 1)) : z("", !0)
|
|
446
446
|
])
|
|
447
447
|
]),
|
|
448
448
|
o("button", {
|
|
449
449
|
type: "button",
|
|
450
450
|
class: "ai-file-card__btn",
|
|
451
|
-
disabled:
|
|
452
|
-
onClick: C[0] || (C[0] = (E) =>
|
|
453
|
-
},
|
|
451
|
+
disabled: r.value,
|
|
452
|
+
onClick: C[0] || (C[0] = (E) => v("download", t.file))
|
|
453
|
+
}, te(l.value), 9, $a)
|
|
454
454
|
], 2));
|
|
455
455
|
}
|
|
456
|
-
}),
|
|
456
|
+
}), Ta = {
|
|
457
457
|
class: "ai-tool-status__icon",
|
|
458
458
|
"aria-hidden": "true"
|
|
459
|
-
},
|
|
459
|
+
}, xa = {
|
|
460
460
|
key: 0,
|
|
461
461
|
class: "ai-tool-status__spinner"
|
|
462
|
-
}, Da = { key: 1 }, Ea = { key: 2 }, Aa = { key: 3 }, Ra = { class: "ai-tool-status__text" }, Pa = /* @__PURE__ */
|
|
462
|
+
}, Da = { key: 1 }, Ea = { key: 2 }, Aa = { key: 3 }, Ra = { class: "ai-tool-status__text" }, Pa = /* @__PURE__ */ $e({
|
|
463
463
|
__name: "AiToolStatus",
|
|
464
464
|
props: {
|
|
465
465
|
state: {}
|
|
466
466
|
},
|
|
467
467
|
setup(t) {
|
|
468
468
|
const w = t, e = S(() => {
|
|
469
|
-
const
|
|
470
|
-
return
|
|
469
|
+
const v = w.state;
|
|
470
|
+
return v.status === "running" ? v.message || "正在查询数据…" : v.status === "done" ? v.message || "已获取数据" : v.status === "failed" ? v.message || "取数失败" : v.message || "";
|
|
471
471
|
});
|
|
472
|
-
return (
|
|
473
|
-
class:
|
|
472
|
+
return (v, a) => (i(), h("div", {
|
|
473
|
+
class: me(["ai-tool-status", `ai-tool-status--${t.state.status}`])
|
|
474
474
|
}, [
|
|
475
|
-
o("span",
|
|
476
|
-
t.state.status === "running" ? (i(),
|
|
475
|
+
o("span", Ta, [
|
|
476
|
+
t.state.status === "running" ? (i(), h("span", xa)) : t.state.status === "done" ? (i(), h("span", Da, "✓")) : t.state.status === "failed" ? (i(), h("span", Ea, "!")) : (i(), h("span", Aa, "·"))
|
|
477
477
|
]),
|
|
478
|
-
o("span", Ra,
|
|
478
|
+
o("span", Ra, te(e.value), 1)
|
|
479
479
|
], 2));
|
|
480
480
|
}
|
|
481
481
|
}), La = { class: "ai-chart-card" }, Ha = {
|
|
482
482
|
key: 1,
|
|
483
483
|
class: "ai-chart-card__hint"
|
|
484
|
-
}, Na = /* @__PURE__ */
|
|
484
|
+
}, Na = /* @__PURE__ */ $e({
|
|
485
485
|
__name: "AiChartCard",
|
|
486
486
|
props: {
|
|
487
487
|
chart: {}
|
|
488
488
|
},
|
|
489
489
|
setup(t) {
|
|
490
|
-
const w = t, e = _(null),
|
|
490
|
+
const w = t, e = _(null), v = _(!1);
|
|
491
491
|
let a = !1;
|
|
492
|
-
const
|
|
493
|
-
var
|
|
494
|
-
return !!((
|
|
492
|
+
const f = S(() => {
|
|
493
|
+
var r;
|
|
494
|
+
return !!((r = Ve()) != null && r.onChartDownload);
|
|
495
495
|
});
|
|
496
|
-
async function
|
|
496
|
+
async function g() {
|
|
497
497
|
var C;
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
500
|
-
const M = (C =
|
|
498
|
+
const r = e.value;
|
|
499
|
+
if (!r || a) return;
|
|
500
|
+
const M = (C = Ve()) == null ? void 0 : C.onChartRender;
|
|
501
501
|
if (!M) {
|
|
502
|
-
|
|
502
|
+
v.value = !0;
|
|
503
503
|
return;
|
|
504
504
|
}
|
|
505
|
-
|
|
505
|
+
v.value = !1;
|
|
506
506
|
try {
|
|
507
|
-
await M(w.chart,
|
|
507
|
+
await M(w.chart, r);
|
|
508
508
|
} catch (E) {
|
|
509
|
-
console.warn("[ai-assist-sdk] onChartRender failed:", E),
|
|
509
|
+
console.warn("[ai-assist-sdk] onChartRender failed:", E), v.value = !0;
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
var
|
|
514
|
-
(M = (
|
|
512
|
+
function l() {
|
|
513
|
+
var r, M;
|
|
514
|
+
(M = (r = Ve()) == null ? void 0 : r.onChartDownload) == null || M.call(r, w.chart);
|
|
515
515
|
}
|
|
516
|
-
return
|
|
516
|
+
return ge(() => w.chart.chartId, () => Se(g)), ge(() => w.chart.option, () => Se(g), { deep: !0 }), Pe(() => Se(g)), Lt(() => {
|
|
517
517
|
a = !0;
|
|
518
|
-
}), (
|
|
519
|
-
|
|
518
|
+
}), (r, M) => (i(), h("figure", La, [
|
|
519
|
+
f.value ? (i(), h("button", {
|
|
520
520
|
key: 0,
|
|
521
521
|
type: "button",
|
|
522
522
|
class: "ai-chart-card__download",
|
|
523
|
-
onClick:
|
|
524
|
-
}, " 下载 ")) :
|
|
523
|
+
onClick: l
|
|
524
|
+
}, " 下载 ")) : z("", !0),
|
|
525
525
|
o("div", {
|
|
526
526
|
ref_key: "chartEl",
|
|
527
527
|
ref: e,
|
|
528
528
|
class: "ai-chart-card__body"
|
|
529
529
|
}, null, 512),
|
|
530
|
-
|
|
530
|
+
v.value ? (i(), h("p", Ha, "当前页面未接入图表渲染")) : z("", !0)
|
|
531
531
|
]));
|
|
532
532
|
}
|
|
533
533
|
});
|
|
534
534
|
function Va(t, w, e) {
|
|
535
|
-
const
|
|
536
|
-
const
|
|
537
|
-
return
|
|
538
|
-
}),
|
|
535
|
+
const v = S(() => t().segments), a = S(() => Dt(v.value)), f = S(() => !!t().streamed), g = S(() => {
|
|
536
|
+
const V = t().status;
|
|
537
|
+
return V === "stop" || V === "error";
|
|
538
|
+
}), l = Math.min(
|
|
539
539
|
Math.max((e == null ? void 0 : e.initial) ?? 0, 0),
|
|
540
|
-
|
|
541
|
-
),
|
|
542
|
-
|
|
543
|
-
var
|
|
544
|
-
return (
|
|
540
|
+
Dt(t().segments)
|
|
541
|
+
), r = _(t().streamed ? l : Dt(t().segments));
|
|
542
|
+
ge(r, (V) => {
|
|
543
|
+
var le;
|
|
544
|
+
return (le = e == null ? void 0 : e.onProgress) == null ? void 0 : le.call(e, V);
|
|
545
545
|
});
|
|
546
546
|
const M = _(0);
|
|
547
547
|
let C = 0, E = 0;
|
|
548
|
-
function
|
|
549
|
-
|
|
548
|
+
function T(V) {
|
|
549
|
+
r.value !== V && (r.value = V);
|
|
550
550
|
}
|
|
551
551
|
function I() {
|
|
552
552
|
if (C) return;
|
|
553
|
-
const
|
|
553
|
+
const V = (le) => {
|
|
554
554
|
if (E === 0) {
|
|
555
|
-
E =
|
|
555
|
+
E = le, C = requestAnimationFrame(V);
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
const s = Math.min(
|
|
559
|
-
E =
|
|
560
|
-
const
|
|
561
|
-
if (M.value =
|
|
558
|
+
const s = Math.min(le - E, 100);
|
|
559
|
+
E = le;
|
|
560
|
+
const ae = a.value, re = Ts(v.value, r.value), de = xs(r.value, ae, M.value, s, re);
|
|
561
|
+
if (M.value = de.frac, de.reveal !== r.value && (r.value = de.reveal, w == null || w()), r.value >= ae) {
|
|
562
562
|
C = 0, E = 0;
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
C = requestAnimationFrame(
|
|
565
|
+
C = requestAnimationFrame(V);
|
|
566
566
|
};
|
|
567
|
-
E = 0, C = requestAnimationFrame(
|
|
567
|
+
E = 0, C = requestAnimationFrame(V);
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function R() {
|
|
570
570
|
C && (cancelAnimationFrame(C), C = 0);
|
|
571
571
|
}
|
|
572
|
-
|
|
573
|
-
[
|
|
572
|
+
ge(
|
|
573
|
+
[f, a],
|
|
574
574
|
() => {
|
|
575
|
-
if (!
|
|
576
|
-
|
|
575
|
+
if (!f.value || g.value) {
|
|
576
|
+
T(a.value);
|
|
577
577
|
return;
|
|
578
578
|
}
|
|
579
|
-
|
|
579
|
+
r.value < a.value && I();
|
|
580
580
|
},
|
|
581
581
|
{ immediate: !0 }
|
|
582
|
-
),
|
|
583
|
-
|
|
584
|
-
}),
|
|
582
|
+
), ge(g, (V) => {
|
|
583
|
+
V && f.value && T(a.value);
|
|
584
|
+
}), ge(
|
|
585
585
|
() => t().status,
|
|
586
|
-
(
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
),
|
|
590
|
-
const y = S(() =>
|
|
591
|
-
() =>
|
|
592
|
-
),
|
|
593
|
-
function
|
|
594
|
-
return
|
|
586
|
+
(V, le) => {
|
|
587
|
+
V === "rethinking" && le !== "rethinking" && (M.value = 0, T(0), a.value > 0 && I());
|
|
588
|
+
}
|
|
589
|
+
), Be(R);
|
|
590
|
+
const y = S(() => Ms(v.value, r.value)), N = S(
|
|
591
|
+
() => f.value ? $s(v.value, r.value) : -1
|
|
592
|
+
), j = S(() => !f.value || r.value >= a.value);
|
|
593
|
+
function A(V) {
|
|
594
|
+
return Ss(v.value, V, r.value);
|
|
595
595
|
}
|
|
596
|
-
return { reveal:
|
|
596
|
+
return { reveal: r, segmentContents: y, frontier: N, revealDone: j, isSegRevealed: A, stopLoop: R };
|
|
597
597
|
}
|
|
598
|
-
function Oa(t, w, e =
|
|
599
|
-
const
|
|
598
|
+
function Oa(t, w, e = Ds) {
|
|
599
|
+
const v = _(!1);
|
|
600
600
|
let a = 0;
|
|
601
|
-
return
|
|
601
|
+
return ge(
|
|
602
602
|
[t, w],
|
|
603
603
|
() => {
|
|
604
|
-
a && (clearTimeout(a), a = 0),
|
|
605
|
-
|
|
604
|
+
a && (clearTimeout(a), a = 0), v.value = !1, t.value && (a = window.setTimeout(() => {
|
|
605
|
+
v.value = !0, a = 0;
|
|
606
606
|
}, e));
|
|
607
607
|
},
|
|
608
608
|
{ immediate: !0 }
|
|
609
|
-
),
|
|
609
|
+
), Be(() => {
|
|
610
610
|
a && clearTimeout(a);
|
|
611
|
-
}), S(() => t.value &&
|
|
611
|
+
}), S(() => t.value && v.value);
|
|
612
612
|
}
|
|
613
613
|
const Wa = {
|
|
614
614
|
key: 1,
|
|
@@ -616,10 +616,10 @@ const Wa = {
|
|
|
616
616
|
}, Ba = { class: "thought-collapse-bar__text" }, Fa = {
|
|
617
617
|
key: 2,
|
|
618
618
|
class: "thought-collapse-bar__duration"
|
|
619
|
-
},
|
|
619
|
+
}, Ia = { class: "thought-collapse-bar__action" }, Xa = {
|
|
620
620
|
key: 0,
|
|
621
621
|
class: "agent-thought-line"
|
|
622
|
-
},
|
|
622
|
+
}, za = { key: 0 }, qa = ["innerHTML"], Ga = ["innerHTML"], Ka = {
|
|
623
623
|
key: 1,
|
|
624
624
|
class: "ai-chart-list"
|
|
625
625
|
}, Ya = {
|
|
@@ -643,7 +643,7 @@ const Wa = {
|
|
|
643
643
|
}, no = {
|
|
644
644
|
key: 1,
|
|
645
645
|
class: "message-content"
|
|
646
|
-
}, so = ["src"], ao = /* @__PURE__ */
|
|
646
|
+
}, so = ["src"], ao = /* @__PURE__ */ $e({
|
|
647
647
|
__name: "MessageItem",
|
|
648
648
|
props: {
|
|
649
649
|
msg: {},
|
|
@@ -655,164 +655,164 @@ const Wa = {
|
|
|
655
655
|
},
|
|
656
656
|
emits: ["regenerate", "reveal-progress", "ask"],
|
|
657
657
|
setup(t, { emit: w }) {
|
|
658
|
-
const e = t,
|
|
659
|
-
var
|
|
660
|
-
return a.value && y.value && !!((
|
|
661
|
-
}),
|
|
662
|
-
var
|
|
663
|
-
return ((
|
|
658
|
+
const e = t, v = w, a = S(() => yn()), f = S(() => {
|
|
659
|
+
var u;
|
|
660
|
+
return a.value && y.value && !!((u = e.msg.charts) != null && u.length);
|
|
661
|
+
}), g = (u, p) => `${p}:${u.type}`, l = (u, p) => {
|
|
662
|
+
var Y;
|
|
663
|
+
return ((Y = e.msg.actionStates) == null ? void 0 : Y[g(u, p)]) || { status: "idle" };
|
|
664
664
|
};
|
|
665
|
-
async function u
|
|
666
|
-
var
|
|
667
|
-
const
|
|
668
|
-
e.msg.actionStates = { ...
|
|
669
|
-
const
|
|
670
|
-
if (!
|
|
671
|
-
e.msg.actionStates = { ...e.msg.actionStates, [
|
|
665
|
+
async function r(u, p) {
|
|
666
|
+
var B;
|
|
667
|
+
const Y = g(u, p), oe = { ...e.msg.actionStates || {} };
|
|
668
|
+
e.msg.actionStates = { ...oe, [Y]: { status: "pending" } };
|
|
669
|
+
const J = (B = Ve()) == null ? void 0 : B.onAction;
|
|
670
|
+
if (!J) {
|
|
671
|
+
e.msg.actionStates = { ...e.msg.actionStates, [Y]: { status: "failed", message: "当前页面未接入动作执行" } };
|
|
672
672
|
return;
|
|
673
673
|
}
|
|
674
674
|
try {
|
|
675
|
-
const W = await
|
|
675
|
+
const W = await J(u);
|
|
676
676
|
e.msg.actionStates = {
|
|
677
677
|
...e.msg.actionStates,
|
|
678
|
-
[
|
|
678
|
+
[Y]: { status: W != null && W.ok ? "applied" : "failed", message: W == null ? void 0 : W.message }
|
|
679
679
|
};
|
|
680
680
|
} catch (W) {
|
|
681
681
|
e.msg.actionStates = {
|
|
682
682
|
...e.msg.actionStates,
|
|
683
|
-
[
|
|
683
|
+
[Y]: { status: "failed", message: (W == null ? void 0 : W.message) || "执行失败,请稍后重试" }
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
|
-
const M = (
|
|
688
|
-
var
|
|
689
|
-
return ((
|
|
687
|
+
const M = (u) => {
|
|
688
|
+
var p;
|
|
689
|
+
return ((p = e.msg.fileStates) == null ? void 0 : p[u.relPath]) || { status: "idle" };
|
|
690
690
|
};
|
|
691
|
-
async function C(
|
|
692
|
-
var
|
|
693
|
-
const
|
|
694
|
-
delete
|
|
695
|
-
const
|
|
696
|
-
if (!
|
|
691
|
+
async function C(u) {
|
|
692
|
+
var oe;
|
|
693
|
+
const p = { ...e.msg.fileStates || {} };
|
|
694
|
+
delete p[u.relPath], e.msg.fileStates = { ...p, [u.relPath]: { status: "pending" } };
|
|
695
|
+
const Y = (oe = Ve()) == null ? void 0 : oe.onDownloadFile;
|
|
696
|
+
if (!Y) {
|
|
697
697
|
e.msg.fileStates = {
|
|
698
698
|
...e.msg.fileStates,
|
|
699
|
-
[
|
|
699
|
+
[u.relPath]: { status: "failed", message: "当前页面未接入文件下载" }
|
|
700
700
|
};
|
|
701
701
|
return;
|
|
702
702
|
}
|
|
703
703
|
try {
|
|
704
|
-
const
|
|
704
|
+
const J = await Y(u);
|
|
705
705
|
e.msg.fileStates = {
|
|
706
706
|
...e.msg.fileStates,
|
|
707
|
-
[
|
|
707
|
+
[u.relPath]: { status: J != null && J.ok ? "applied" : "failed", message: J == null ? void 0 : J.message }
|
|
708
708
|
};
|
|
709
|
-
} catch (
|
|
709
|
+
} catch (J) {
|
|
710
710
|
e.msg.fileStates = {
|
|
711
711
|
...e.msg.fileStates,
|
|
712
|
-
[
|
|
712
|
+
[u.relPath]: { status: "failed", message: (J == null ? void 0 : J.message) || "下载失败,请重试" }
|
|
713
713
|
};
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
const { reveal: E, segmentContents:
|
|
716
|
+
const { reveal: E, segmentContents: T, frontier: I, revealDone: R } = Va(
|
|
717
717
|
() => e.msg,
|
|
718
718
|
() => e.scrollToBottom(),
|
|
719
719
|
{
|
|
720
720
|
initial: e.initialReveal,
|
|
721
|
-
onProgress: (
|
|
721
|
+
onProgress: (u) => v("reveal-progress", u)
|
|
722
722
|
}
|
|
723
723
|
), y = S(
|
|
724
724
|
() => e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP
|
|
725
|
-
),
|
|
726
|
-
|
|
727
|
-
|
|
725
|
+
), N = S(() => y.value && R.value), j = _(!1);
|
|
726
|
+
ge(N, (u) => {
|
|
727
|
+
u && (j.value = !1);
|
|
728
728
|
});
|
|
729
|
-
const
|
|
730
|
-
() =>
|
|
731
|
-
(
|
|
729
|
+
const A = S(() => Es(e.msg.segments, E.value)), V = S(() => A.value.length > 0), le = S(() => A.value.some((u) => u.kind === "thinking")), s = S(() => A.value.some((u) => u.kind === "tools")), ae = S(() => A.value.some((u) => u.kind === "steps")), re = S(
|
|
730
|
+
() => A.value.some(
|
|
731
|
+
(u) => u.kind === "thinking" && u.streaming || u.kind === "tools" && u.calling || u.kind === "steps" && u.items.some((p) => p.state !== "done")
|
|
732
732
|
)
|
|
733
|
-
),
|
|
733
|
+
), de = S(
|
|
734
734
|
() => e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING || e.msg.status === e.STATUS.ANSWERING
|
|
735
735
|
), k = S(
|
|
736
|
-
() =>
|
|
737
|
-
),
|
|
738
|
-
|
|
739
|
-
|
|
736
|
+
() => de.value && !!e.msg.streamed && R.value && !re.value && e.msg.lastChunkAt != null
|
|
737
|
+
), U = Oa(k, S(() => e.msg.lastChunkAt));
|
|
738
|
+
ge(U, (u) => {
|
|
739
|
+
u && e.scrollToBottom();
|
|
740
740
|
});
|
|
741
|
-
const
|
|
742
|
-
const
|
|
743
|
-
return
|
|
744
|
-
}),
|
|
741
|
+
const m = S(() => {
|
|
742
|
+
const u = [];
|
|
743
|
+
return le.value && u.push("深度思考"), s.value && u.push("工具调用"), ae.value && u.push("执行步骤"), u.join(" · ") || "思考过程";
|
|
744
|
+
}), O = S(() => !N.value || j.value), q = S(
|
|
745
745
|
() => (e.msg.segments ?? []).reduce(
|
|
746
|
-
(
|
|
746
|
+
(u, p) => p.type === "thinking" || p.type === "agent_thought" || p.type === "step" ? u + (p.duration ?? 0) : u,
|
|
747
747
|
0
|
|
748
748
|
)
|
|
749
|
-
),
|
|
749
|
+
), X = S(
|
|
750
750
|
() => (e.msg.segments ?? []).some(
|
|
751
|
-
(
|
|
751
|
+
(u, p) => u.type === "answer" && (T.value[p] || "").length > 0
|
|
752
752
|
)
|
|
753
|
-
),
|
|
754
|
-
() => !
|
|
753
|
+
), L = S(
|
|
754
|
+
() => !N.value && !U.value && e.msg.status !== e.STATUS.ERROR && e.msg.status !== e.STATUS.PAUSED && A.value.length === 0 && !X.value && // 已有 content(page 模式流式输出)或正在取数时不显示 loading 点
|
|
755
755
|
!e.msg.content && !e.msg.toolState
|
|
756
756
|
);
|
|
757
|
-
function D(
|
|
758
|
-
return
|
|
757
|
+
function D(u) {
|
|
758
|
+
return u == null || u <= 0 ? "" : u < 1 ? `${Math.round(u * 1e3)}ms` : u < 60 ? `${u.toFixed(1)}s` : `${Math.floor(u / 60)}m${Math.round(u % 60)}s`;
|
|
759
759
|
}
|
|
760
|
-
const
|
|
761
|
-
function
|
|
762
|
-
const
|
|
763
|
-
|
|
760
|
+
const c = He(/* @__PURE__ */ new Map()), b = _("");
|
|
761
|
+
function x(u) {
|
|
762
|
+
const p = u.target;
|
|
763
|
+
p.tagName === "IMG" && (b.value = p.src);
|
|
764
764
|
}
|
|
765
|
-
function
|
|
765
|
+
function H() {
|
|
766
766
|
b.value = "";
|
|
767
767
|
}
|
|
768
|
-
function
|
|
769
|
-
var
|
|
768
|
+
function F(u, p) {
|
|
769
|
+
var Y;
|
|
770
770
|
try {
|
|
771
|
-
let
|
|
772
|
-
if (!
|
|
773
|
-
`)),
|
|
774
|
-
const { copy:
|
|
775
|
-
|
|
771
|
+
let oe = u.content;
|
|
772
|
+
if (!oe && ((Y = u.segments) != null && Y.length) && (oe = u.segments.filter((J) => J.type === "answer").map((J) => J.content).join(`
|
|
773
|
+
`)), oe) {
|
|
774
|
+
const { copy: J } = as();
|
|
775
|
+
J(Tt(oe)), c.set(p, !0), setTimeout(() => c.set(p, !1), 2e3);
|
|
776
776
|
}
|
|
777
777
|
} catch {
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
-
return (
|
|
781
|
-
var
|
|
782
|
-
return i(),
|
|
783
|
-
class:
|
|
780
|
+
return (u, p) => {
|
|
781
|
+
var Y, oe, J, B, W, ue;
|
|
782
|
+
return i(), h("div", {
|
|
783
|
+
class: me(["message", `${t.msg.type}-message`])
|
|
784
784
|
}, [
|
|
785
|
-
t.msg.type === "ai" ? (i(),
|
|
786
|
-
a.value && t.msg.toolState ? (i(),
|
|
785
|
+
t.msg.type === "ai" ? (i(), h(Ce, { key: 0 }, [
|
|
786
|
+
a.value && t.msg.toolState ? (i(), we(Pa, {
|
|
787
787
|
key: 0,
|
|
788
788
|
state: t.msg.toolState
|
|
789
|
-
}, null, 8, ["state"])) :
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
])])) :
|
|
793
|
-
t.msg.segments && t.msg.segments.length ? (i(),
|
|
789
|
+
}, null, 8, ["state"])) : z("", !0),
|
|
790
|
+
L.value ? (i(), h("div", Wa, [...p[4] || (p[4] = [
|
|
791
|
+
ts('<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)
|
|
792
|
+
])])) : z("", !0),
|
|
793
|
+
t.msg.segments && t.msg.segments.length ? (i(), h("div", {
|
|
794
794
|
key: 2,
|
|
795
795
|
class: "message-content ba-markdown",
|
|
796
|
-
ref: (
|
|
797
|
-
onClick:
|
|
796
|
+
ref: (Q) => t.setMessageRef(Q, t.index),
|
|
797
|
+
onClick: x
|
|
798
798
|
}, [
|
|
799
|
-
|
|
799
|
+
N.value && V.value ? (i(), h("div", {
|
|
800
800
|
key: 0,
|
|
801
|
-
class:
|
|
802
|
-
onClick:
|
|
801
|
+
class: me(["thought-collapse-bar", { "thought-collapse-bar--expanded": j.value }]),
|
|
802
|
+
onClick: p[0] || (p[0] = Le((Q) => j.value = !j.value, ["stop"]))
|
|
803
803
|
}, [
|
|
804
|
-
|
|
804
|
+
le.value ? (i(), we(ie(Hs), {
|
|
805
805
|
key: 0,
|
|
806
806
|
class: "thought-collapse-bar__icon"
|
|
807
|
-
})) : (i(),
|
|
807
|
+
})) : (i(), we(ie(Cn), {
|
|
808
808
|
key: 1,
|
|
809
809
|
class: "thought-collapse-bar__icon"
|
|
810
810
|
})),
|
|
811
|
-
o("span", Ba,
|
|
812
|
-
|
|
813
|
-
o("span",
|
|
814
|
-
(i(),
|
|
815
|
-
class:
|
|
811
|
+
o("span", Ba, te(m.value), 1),
|
|
812
|
+
q.value > 0 ? (i(), h("span", Fa, te(D(q.value)), 1)) : z("", !0),
|
|
813
|
+
o("span", Ia, te(j.value ? "收起" : "查看"), 1),
|
|
814
|
+
(i(), h("svg", {
|
|
815
|
+
class: me(["thought-collapse-bar__arrow", { "thought-collapse-bar__arrow--down": j.value }]),
|
|
816
816
|
viewBox: "0 0 24 24",
|
|
817
817
|
width: "12",
|
|
818
818
|
height: "12",
|
|
@@ -821,128 +821,128 @@ const Wa = {
|
|
|
821
821
|
"stroke-width": "2.5",
|
|
822
822
|
"stroke-linecap": "round",
|
|
823
823
|
"stroke-linejoin": "round"
|
|
824
|
-
}, [...
|
|
824
|
+
}, [...p[5] || (p[5] = [
|
|
825
825
|
o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
|
|
826
826
|
])], 2))
|
|
827
|
-
], 2)) :
|
|
828
|
-
|
|
829
|
-
(i(!0),
|
|
830
|
-
|
|
827
|
+
], 2)) : z("", !0),
|
|
828
|
+
O.value ? (i(), h(Ce, { key: 1 }, [
|
|
829
|
+
(i(!0), h(Ce, null, Ae(A.value, (Q, ve) => (i(), h(Ce, { key: ve }, [
|
|
830
|
+
Q.kind === "steps" ? (i(), we(ia, {
|
|
831
831
|
key: 0,
|
|
832
|
-
steps:
|
|
833
|
-
}, null, 8, ["steps"])) :
|
|
832
|
+
steps: Q.items
|
|
833
|
+
}, null, 8, ["steps"])) : Q.kind === "thinking" ? (i(), we(Gs, {
|
|
834
834
|
key: 1,
|
|
835
|
-
content:
|
|
836
|
-
"is-streaming":
|
|
837
|
-
"message-done":
|
|
838
|
-
}, null, 8, ["content", "is-streaming", "message-done"])) : (i(),
|
|
835
|
+
content: Q.content,
|
|
836
|
+
"is-streaming": Q.streaming,
|
|
837
|
+
"message-done": N.value
|
|
838
|
+
}, null, 8, ["content", "is-streaming", "message-done"])) : (i(), we(cn, {
|
|
839
839
|
key: 2,
|
|
840
|
-
"is-done": !
|
|
841
|
-
count:
|
|
842
|
-
duration:
|
|
840
|
+
"is-done": !Q.calling,
|
|
841
|
+
count: Q.count,
|
|
842
|
+
duration: Q.duration
|
|
843
843
|
}, null, 8, ["is-done", "count", "duration"]))
|
|
844
844
|
], 64))), 128)),
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
])) :
|
|
848
|
-
], 64)) :
|
|
849
|
-
(i(!0),
|
|
850
|
-
|
|
845
|
+
ie(U) ? (i(), h("div", Xa, [
|
|
846
|
+
ke(cn)
|
|
847
|
+
])) : z("", !0)
|
|
848
|
+
], 64)) : z("", !0),
|
|
849
|
+
(i(!0), h(Ce, null, Ae(t.msg.segments, (Q, ve) => (i(), h(Ce, { key: ve }, [
|
|
850
|
+
Q.type === "answer" ? (i(), h("div", za, [
|
|
851
851
|
o("div", {
|
|
852
|
-
innerHTML:
|
|
853
|
-
|
|
854
|
-
!
|
|
852
|
+
innerHTML: ie(pn)(
|
|
853
|
+
ie(Et)(ie(Tt)(ie(At)(ie(T)[ve] ?? ""))),
|
|
854
|
+
!ie(R) && ie(I) === ve && t.msg.status !== t.STATUS.STOP
|
|
855
855
|
)
|
|
856
856
|
}, null, 8, qa)
|
|
857
|
-
])) :
|
|
857
|
+
])) : z("", !0)
|
|
858
858
|
], 64))), 128))
|
|
859
|
-
], 512)) :
|
|
860
|
-
!((
|
|
859
|
+
], 512)) : z("", !0),
|
|
860
|
+
!((Y = t.msg.segments) != null && Y.length) && (t.msg.content || f.value) ? (i(), h("div", {
|
|
861
861
|
key: 3,
|
|
862
862
|
class: "message-content ba-markdown",
|
|
863
|
-
ref: (
|
|
864
|
-
onClick:
|
|
863
|
+
ref: (Q) => t.setMessageRef(Q, t.index),
|
|
864
|
+
onClick: x
|
|
865
865
|
}, [
|
|
866
|
-
t.msg.content ? (i(),
|
|
866
|
+
t.msg.content ? (i(), h("div", {
|
|
867
867
|
key: 0,
|
|
868
|
-
innerHTML:
|
|
869
|
-
}, null, 8, Ga)) :
|
|
870
|
-
|
|
871
|
-
(i(!0),
|
|
872
|
-
key:
|
|
873
|
-
chart:
|
|
868
|
+
innerHTML: ie(Et)(ie(Tt)(ie(At)(t.msg.content)))
|
|
869
|
+
}, null, 8, Ga)) : z("", !0),
|
|
870
|
+
f.value ? (i(), h("div", Ka, [
|
|
871
|
+
(i(!0), h(Ce, null, Ae(t.msg.charts, (Q) => (i(), we(Na, {
|
|
872
|
+
key: Q.chartId,
|
|
873
|
+
chart: Q
|
|
874
874
|
}, null, 8, ["chart"]))), 128))
|
|
875
|
-
])) :
|
|
876
|
-
], 512)) :
|
|
877
|
-
a.value && ((
|
|
878
|
-
(
|
|
879
|
-
(i(!0),
|
|
880
|
-
key: `${
|
|
881
|
-
action:
|
|
882
|
-
state:
|
|
883
|
-
onRun: (
|
|
875
|
+
])) : z("", !0)
|
|
876
|
+
], 512)) : z("", !0),
|
|
877
|
+
a.value && ((oe = t.msg.actions) != null && oe.length || (J = t.msg.suggestions) != null && J.length) ? (i(), h(Ce, { key: 4 }, [
|
|
878
|
+
(B = t.msg.actions) != null && B.length ? (i(), h("div", Ya, [
|
|
879
|
+
(i(!0), h(Ce, null, Ae(t.msg.actions, (Q, ve) => (i(), we(wa, {
|
|
880
|
+
key: `${ve}-${Q.type}`,
|
|
881
|
+
action: Q,
|
|
882
|
+
state: l(Q, ve),
|
|
883
|
+
onRun: (fe) => r(Q, ve)
|
|
884
884
|
}, null, 8, ["action", "state", "onRun"]))), 128))
|
|
885
|
-
])) :
|
|
886
|
-
(W = t.msg.suggestions) != null && W.length ? (i(),
|
|
887
|
-
(i(!0),
|
|
888
|
-
key:
|
|
885
|
+
])) : z("", !0),
|
|
886
|
+
(W = t.msg.suggestions) != null && W.length ? (i(), h("div", Qa, [
|
|
887
|
+
(i(!0), h(Ce, null, Ae(t.msg.suggestions, (Q, ve) => (i(), h("button", {
|
|
888
|
+
key: ve,
|
|
889
889
|
type: "button",
|
|
890
890
|
class: "ai-suggestion",
|
|
891
|
-
onClick: (
|
|
892
|
-
},
|
|
893
|
-
])) :
|
|
894
|
-
], 64)) :
|
|
895
|
-
a.value && ((
|
|
896
|
-
(i(!0),
|
|
897
|
-
key:
|
|
898
|
-
file:
|
|
899
|
-
state: M(
|
|
891
|
+
onClick: (fe) => v("ask", Q)
|
|
892
|
+
}, te(Q), 9, ja))), 128))
|
|
893
|
+
])) : z("", !0)
|
|
894
|
+
], 64)) : z("", !0),
|
|
895
|
+
a.value && ((ue = t.msg.files) != null && ue.length) ? (i(), h("div", Ja, [
|
|
896
|
+
(i(!0), h(Ce, null, Ae(t.msg.files, (Q) => (i(), we(Sa, {
|
|
897
|
+
key: Q.relPath,
|
|
898
|
+
file: Q,
|
|
899
|
+
state: M(Q),
|
|
900
900
|
onDownload: C
|
|
901
901
|
}, null, 8, ["file", "state"]))), 128))
|
|
902
|
-
])) :
|
|
903
|
-
t.msg.errorMessage ? (i(),
|
|
904
|
-
|
|
905
|
-
o("span", null,
|
|
906
|
-
])) :
|
|
907
|
-
|
|
902
|
+
])) : z("", !0),
|
|
903
|
+
t.msg.errorMessage ? (i(), h("div", Za, [
|
|
904
|
+
p[6] || (p[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
|
|
905
|
+
o("span", null, te(t.msg.errorMessage), 1)
|
|
906
|
+
])) : z("", !0),
|
|
907
|
+
N.value ? (i(), h("div", Ua, [
|
|
908
908
|
o("div", {
|
|
909
909
|
class: "tooltip-enhanced",
|
|
910
|
-
"data-tooltip":
|
|
910
|
+
"data-tooltip": c.get(t.index) ? "已复制" : "复制回答"
|
|
911
911
|
}, [
|
|
912
|
-
|
|
912
|
+
c.get(t.index) ? (i(), we(ie(Ns), {
|
|
913
913
|
key: 0,
|
|
914
914
|
class: "message-toolbar__check"
|
|
915
|
-
})) : (i(),
|
|
915
|
+
})) : (i(), we(ie(Vs), {
|
|
916
916
|
key: 1,
|
|
917
|
-
onClick:
|
|
917
|
+
onClick: p[1] || (p[1] = (Q) => F(t.msg, t.index))
|
|
918
918
|
}))
|
|
919
919
|
], 8, eo),
|
|
920
920
|
o("div", to, [
|
|
921
|
-
|
|
922
|
-
onClick:
|
|
921
|
+
ke(ie(Os), {
|
|
922
|
+
onClick: p[2] || (p[2] = (Q) => u.$emit("regenerate"))
|
|
923
923
|
})
|
|
924
924
|
])
|
|
925
|
-
])) :
|
|
926
|
-
], 64)) : (i(),
|
|
927
|
-
(i(),
|
|
928
|
-
b.value ? (i(),
|
|
925
|
+
])) : z("", !0)
|
|
926
|
+
], 64)) : (i(), h("div", no, te(t.msg.content), 1)),
|
|
927
|
+
(i(), we(mn, { to: "#ai-assist-root" }, [
|
|
928
|
+
b.value ? (i(), h("div", {
|
|
929
929
|
key: 0,
|
|
930
930
|
class: "ai-image-preview-overlay",
|
|
931
|
-
onClick:
|
|
931
|
+
onClick: H
|
|
932
932
|
}, [
|
|
933
933
|
o("img", {
|
|
934
934
|
src: b.value,
|
|
935
935
|
class: "ai-image-preview-overlay__img",
|
|
936
|
-
onClick:
|
|
936
|
+
onClick: p[3] || (p[3] = Le(() => {
|
|
937
937
|
}, ["stop"]))
|
|
938
938
|
}, null, 8, so),
|
|
939
939
|
o("button", {
|
|
940
940
|
class: "ai-image-preview-overlay__close",
|
|
941
|
-
onClick:
|
|
941
|
+
onClick: Le(H, ["stop"])
|
|
942
942
|
}, [
|
|
943
|
-
|
|
943
|
+
ke(ie(Ws))
|
|
944
944
|
])
|
|
945
|
-
])) :
|
|
945
|
+
])) : z("", !0)
|
|
946
946
|
]))
|
|
947
947
|
], 2);
|
|
948
948
|
};
|
|
@@ -972,7 +972,7 @@ const Wa = {
|
|
|
972
972
|
}, go = ["data-tooltip"], po = {
|
|
973
973
|
key: 3,
|
|
974
974
|
class: "moveTB"
|
|
975
|
-
}, yo = 400, wo = 10, ko = /* @__PURE__ */
|
|
975
|
+
}, yo = 400, wo = 10, ko = /* @__PURE__ */ $e({
|
|
976
976
|
__name: "ChatInput",
|
|
977
977
|
props: {
|
|
978
978
|
modelValue: {},
|
|
@@ -982,436 +982,436 @@ const Wa = {
|
|
|
982
982
|
},
|
|
983
983
|
emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
|
|
984
984
|
setup(t, { emit: w }) {
|
|
985
|
-
const e = t,
|
|
986
|
-
let I = !1,
|
|
987
|
-
const
|
|
988
|
-
() =>
|
|
985
|
+
const e = t, v = w, a = _(!1), f = _(""), g = _(""), l = _("idle"), r = _(""), M = _(null), C = _(null), E = _(!1), T = _(!1);
|
|
986
|
+
let I = !1, R = null, y = null, N = !1, j = !1, A = null;
|
|
987
|
+
const V = S(() => l.value === "connecting"), le = S(
|
|
988
|
+
() => l.value === "recording" || l.value === "stopping"
|
|
989
989
|
), s = S(
|
|
990
|
-
() =>
|
|
991
|
-
),
|
|
992
|
-
() =>
|
|
993
|
-
),
|
|
994
|
-
() =>
|
|
990
|
+
() => l.value === "connecting" || l.value === "recording" || l.value === "stopping"
|
|
991
|
+
), ae = S(() => a.value && !s.value), re = S(
|
|
992
|
+
() => ae.value ? !!r.value.trim() : !!(f.value.trim() || g.value.trim())
|
|
993
|
+
), de = S(
|
|
994
|
+
() => ot.isSupported() && !e.modelValue.trim() && !e.isGenerating
|
|
995
995
|
), k = _(!1);
|
|
996
|
-
function
|
|
997
|
-
|
|
996
|
+
function U(B) {
|
|
997
|
+
B.pointerType === "mouse" && (k.value = !0);
|
|
998
998
|
}
|
|
999
|
-
function
|
|
1000
|
-
|
|
999
|
+
function m(B) {
|
|
1000
|
+
B.pointerType === "mouse" && (k.value = !1);
|
|
1001
1001
|
}
|
|
1002
|
-
const
|
|
1002
|
+
const O = S(() => T.value ? "正在请求麦克风权限…" : k.value && de.value ? "发消息...(按住可语音输入)" : "发消息..."), q = S(
|
|
1003
1003
|
() => E.value ? "正在聆听…松手结束" : "正在聆听…点击结束"
|
|
1004
1004
|
);
|
|
1005
|
-
function
|
|
1006
|
-
|
|
1007
|
-
onStatusChange: (
|
|
1008
|
-
|
|
1005
|
+
function X() {
|
|
1006
|
+
A = new ot({}, {
|
|
1007
|
+
onStatusChange: (B) => {
|
|
1008
|
+
l.value = B;
|
|
1009
1009
|
},
|
|
1010
|
-
onInterim: (
|
|
1011
|
-
|
|
1010
|
+
onInterim: (B) => {
|
|
1011
|
+
g.value = B;
|
|
1012
1012
|
},
|
|
1013
|
-
onFinal: (
|
|
1014
|
-
|
|
1013
|
+
onFinal: (B) => {
|
|
1014
|
+
f.value += B, g.value = "";
|
|
1015
1015
|
},
|
|
1016
1016
|
onError: () => {
|
|
1017
1017
|
a.value = !1;
|
|
1018
1018
|
}
|
|
1019
1019
|
});
|
|
1020
1020
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}),
|
|
1024
|
-
|
|
1021
|
+
Pe(X), Lt(() => {
|
|
1022
|
+
c(), A == null || A.destroy(), A = null;
|
|
1023
|
+
}), ge([f, g], () => {
|
|
1024
|
+
Se(() => {
|
|
1025
1025
|
M.value && (M.value.scrollTop = M.value.scrollHeight);
|
|
1026
1026
|
});
|
|
1027
|
-
}),
|
|
1028
|
-
if (
|
|
1029
|
-
|
|
1027
|
+
}), ge(l, (B) => {
|
|
1028
|
+
if (B === "recording" && j) {
|
|
1029
|
+
j = !1, A == null || A.stop();
|
|
1030
1030
|
return;
|
|
1031
1031
|
}
|
|
1032
|
-
|
|
1032
|
+
B === "idle" && a.value && (r.value = (f.value + g.value).trim(), Se(() => {
|
|
1033
1033
|
var W;
|
|
1034
1034
|
return (W = C.value) == null ? void 0 : W.focus();
|
|
1035
1035
|
}));
|
|
1036
1036
|
});
|
|
1037
|
-
function
|
|
1038
|
-
s.value && (
|
|
1037
|
+
function L() {
|
|
1038
|
+
s.value && (A == null || A.stop());
|
|
1039
1039
|
}
|
|
1040
1040
|
function D() {
|
|
1041
|
-
window.removeEventListener("pointerup",
|
|
1041
|
+
window.removeEventListener("pointerup", F), window.removeEventListener("pointercancel", F), window.removeEventListener("pointermove", H), window.removeEventListener("blur", u);
|
|
1042
1042
|
}
|
|
1043
|
-
function
|
|
1044
|
-
|
|
1043
|
+
function c() {
|
|
1044
|
+
R !== null && (clearTimeout(R), R = null), y = null, D();
|
|
1045
1045
|
}
|
|
1046
1046
|
function b() {
|
|
1047
|
-
|
|
1047
|
+
l.value === "recording" ? A == null || A.stop() : (l.value === "connecting" || l.value === "stopping") && (j = !0);
|
|
1048
1048
|
}
|
|
1049
|
-
function
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1049
|
+
function x() {
|
|
1050
|
+
const B = N;
|
|
1051
|
+
N = !1, c(), B && b();
|
|
1052
1052
|
}
|
|
1053
|
-
function B
|
|
1053
|
+
function H(B) {
|
|
1054
1054
|
if (!y) return;
|
|
1055
|
-
if (
|
|
1056
|
-
|
|
1055
|
+
if (N) {
|
|
1056
|
+
B.buttons === 0 && x();
|
|
1057
1057
|
return;
|
|
1058
1058
|
}
|
|
1059
|
-
const W =
|
|
1060
|
-
Math.hypot(W,
|
|
1061
|
-
}
|
|
1062
|
-
function X() {
|
|
1063
|
-
T();
|
|
1059
|
+
const W = B.clientX - y.x, ue = B.clientY - y.y;
|
|
1060
|
+
Math.hypot(W, ue) > wo && c();
|
|
1064
1061
|
}
|
|
1065
|
-
function
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
function
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
if (
|
|
1081
|
-
|
|
1062
|
+
function F() {
|
|
1063
|
+
x();
|
|
1064
|
+
}
|
|
1065
|
+
function u() {
|
|
1066
|
+
N && x();
|
|
1067
|
+
}
|
|
1068
|
+
function p(B) {
|
|
1069
|
+
de.value && (B.pointerType === "mouse" && B.button !== 0 || (y = { x: B.clientX, y: B.clientY }, N = !1, j = !1, R !== null && clearTimeout(R), R = setTimeout(() => {
|
|
1070
|
+
var ue, Q, ve;
|
|
1071
|
+
R = null, N = !0;
|
|
1072
|
+
const W = B.target;
|
|
1073
|
+
W && typeof W.blur == "function" && W.blur(), (ve = (Q = (ue = window.getSelection) == null ? void 0 : ue.call(window)) == null ? void 0 : Q.removeAllRanges) == null || ve.call(Q), Y(!0);
|
|
1074
|
+
}, yo), window.addEventListener("pointerup", F), window.addEventListener("pointercancel", F), window.addEventListener("pointermove", H), window.addEventListener("blur", u)));
|
|
1075
|
+
}
|
|
1076
|
+
async function Y(B = !1) {
|
|
1077
|
+
if (!A || I) return;
|
|
1078
|
+
T.value = !0, I = !0;
|
|
1079
|
+
const { granted: W, prompted: ue } = await ot.ensurePermission();
|
|
1080
|
+
if (T.value = !1, I = !1, !W) {
|
|
1081
|
+
Fe("麦克风不可用,请允许浏览器使用麦克风后重试");
|
|
1082
1082
|
return;
|
|
1083
1083
|
}
|
|
1084
|
-
if (
|
|
1085
|
-
|
|
1084
|
+
if (B && !N) {
|
|
1085
|
+
ue && Fe("麦克风已开启,请重新按住输入框开始说话", "info");
|
|
1086
1086
|
return;
|
|
1087
1087
|
}
|
|
1088
|
-
E.value =
|
|
1088
|
+
E.value = B, f.value = "", g.value = "", r.value = "", a.value = !0;
|
|
1089
1089
|
try {
|
|
1090
|
-
await
|
|
1090
|
+
await A.start();
|
|
1091
1091
|
} catch {
|
|
1092
1092
|
a.value = !1;
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
|
-
function
|
|
1096
|
-
|
|
1095
|
+
function oe() {
|
|
1096
|
+
A == null || A.cancel(), a.value = !1, E.value = !1, j = !1, f.value = "", g.value = "", r.value = "";
|
|
1097
1097
|
}
|
|
1098
|
-
function
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1098
|
+
function J() {
|
|
1099
|
+
const B = (ae.value ? r.value : f.value + g.value).trim();
|
|
1100
|
+
B && (A == null || A.stop(), a.value = !1, E.value = !1, j = !1, v("update:modelValue", B), setTimeout(() => v("send"), 0));
|
|
1101
1101
|
}
|
|
1102
|
-
return (
|
|
1102
|
+
return (B, W) => a.value ? (i(), h("div", oo, [
|
|
1103
1103
|
o("div", {
|
|
1104
|
-
class:
|
|
1104
|
+
class: me(["voice-visual", { recording: le.value }])
|
|
1105
1105
|
}, null, 2),
|
|
1106
|
-
s.value ? (i(),
|
|
1106
|
+
s.value ? (i(), h("div", {
|
|
1107
1107
|
key: 0,
|
|
1108
1108
|
class: "voice-text",
|
|
1109
1109
|
ref_key: "voiceTextEl",
|
|
1110
1110
|
ref: M,
|
|
1111
|
-
onClick:
|
|
1111
|
+
onClick: L
|
|
1112
1112
|
}, [
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
!
|
|
1116
|
-
], 512)) :
|
|
1113
|
+
f.value ? (i(), h("span", io, te(f.value), 1)) : z("", !0),
|
|
1114
|
+
g.value ? (i(), h("span", lo, te(g.value), 1)) : z("", !0),
|
|
1115
|
+
!f.value && !g.value ? (i(), h("span", ro, te(V.value ? "启动中…" : q.value), 1)) : z("", !0)
|
|
1116
|
+
], 512)) : qe((i(), h("input", {
|
|
1117
1117
|
key: 1,
|
|
1118
1118
|
ref_key: "editorEl",
|
|
1119
1119
|
ref: C,
|
|
1120
|
-
"onUpdate:modelValue": W[0] || (W[0] = (
|
|
1120
|
+
"onUpdate:modelValue": W[0] || (W[0] = (ue) => r.value = ue),
|
|
1121
1121
|
type: "text",
|
|
1122
1122
|
class: "voice-editor",
|
|
1123
1123
|
placeholder: "识别结果,可点击直接修改…",
|
|
1124
|
-
onKeydown:
|
|
1125
|
-
onKeyup: W[1] || (W[1] =
|
|
1124
|
+
onKeydown: St(Le(oe, ["prevent"]), ["esc"]),
|
|
1125
|
+
onKeyup: W[1] || (W[1] = St((ue) => re.value && J(), ["enter"]))
|
|
1126
1126
|
}, null, 40, uo)), [
|
|
1127
|
-
[
|
|
1127
|
+
[gn, r.value]
|
|
1128
1128
|
]),
|
|
1129
1129
|
o("div", {
|
|
1130
1130
|
class: "tooltip-enhanced voice-close",
|
|
1131
1131
|
"data-tooltip": "关闭",
|
|
1132
|
-
onClick:
|
|
1132
|
+
onClick: oe
|
|
1133
1133
|
}, [
|
|
1134
|
-
|
|
1134
|
+
ke(Te, {
|
|
1135
1135
|
class: "op-icon",
|
|
1136
1136
|
name: "voiceClose"
|
|
1137
1137
|
})
|
|
1138
1138
|
]),
|
|
1139
1139
|
o("div", {
|
|
1140
|
-
class:
|
|
1141
|
-
"data-tooltip":
|
|
1142
|
-
onClick: W[2] || (W[2] = (
|
|
1140
|
+
class: me(["tooltip-enhanced voice-send", { disabled: !re.value }]),
|
|
1141
|
+
"data-tooltip": re.value ? "发送" : "未识别到文字",
|
|
1142
|
+
onClick: W[2] || (W[2] = (ue) => re.value && J())
|
|
1143
1143
|
}, [
|
|
1144
|
-
|
|
1144
|
+
ke(Te, {
|
|
1145
1145
|
class: "op-icon",
|
|
1146
1146
|
name: "send"
|
|
1147
1147
|
})
|
|
1148
1148
|
], 10, co),
|
|
1149
|
-
t.hasScroll && !t.isAtBottom ? (i(),
|
|
1150
|
-
|
|
1149
|
+
t.hasScroll && !t.isAtBottom ? (i(), h("div", vo, [
|
|
1150
|
+
ke(Te, {
|
|
1151
1151
|
class: "op-icon",
|
|
1152
1152
|
name: "arrowDown",
|
|
1153
|
-
onClick: W[3] || (W[3] = (
|
|
1153
|
+
onClick: W[3] || (W[3] = (ue) => B.$emit("scroll-to-bottom"))
|
|
1154
1154
|
})
|
|
1155
|
-
])) :
|
|
1156
|
-
])) : (i(),
|
|
1155
|
+
])) : z("", !0)
|
|
1156
|
+
])) : (i(), h("div", ho, [
|
|
1157
1157
|
o("input", {
|
|
1158
1158
|
value: t.modelValue,
|
|
1159
1159
|
type: "text",
|
|
1160
|
-
placeholder:
|
|
1161
|
-
onInput: W[4] || (W[4] = (
|
|
1162
|
-
onKeyup: W[5] || (W[5] =
|
|
1160
|
+
placeholder: O.value,
|
|
1161
|
+
onInput: W[4] || (W[4] = (ue) => B.$emit("update:modelValue", ue.target.value)),
|
|
1162
|
+
onKeyup: W[5] || (W[5] = St((ue) => t.modelValue.trim() && B.$emit("send"), ["enter"])),
|
|
1163
1163
|
disabled: t.isGenerating,
|
|
1164
|
-
onPointerdown:
|
|
1165
|
-
onPointerenter:
|
|
1166
|
-
onPointerleave:
|
|
1164
|
+
onPointerdown: p,
|
|
1165
|
+
onPointerenter: U,
|
|
1166
|
+
onPointerleave: m
|
|
1167
1167
|
}, null, 40, fo),
|
|
1168
|
-
t.isGenerating ? (i(),
|
|
1169
|
-
|
|
1168
|
+
t.isGenerating ? (i(), h("div", mo, [
|
|
1169
|
+
ke(Te, {
|
|
1170
1170
|
class: "op-icon stop-icon",
|
|
1171
1171
|
name: "stop",
|
|
1172
|
-
onClick: W[6] || (W[6] = (
|
|
1172
|
+
onClick: W[6] || (W[6] = (ue) => B.$emit("stop"))
|
|
1173
1173
|
})
|
|
1174
|
-
])) :
|
|
1174
|
+
])) : de.value ? (i(), h("div", {
|
|
1175
1175
|
key: 1,
|
|
1176
1176
|
class: "tooltip-enhanced send voice",
|
|
1177
1177
|
"data-tooltip": "语音输入(也可按住输入框说话)",
|
|
1178
|
-
onClick: W[7] || (W[7] = (
|
|
1178
|
+
onClick: W[7] || (W[7] = (ue) => Y())
|
|
1179
1179
|
}, [
|
|
1180
|
-
|
|
1180
|
+
ke(Te, {
|
|
1181
1181
|
class: "op-icon",
|
|
1182
1182
|
name: "voice"
|
|
1183
1183
|
})
|
|
1184
|
-
])) : (i(),
|
|
1184
|
+
])) : (i(), h("div", {
|
|
1185
1185
|
key: 2,
|
|
1186
|
-
class:
|
|
1186
|
+
class: me(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
|
|
1187
1187
|
"data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
|
|
1188
1188
|
}, [
|
|
1189
|
-
|
|
1189
|
+
ke(Te, {
|
|
1190
1190
|
class: "op-icon",
|
|
1191
1191
|
name: "send",
|
|
1192
|
-
onClick: W[8] || (W[8] = (
|
|
1192
|
+
onClick: W[8] || (W[8] = (ue) => t.modelValue.trim() && B.$emit("send"))
|
|
1193
1193
|
})
|
|
1194
1194
|
], 10, go)),
|
|
1195
|
-
t.hasScroll && !t.isAtBottom ? (i(),
|
|
1196
|
-
|
|
1195
|
+
t.hasScroll && !t.isAtBottom ? (i(), h("div", po, [
|
|
1196
|
+
ke(Te, {
|
|
1197
1197
|
class: "op-icon",
|
|
1198
1198
|
name: "arrowDown",
|
|
1199
|
-
onClick: W[9] || (W[9] = (
|
|
1199
|
+
onClick: W[9] || (W[9] = (ue) => B.$emit("scroll-to-bottom"))
|
|
1200
1200
|
})
|
|
1201
|
-
])) :
|
|
1201
|
+
])) : z("", !0)
|
|
1202
1202
|
]));
|
|
1203
1203
|
}
|
|
1204
1204
|
});
|
|
1205
1205
|
function _o(t) {
|
|
1206
1206
|
const w = _(!0), e = _(!1);
|
|
1207
|
-
function
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1210
|
-
|
|
1207
|
+
function v(g) {
|
|
1208
|
+
const l = g.closest(".chat-wrap") || g, r = g.scrollHeight, M = g.clientHeight;
|
|
1209
|
+
if (r <= M) {
|
|
1210
|
+
l.style.setProperty("--ai-thumb-height", "0px"), l.style.setProperty("--ai-thumb-top", "0px");
|
|
1211
1211
|
return;
|
|
1212
1212
|
}
|
|
1213
|
-
const C = Math.max(M * M /
|
|
1214
|
-
|
|
1213
|
+
const C = Math.max(M * M / r, 32), E = M - C, T = g.scrollTop / (r - M);
|
|
1214
|
+
l.style.setProperty("--ai-thumb-height", `${C}px`), l.style.setProperty("--ai-thumb-top", `${T * E}px`);
|
|
1215
1215
|
}
|
|
1216
1216
|
function a() {
|
|
1217
|
-
|
|
1217
|
+
Se(() => {
|
|
1218
1218
|
t.value && (t.value.scrollTop = t.value.scrollHeight);
|
|
1219
1219
|
});
|
|
1220
1220
|
}
|
|
1221
|
-
function
|
|
1221
|
+
function f() {
|
|
1222
1222
|
if (!t.value) return;
|
|
1223
|
-
const
|
|
1224
|
-
w.value =
|
|
1223
|
+
const g = t.value, l = g.scrollTop + g.clientHeight >= g.scrollHeight - 1, r = g.scrollHeight > g.clientHeight;
|
|
1224
|
+
w.value = l, e.value = r, v(g);
|
|
1225
1225
|
}
|
|
1226
|
-
return { isAtBottom: w, hasScroll: e, scrollToBottom: a, checkScrollStatus:
|
|
1226
|
+
return { isAtBottom: w, hasScroll: e, scrollToBottom: a, checkScrollStatus: f };
|
|
1227
1227
|
}
|
|
1228
1228
|
function Co() {
|
|
1229
1229
|
function t(w) {
|
|
1230
|
-
w.querySelectorAll("pre").forEach((
|
|
1231
|
-
if (
|
|
1232
|
-
const a =
|
|
1230
|
+
w.querySelectorAll("pre").forEach((v) => {
|
|
1231
|
+
if (v.querySelector(".copy-button")) return;
|
|
1232
|
+
const a = v.querySelector("code");
|
|
1233
1233
|
if (!a) return;
|
|
1234
|
-
const
|
|
1235
|
-
if (
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1234
|
+
const g = (Array.from(a.classList).find((r) => r.startsWith("language-")) || "").replace("language-", "");
|
|
1235
|
+
if (g) {
|
|
1236
|
+
const r = document.createElement("span");
|
|
1237
|
+
r.className = "code-lang", r.textContent = g, v.appendChild(r);
|
|
1238
1238
|
}
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1239
|
+
const l = document.createElement("button");
|
|
1240
|
+
l.className = "copy-button", l.textContent = "复制", l.onclick = () => {
|
|
1241
1241
|
navigator.clipboard.writeText(a.textContent || "").then(() => {
|
|
1242
|
-
|
|
1243
|
-
|
|
1242
|
+
l.textContent = "已复制", setTimeout(() => {
|
|
1243
|
+
l.textContent = "复制";
|
|
1244
1244
|
}, 2e3);
|
|
1245
1245
|
});
|
|
1246
|
-
},
|
|
1246
|
+
}, v.appendChild(l);
|
|
1247
1247
|
});
|
|
1248
1248
|
}
|
|
1249
1249
|
return { enhanceCodeBlocks: t };
|
|
1250
1250
|
}
|
|
1251
1251
|
function bo(t) {
|
|
1252
1252
|
let w = null, e = 0;
|
|
1253
|
-
function
|
|
1254
|
-
w =
|
|
1253
|
+
function v(f) {
|
|
1254
|
+
w = f(w || [...t.value]), e || (e = requestAnimationFrame(() => {
|
|
1255
1255
|
e = 0, w && (t.value = w, w = null);
|
|
1256
1256
|
}));
|
|
1257
1257
|
}
|
|
1258
1258
|
function a() {
|
|
1259
1259
|
e && (cancelAnimationFrame(e), e = 0), w && (t.value = w, w = null);
|
|
1260
1260
|
}
|
|
1261
|
-
return { batchMessagesUpdate:
|
|
1261
|
+
return { batchMessagesUpdate: v, flushMessagesBatch: a };
|
|
1262
1262
|
}
|
|
1263
1263
|
function Mo({
|
|
1264
1264
|
messages: t,
|
|
1265
1265
|
isGenerating: w,
|
|
1266
1266
|
lastUserMessage: e,
|
|
1267
|
-
batchMessagesUpdate:
|
|
1267
|
+
batchMessagesUpdate: v,
|
|
1268
1268
|
flushMessagesBatch: a,
|
|
1269
|
-
STATUS:
|
|
1270
|
-
cfg:
|
|
1269
|
+
STATUS: f,
|
|
1270
|
+
cfg: g
|
|
1271
1271
|
}) {
|
|
1272
|
-
const
|
|
1273
|
-
function y(
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1276
|
-
if (s[
|
|
1277
|
-
const
|
|
1278
|
-
return
|
|
1272
|
+
const l = _(/* @__PURE__ */ new Map()), r = _(/* @__PURE__ */ new Map()), M = _(/* @__PURE__ */ new Map()), C = _(/* @__PURE__ */ new Map()), E = _(!1), T = _(/* @__PURE__ */ new Map()), I = _(/* @__PURE__ */ new Map()), R = _(!1);
|
|
1273
|
+
function y(V) {
|
|
1274
|
+
const le = l.value.get(V) || [];
|
|
1275
|
+
v((s) => {
|
|
1276
|
+
if (s[V]) {
|
|
1277
|
+
const ae = [...s];
|
|
1278
|
+
return ae[V] = { ...ae[V], segments: le.map((re) => ({ ...re })) }, ae;
|
|
1279
1279
|
}
|
|
1280
1280
|
return s;
|
|
1281
1281
|
});
|
|
1282
1282
|
}
|
|
1283
|
-
function
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
const
|
|
1287
|
-
if (!
|
|
1283
|
+
function N(V) {
|
|
1284
|
+
const le = Date.now();
|
|
1285
|
+
v((s) => {
|
|
1286
|
+
const ae = s[V];
|
|
1287
|
+
if (!ae || ae.status === f.COMPLETED || ae.status === f.STOP || ae.status === f.ERROR)
|
|
1288
1288
|
return s;
|
|
1289
|
-
const
|
|
1290
|
-
return
|
|
1289
|
+
const re = [...s];
|
|
1290
|
+
return re[V] = { ...ae, lastChunkAt: le }, re;
|
|
1291
1291
|
});
|
|
1292
1292
|
}
|
|
1293
|
-
function
|
|
1294
|
-
const
|
|
1295
|
-
let
|
|
1296
|
-
|
|
1293
|
+
function j(V) {
|
|
1294
|
+
const le = l.value.get(V) || [], s = M.value.get(V), ae = I.value.get(V);
|
|
1295
|
+
let re = 0, de = !1;
|
|
1296
|
+
le.forEach((k) => {
|
|
1297
1297
|
if ((k.type === "thinking" || k.type === "step") && k.duration == null) {
|
|
1298
|
-
const
|
|
1299
|
-
k.duration =
|
|
1298
|
+
const m = (k.id != null ? ae == null ? void 0 : ae.get(k.id) : void 0) ?? s, O = m ? Math.round((Date.now() - m) / 1e3 * 10) / 10 : 0;
|
|
1299
|
+
k.duration = O, k.type === "thinking" && (re += O), de = !0;
|
|
1300
1300
|
}
|
|
1301
|
-
}),
|
|
1302
|
-
if (k[
|
|
1303
|
-
const
|
|
1304
|
-
return
|
|
1305
|
-
...
|
|
1306
|
-
segments:
|
|
1307
|
-
thinkingDuration: (
|
|
1308
|
-
},
|
|
1301
|
+
}), de && (l.value.set(V, le), v((k) => {
|
|
1302
|
+
if (k[V]) {
|
|
1303
|
+
const U = [...k];
|
|
1304
|
+
return U[V] = {
|
|
1305
|
+
...U[V],
|
|
1306
|
+
segments: le.map((m) => ({ ...m })),
|
|
1307
|
+
thinkingDuration: (U[V].thinkingDuration || 0) + re
|
|
1308
|
+
}, U;
|
|
1309
1309
|
}
|
|
1310
1310
|
return k;
|
|
1311
1311
|
}));
|
|
1312
1312
|
}
|
|
1313
|
-
async function
|
|
1314
|
-
|
|
1313
|
+
async function A(V, le, s, ae, re = !1) {
|
|
1314
|
+
R.value = !1, E.value = !1, l.value.set(s, []), T.value.set(s, /* @__PURE__ */ new Map()), I.value.set(s, /* @__PURE__ */ new Map()), w.value = !0;
|
|
1315
1315
|
try {
|
|
1316
|
-
const
|
|
1317
|
-
await
|
|
1316
|
+
const de = g.baseUrl.replace(/\/+$/, "") + "/" + V.replace(/^\/+/, "");
|
|
1317
|
+
await As(de, {
|
|
1318
1318
|
method: "POST",
|
|
1319
1319
|
headers: {
|
|
1320
1320
|
"Content-Type": "application/json",
|
|
1321
|
-
Authorization: `Bearer ${
|
|
1321
|
+
Authorization: `Bearer ${g.token}`
|
|
1322
1322
|
},
|
|
1323
|
-
body: JSON.stringify({ app:
|
|
1324
|
-
signal:
|
|
1323
|
+
body: JSON.stringify({ app: g.app ?? 1, data: le }),
|
|
1324
|
+
signal: ae,
|
|
1325
1325
|
openWhenHidden: !0,
|
|
1326
1326
|
async onopen(k) {
|
|
1327
1327
|
k.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", k.status, k.statusText);
|
|
1328
1328
|
},
|
|
1329
1329
|
onmessage(k) {
|
|
1330
|
-
var
|
|
1330
|
+
var U, m, O, q, X;
|
|
1331
1331
|
try {
|
|
1332
|
-
let
|
|
1333
|
-
for (;
|
|
1334
|
-
|
|
1335
|
-
if (!
|
|
1332
|
+
let L = k.data || "";
|
|
1333
|
+
for (; L.startsWith("data:"); )
|
|
1334
|
+
L = L.replace(/^data:\s*/, "");
|
|
1335
|
+
if (!L) return;
|
|
1336
1336
|
let D;
|
|
1337
1337
|
try {
|
|
1338
|
-
D = JSON.parse(
|
|
1338
|
+
D = JSON.parse(L);
|
|
1339
1339
|
} catch {
|
|
1340
1340
|
return;
|
|
1341
1341
|
}
|
|
1342
|
-
switch (
|
|
1342
|
+
switch (N(s), D.event) {
|
|
1343
1343
|
case "message_start":
|
|
1344
|
-
|
|
1344
|
+
re || (e.value = D.id), r.value.set(s, "answer");
|
|
1345
1345
|
break;
|
|
1346
1346
|
// ── 对话流型智能体:流程开始,标记进入 flow 协议 ──
|
|
1347
1347
|
case "flow_start":
|
|
1348
1348
|
E.value = !0;
|
|
1349
1349
|
break;
|
|
1350
1350
|
case "think_message_output_start": {
|
|
1351
|
-
M.value.set(s, Date.now()),
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1351
|
+
M.value.set(s, Date.now()), r.value.set(s, "thinking");
|
|
1352
|
+
const c = l.value.get(s) || [];
|
|
1353
|
+
l.value.set(s, [...c, { type: "thinking", content: "" }]), y(s);
|
|
1354
1354
|
break;
|
|
1355
1355
|
}
|
|
1356
1356
|
case "agent_thought": {
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
if (
|
|
1360
|
-
const
|
|
1361
|
-
return
|
|
1362
|
-
...
|
|
1363
|
-
segments: b.map((
|
|
1364
|
-
thinkingContent: (
|
|
1365
|
-
status:
|
|
1366
|
-
},
|
|
1357
|
+
const c = D.thought || D.thinking || "", b = l.value.get(s) || [], x = b[b.length - 1];
|
|
1358
|
+
x && x.type === "agent_thought" && x.duration == null ? x.content += c : (r.value.set(s, "agent_thought"), b.push({ type: "agent_thought", content: c }), C.value.set(s, Date.now())), l.value.set(s, b), v((H) => {
|
|
1359
|
+
if (H[s]) {
|
|
1360
|
+
const F = [...H];
|
|
1361
|
+
return F[s] = {
|
|
1362
|
+
...F[s],
|
|
1363
|
+
segments: b.map((u) => ({ ...u })),
|
|
1364
|
+
thinkingContent: (F[s].thinkingContent || "") + c,
|
|
1365
|
+
status: f.THINKING
|
|
1366
|
+
}, F;
|
|
1367
1367
|
}
|
|
1368
|
-
return
|
|
1368
|
+
return H;
|
|
1369
1369
|
});
|
|
1370
1370
|
break;
|
|
1371
1371
|
}
|
|
1372
1372
|
case "think_message": {
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1375
|
-
if (
|
|
1376
|
-
const
|
|
1377
|
-
return
|
|
1378
|
-
...
|
|
1379
|
-
segments: b.map((
|
|
1380
|
-
thinkingContent: (
|
|
1381
|
-
status:
|
|
1382
|
-
},
|
|
1373
|
+
const c = D.thinking || D.answer || D.text || "", b = l.value.get(s) || [], x = b[b.length - 1];
|
|
1374
|
+
x && x.type === "thinking" ? x.content += c : (b.push({ type: "thinking", content: c }), M.value.set(s, Date.now())), l.value.set(s, b), v((H) => {
|
|
1375
|
+
if (H[s]) {
|
|
1376
|
+
const F = [...H];
|
|
1377
|
+
return F[s] = {
|
|
1378
|
+
...F[s],
|
|
1379
|
+
segments: b.map((u) => ({ ...u })),
|
|
1380
|
+
thinkingContent: (F[s].thinkingContent || "") + c,
|
|
1381
|
+
status: f.THINKING
|
|
1382
|
+
}, F;
|
|
1383
1383
|
}
|
|
1384
|
-
return
|
|
1384
|
+
return H;
|
|
1385
1385
|
});
|
|
1386
1386
|
break;
|
|
1387
1387
|
}
|
|
1388
1388
|
case "agent_thought_end": {
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
if (
|
|
1392
|
-
const
|
|
1393
|
-
return
|
|
1394
|
-
...
|
|
1395
|
-
segments:
|
|
1396
|
-
thinkingDuration: (
|
|
1397
|
-
},
|
|
1389
|
+
const c = C.value.get(s), b = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, x = l.value.get(s) || [], H = x[x.length - 1];
|
|
1390
|
+
H && H.type === "agent_thought" && (H.duration = b), l.value.set(s, x), v((F) => {
|
|
1391
|
+
if (F[s]) {
|
|
1392
|
+
const u = [...F];
|
|
1393
|
+
return u[s] = {
|
|
1394
|
+
...u[s],
|
|
1395
|
+
segments: x.map((p) => ({ ...p })),
|
|
1396
|
+
thinkingDuration: (u[s].thinkingDuration || 0) + b
|
|
1397
|
+
}, u;
|
|
1398
1398
|
}
|
|
1399
|
-
return
|
|
1399
|
+
return F;
|
|
1400
1400
|
});
|
|
1401
1401
|
break;
|
|
1402
1402
|
}
|
|
1403
1403
|
case "think_message_output_end": {
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1406
|
-
if (
|
|
1407
|
-
const
|
|
1408
|
-
return
|
|
1409
|
-
...
|
|
1410
|
-
segments:
|
|
1411
|
-
thinkingDuration: (
|
|
1412
|
-
},
|
|
1404
|
+
const c = M.value.get(s), b = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, x = l.value.get(s) || [], H = x[x.length - 1];
|
|
1405
|
+
H && H.type === "thinking" && (H.duration = b), l.value.set(s, x), v((F) => {
|
|
1406
|
+
if (F[s]) {
|
|
1407
|
+
const u = [...F];
|
|
1408
|
+
return u[s] = {
|
|
1409
|
+
...u[s],
|
|
1410
|
+
segments: x.map((p) => ({ ...p })),
|
|
1411
|
+
thinkingDuration: (u[s].thinkingDuration || 0) + b
|
|
1412
|
+
}, u;
|
|
1413
1413
|
}
|
|
1414
|
-
return
|
|
1414
|
+
return F;
|
|
1415
1415
|
});
|
|
1416
1416
|
break;
|
|
1417
1417
|
}
|
|
@@ -1420,153 +1420,153 @@ function Mo({
|
|
|
1420
1420
|
// 其余(執行準備/資料獲取/...)归入流程步骤。
|
|
1421
1421
|
case "tool_message_output_start": {
|
|
1422
1422
|
E.value = !0;
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1425
|
-
type:
|
|
1423
|
+
const c = ((U = D.message_config) == null ? void 0 : U.reasoning) === !0 || D.reasoning === !0, b = Date.now(), x = l.value.get(s) || [];
|
|
1424
|
+
x.push({
|
|
1425
|
+
type: c ? "thinking" : "step",
|
|
1426
1426
|
title: D.message_title || "",
|
|
1427
1427
|
id: D.id,
|
|
1428
1428
|
content: "",
|
|
1429
|
-
reasoning:
|
|
1429
|
+
reasoning: c
|
|
1430
1430
|
});
|
|
1431
|
-
const
|
|
1432
|
-
if (
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1431
|
+
const H = x.length - 1;
|
|
1432
|
+
if (l.value.set(s, x), r.value.set(s, c ? "thinking" : "step"), D.id != null) {
|
|
1433
|
+
const F = T.value.get(s) || /* @__PURE__ */ new Map();
|
|
1434
|
+
F.set(String(D.id), H), T.value.set(s, F);
|
|
1435
|
+
const u = I.value.get(s) || /* @__PURE__ */ new Map();
|
|
1436
|
+
u.set(String(D.id), b), I.value.set(s, u);
|
|
1437
1437
|
}
|
|
1438
|
-
|
|
1438
|
+
c && M.value.set(s, b), y(s);
|
|
1439
1439
|
break;
|
|
1440
1440
|
}
|
|
1441
1441
|
case "tool_message": {
|
|
1442
|
-
const
|
|
1443
|
-
if (!
|
|
1444
|
-
const b =
|
|
1442
|
+
const c = D.answer || D.text || D.content || "";
|
|
1443
|
+
if (!c) break;
|
|
1444
|
+
const b = l.value.get(s) || [];
|
|
1445
1445
|
if (E.value) {
|
|
1446
|
-
const
|
|
1447
|
-
let
|
|
1448
|
-
if (
|
|
1449
|
-
const
|
|
1446
|
+
const x = D.id != null ? String(D.id) : null, H = T.value.get(s);
|
|
1447
|
+
let F = x != null ? H == null ? void 0 : H.get(x) : void 0;
|
|
1448
|
+
if (F == null || !b[F]) {
|
|
1449
|
+
const u = ((m = D.message_config) == null ? void 0 : m.reasoning) === !0 || D.reasoning === !0;
|
|
1450
1450
|
if (b.push({
|
|
1451
|
-
type:
|
|
1451
|
+
type: u ? "thinking" : "step",
|
|
1452
1452
|
title: D.message_title || "",
|
|
1453
1453
|
id: D.id,
|
|
1454
|
-
content:
|
|
1455
|
-
reasoning:
|
|
1456
|
-
}),
|
|
1457
|
-
const
|
|
1458
|
-
|
|
1454
|
+
content: c,
|
|
1455
|
+
reasoning: u
|
|
1456
|
+
}), F = b.length - 1, x != null) {
|
|
1457
|
+
const p = H || /* @__PURE__ */ new Map();
|
|
1458
|
+
p.set(x, F), T.value.set(s, p), u && M.value.set(s, Date.now());
|
|
1459
1459
|
}
|
|
1460
1460
|
} else {
|
|
1461
|
-
const
|
|
1462
|
-
b[
|
|
1461
|
+
const u = b[F];
|
|
1462
|
+
b[F] = { ...u, content: u.content + c };
|
|
1463
1463
|
}
|
|
1464
|
-
|
|
1465
|
-
if (
|
|
1466
|
-
const
|
|
1467
|
-
return
|
|
1468
|
-
...
|
|
1469
|
-
segments: b.map((
|
|
1470
|
-
status:
|
|
1471
|
-
},
|
|
1464
|
+
l.value.set(s, b), v((u) => {
|
|
1465
|
+
if (u[s]) {
|
|
1466
|
+
const p = [...u];
|
|
1467
|
+
return p[s] = {
|
|
1468
|
+
...p[s],
|
|
1469
|
+
segments: b.map((Y) => ({ ...Y })),
|
|
1470
|
+
status: f.THINKING
|
|
1471
|
+
}, p;
|
|
1472
1472
|
}
|
|
1473
|
-
return
|
|
1473
|
+
return u;
|
|
1474
1474
|
});
|
|
1475
1475
|
break;
|
|
1476
1476
|
}
|
|
1477
|
-
b.push({ type: "answer", content:
|
|
1477
|
+
b.push({ type: "answer", content: c }), l.value.set(s, b), y(s);
|
|
1478
1478
|
break;
|
|
1479
1479
|
}
|
|
1480
1480
|
// ── 对话流型智能体:步骤/推理消息结束,记录该步骤耗时 ──
|
|
1481
1481
|
case "tool_message_output_end": {
|
|
1482
|
-
const
|
|
1483
|
-
let
|
|
1484
|
-
(
|
|
1485
|
-
const
|
|
1486
|
-
let
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
if (
|
|
1490
|
-
const
|
|
1491
|
-
return
|
|
1492
|
-
...
|
|
1493
|
-
segments:
|
|
1494
|
-
...
|
|
1495
|
-
},
|
|
1482
|
+
const c = l.value.get(s) || [], b = D.id != null ? String(D.id) : null;
|
|
1483
|
+
let x = b != null ? (O = T.value.get(s)) == null ? void 0 : O.get(b) : c.length - 1;
|
|
1484
|
+
(x == null || !c[x]) && (x = c.length - 1);
|
|
1485
|
+
const H = (b != null ? (q = I.value.get(s)) == null ? void 0 : q.get(b) : void 0) ?? M.value.get(s), F = H ? Math.round((Date.now() - H) / 1e3 * 10) / 10 : 0;
|
|
1486
|
+
let u = 0;
|
|
1487
|
+
const p = c[x];
|
|
1488
|
+
p && p.duration == null && (c[x] = { ...p, duration: F }, p.type === "thinking" && (u = F)), l.value.set(s, c), v((Y) => {
|
|
1489
|
+
if (Y[s]) {
|
|
1490
|
+
const oe = [...Y];
|
|
1491
|
+
return oe[s] = {
|
|
1492
|
+
...oe[s],
|
|
1493
|
+
segments: c.map((J) => ({ ...J })),
|
|
1494
|
+
...u ? { thinkingDuration: (oe[s].thinkingDuration || 0) + u } : {}
|
|
1495
|
+
}, oe;
|
|
1496
1496
|
}
|
|
1497
|
-
return
|
|
1497
|
+
return Y;
|
|
1498
1498
|
});
|
|
1499
1499
|
break;
|
|
1500
1500
|
}
|
|
1501
1501
|
case "message_output_start":
|
|
1502
|
-
|
|
1502
|
+
r.value.set(s, "answer"), j(s);
|
|
1503
1503
|
break;
|
|
1504
1504
|
// 对话流型智能体:回答输出结束 / 流程结束(状态统一由 message_end 收尾)
|
|
1505
1505
|
case "message_output_end":
|
|
1506
1506
|
case "flow_end":
|
|
1507
1507
|
break;
|
|
1508
1508
|
case "message": {
|
|
1509
|
-
const
|
|
1510
|
-
b === "answer" &&
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
if (
|
|
1514
|
-
const
|
|
1515
|
-
return
|
|
1516
|
-
...
|
|
1517
|
-
segments:
|
|
1518
|
-
content:
|
|
1519
|
-
status:
|
|
1520
|
-
},
|
|
1509
|
+
const c = D.answer || "", b = r.value.get(s), x = l.value.get(s) || [], H = x[x.length - 1];
|
|
1510
|
+
b === "answer" && H && H.type === "answer" ? H.content += c : (j(s), r.value.set(s, "answer"), x.push({ type: "answer", content: c })), l.value.set(s, x);
|
|
1511
|
+
const F = x.filter((u) => u.type === "answer").map((u) => u.content).join("");
|
|
1512
|
+
v((u) => {
|
|
1513
|
+
if (u[s]) {
|
|
1514
|
+
const p = [...u];
|
|
1515
|
+
return p[s] = {
|
|
1516
|
+
...p[s],
|
|
1517
|
+
segments: x.map((Y) => ({ ...Y })),
|
|
1518
|
+
content: F,
|
|
1519
|
+
status: R.value ? f.STOP : f.ANSWERING
|
|
1520
|
+
}, p;
|
|
1521
1521
|
}
|
|
1522
|
-
return
|
|
1522
|
+
return u;
|
|
1523
1523
|
});
|
|
1524
1524
|
break;
|
|
1525
1525
|
}
|
|
1526
1526
|
case "message_end": {
|
|
1527
1527
|
a();
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1528
|
+
const c = [...t.value];
|
|
1529
|
+
c[s] && (c[s] = { ...c[s], status: R.value ? f.STOP : f.COMPLETED }), t.value = c, w.value = !1;
|
|
1530
1530
|
break;
|
|
1531
1531
|
}
|
|
1532
1532
|
case "agent_error":
|
|
1533
1533
|
case "message_failed": {
|
|
1534
1534
|
a();
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
...
|
|
1538
|
-
status:
|
|
1535
|
+
const c = [...t.value];
|
|
1536
|
+
c[s] && (c[s] = {
|
|
1537
|
+
...c[s],
|
|
1538
|
+
status: f.ERROR,
|
|
1539
1539
|
content: D.error_msg || D.message || "请求失败",
|
|
1540
1540
|
errorMessage: D.error_msg || D.message || "请求失败"
|
|
1541
|
-
}, t.value =
|
|
1541
|
+
}, t.value = c), w.value = !1;
|
|
1542
1542
|
break;
|
|
1543
1543
|
}
|
|
1544
1544
|
case "message_replace": {
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1547
|
-
if (
|
|
1548
|
-
const
|
|
1549
|
-
return
|
|
1550
|
-
...
|
|
1551
|
-
segments: b.map((
|
|
1552
|
-
content:
|
|
1553
|
-
},
|
|
1545
|
+
const c = D.answer || "", b = l.value.get(s) || [], x = (X = b.map((H, F) => ({ s: H, i: F })).reverse().find((H) => H.s.type === "answer")) == null ? void 0 : X.i;
|
|
1546
|
+
x != null ? b[x] = { ...b[x], content: c } : b.push({ type: "answer", content: c }), l.value.set(s, b), v((H) => {
|
|
1547
|
+
if (H[s]) {
|
|
1548
|
+
const F = [...H];
|
|
1549
|
+
return F[s] = {
|
|
1550
|
+
...F[s],
|
|
1551
|
+
segments: b.map((u) => ({ ...u })),
|
|
1552
|
+
content: c
|
|
1553
|
+
}, F;
|
|
1554
1554
|
}
|
|
1555
|
-
return
|
|
1555
|
+
return H;
|
|
1556
1556
|
});
|
|
1557
1557
|
break;
|
|
1558
1558
|
}
|
|
1559
1559
|
case "message_cost": {
|
|
1560
|
-
const
|
|
1560
|
+
const c = {
|
|
1561
1561
|
inputTokens: D.input_tokens || 0,
|
|
1562
1562
|
outputTokens: D.output_tokens || 0,
|
|
1563
1563
|
latency: D.latency || 0,
|
|
1564
1564
|
latencyFirstResp: D.latency_first_resp
|
|
1565
1565
|
};
|
|
1566
|
-
|
|
1566
|
+
v((b) => {
|
|
1567
1567
|
if (b[s]) {
|
|
1568
|
-
const
|
|
1569
|
-
return
|
|
1568
|
+
const x = [...b];
|
|
1569
|
+
return x[s] = { ...x[s], cost: c }, x;
|
|
1570
1570
|
}
|
|
1571
1571
|
return b;
|
|
1572
1572
|
});
|
|
@@ -1574,35 +1574,35 @@ function Mo({
|
|
|
1574
1574
|
}
|
|
1575
1575
|
default:
|
|
1576
1576
|
}
|
|
1577
|
-
} catch (
|
|
1578
|
-
console.error("[ai-assist-sdk] onmessage 解析失败:",
|
|
1577
|
+
} catch (L) {
|
|
1578
|
+
console.error("[ai-assist-sdk] onmessage 解析失败:", L);
|
|
1579
1579
|
}
|
|
1580
1580
|
},
|
|
1581
1581
|
onclose() {
|
|
1582
|
-
a(),
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
...
|
|
1586
|
-
content:
|
|
1587
|
-
status:
|
|
1588
|
-
}), t.value =
|
|
1582
|
+
a(), j(s), a();
|
|
1583
|
+
const U = (l.value.get(s) || []).filter((O) => O.type === "answer").map((O) => O.content).join(""), m = [...t.value];
|
|
1584
|
+
m[s] && m[s].status !== f.ERROR && (m[s] = {
|
|
1585
|
+
...m[s],
|
|
1586
|
+
content: R.value && !U ? "已停止回答" : U,
|
|
1587
|
+
status: R.value ? f.STOP : f.COMPLETED
|
|
1588
|
+
}), t.value = m, w.value = !1;
|
|
1589
1589
|
},
|
|
1590
1590
|
onerror(k) {
|
|
1591
1591
|
console.error("[ai-assist-sdk] ❌ 连接错误:", k), a();
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
⚠️ 请求异常,已终止`, status:
|
|
1592
|
+
const U = [...t.value];
|
|
1593
|
+
U[s] && (U[s] = { ...U[s], content: `
|
|
1594
|
+
⚠️ 请求异常,已终止`, status: f.ERROR }), t.value = U, w.value = !1;
|
|
1595
1595
|
}
|
|
1596
1596
|
});
|
|
1597
|
-
} catch (
|
|
1598
|
-
if (console.error("[ai-assist-sdk] doStreamRequest error:",
|
|
1597
|
+
} catch (de) {
|
|
1598
|
+
if (console.error("[ai-assist-sdk] doStreamRequest error:", de), !R.value) {
|
|
1599
1599
|
a();
|
|
1600
1600
|
const k = [...t.value];
|
|
1601
|
-
k[s] && (k[s] = { ...k[s], content: "服务连接失败,请稍后重试", status:
|
|
1601
|
+
k[s] && (k[s] = { ...k[s], content: "服务连接失败,请稍后重试", status: f.ERROR }), t.value = k, w.value = !1;
|
|
1602
1602
|
}
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
|
-
return { doStreamRequest:
|
|
1605
|
+
return { doStreamRequest: A, issTop: R };
|
|
1606
1606
|
}
|
|
1607
1607
|
function $o(t) {
|
|
1608
1608
|
return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
|
|
@@ -1611,459 +1611,505 @@ function So({
|
|
|
1611
1611
|
messages: t,
|
|
1612
1612
|
userInput: w,
|
|
1613
1613
|
isGenerating: e,
|
|
1614
|
-
lastUserMessage:
|
|
1614
|
+
lastUserMessage: v,
|
|
1615
1615
|
conversationId: a,
|
|
1616
|
-
doStreamRequest:
|
|
1617
|
-
issTop:
|
|
1618
|
-
scrollToBottom:
|
|
1619
|
-
STATUS:
|
|
1616
|
+
doStreamRequest: f,
|
|
1617
|
+
issTop: g,
|
|
1618
|
+
scrollToBottom: l,
|
|
1619
|
+
STATUS: r,
|
|
1620
1620
|
cfg: M,
|
|
1621
1621
|
onTitleGenerated: C
|
|
1622
1622
|
}) {
|
|
1623
|
-
const E = M.apis,
|
|
1623
|
+
const E = M.apis, T = He({
|
|
1624
1624
|
first: new AbortController(),
|
|
1625
1625
|
again: new AbortController()
|
|
1626
|
-
}), I = _(!1),
|
|
1627
|
-
let y = 0,
|
|
1628
|
-
function
|
|
1629
|
-
var
|
|
1630
|
-
return
|
|
1626
|
+
}), I = _(!1), R = _("");
|
|
1627
|
+
let y = 0, N = null;
|
|
1628
|
+
function j() {
|
|
1629
|
+
var m;
|
|
1630
|
+
return Ct() === "page" && !!((m = Ve()) != null && m.api);
|
|
1631
1631
|
}
|
|
1632
|
-
async function
|
|
1633
|
-
var
|
|
1634
|
-
const
|
|
1635
|
-
if (!
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1632
|
+
async function A(m, O) {
|
|
1633
|
+
var G, ne;
|
|
1634
|
+
const q = (G = Ve()) == null ? void 0 : G.api;
|
|
1635
|
+
if (!q) return;
|
|
1636
|
+
const X = We(), L = ++y;
|
|
1637
|
+
N == null || N.abort();
|
|
1638
1638
|
const D = new AbortController();
|
|
1639
|
-
|
|
1640
|
-
const
|
|
1641
|
-
var
|
|
1642
|
-
const
|
|
1643
|
-
if (((
|
|
1644
|
-
for (let
|
|
1645
|
-
if (
|
|
1639
|
+
N = D, e.value = !0;
|
|
1640
|
+
const c = () => {
|
|
1641
|
+
var se;
|
|
1642
|
+
const P = t.value;
|
|
1643
|
+
if (((se = P[O]) == null ? void 0 : se.type) === "ai") return O;
|
|
1644
|
+
for (let ee = P.length - 1; ee >= 0; ee -= 1)
|
|
1645
|
+
if (P[ee].type === "ai") return ee;
|
|
1646
1646
|
return -1;
|
|
1647
|
-
}, b = (
|
|
1648
|
-
if (
|
|
1649
|
-
const
|
|
1650
|
-
if (
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
},
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1647
|
+
}, b = (P, se = !1) => {
|
|
1648
|
+
if (L !== y) return;
|
|
1649
|
+
const ee = c();
|
|
1650
|
+
if (ee < 0) return;
|
|
1651
|
+
const Z = [...t.value];
|
|
1652
|
+
Z[ee] = P(Z[ee]), t.value = Z, se && l();
|
|
1653
|
+
}, x = (P, se) => b((ee) => ({ ...ee, content: P, status: se }), !0);
|
|
1654
|
+
let H = "", F = 0, u = null;
|
|
1655
|
+
const p = () => {
|
|
1656
|
+
u && (clearInterval(u), u = null);
|
|
1657
|
+
}, Y = (P, se) => {
|
|
1658
|
+
H = P, F = Date.now(), b((ee) => {
|
|
1659
|
+
var Z;
|
|
1660
|
+
return {
|
|
1661
|
+
...ee,
|
|
1662
|
+
toolState: { name: se || ((Z = ee.toolState) == null ? void 0 : Z.name) || "status", status: "running", message: P }
|
|
1663
|
+
};
|
|
1664
|
+
}), p(), u = setInterval(() => {
|
|
1665
|
+
if (L !== y || !H) return;
|
|
1666
|
+
const ee = Math.round((Date.now() - F) / 1e3);
|
|
1667
|
+
ee < 2 || b((Z) => {
|
|
1668
|
+
var _e;
|
|
1662
1669
|
return {
|
|
1663
|
-
...
|
|
1670
|
+
...Z,
|
|
1664
1671
|
toolState: {
|
|
1665
|
-
name: ((
|
|
1666
|
-
status:
|
|
1667
|
-
message:
|
|
1672
|
+
name: ((_e = Z.toolState) == null ? void 0 : _e.name) || "status",
|
|
1673
|
+
status: "running",
|
|
1674
|
+
message: `${H}(已用 ${ee}s)`
|
|
1668
1675
|
}
|
|
1669
1676
|
};
|
|
1670
1677
|
});
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1678
|
+
}, 1e3);
|
|
1679
|
+
};
|
|
1680
|
+
let oe = "", J = "", B = null;
|
|
1681
|
+
const W = () => {
|
|
1682
|
+
B && (clearInterval(B), B = null);
|
|
1683
|
+
}, ue = () => {
|
|
1684
|
+
const P = rn(oe);
|
|
1685
|
+
if (P.length <= J.length) return;
|
|
1686
|
+
const se = Math.max(2, Math.ceil((P.length - J.length) / 12));
|
|
1687
|
+
J = P.slice(0, J.length + se), x(J, r.ANSWERING);
|
|
1688
|
+
}, Q = () => {
|
|
1689
|
+
B || (B = setInterval(ue, 24));
|
|
1690
|
+
}, ve = () => {
|
|
1691
|
+
W();
|
|
1692
|
+
const P = rn(oe);
|
|
1693
|
+
P !== J && (J = P, x(J, r.ANSWERING));
|
|
1694
|
+
}, fe = (P) => {
|
|
1695
|
+
if (P.type === "status")
|
|
1696
|
+
Y(P.message || "正在处理…");
|
|
1697
|
+
else if (P.type === "tool")
|
|
1698
|
+
Y(P.message || "正在查询数据…", P.name);
|
|
1699
|
+
else if (P.type === "tool_result")
|
|
1700
|
+
p(), H = "", b((se) => {
|
|
1701
|
+
var ee;
|
|
1702
|
+
return {
|
|
1703
|
+
...se,
|
|
1704
|
+
toolState: {
|
|
1705
|
+
name: ((ee = se.toolState) == null ? void 0 : ee.name) || "turnover_trend",
|
|
1706
|
+
status: P.ok ? "done" : "failed",
|
|
1707
|
+
message: P.summary
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
});
|
|
1711
|
+
else if (P.type === "chart") {
|
|
1712
|
+
const se = { chartId: P.chartId, option: P.option };
|
|
1713
|
+
b((ee) => ({
|
|
1714
|
+
...ee,
|
|
1715
|
+
charts: [...(ee.charts || []).filter((Z) => Z.chartId !== se.chartId), se]
|
|
1676
1716
|
}));
|
|
1677
1717
|
}
|
|
1678
1718
|
};
|
|
1679
1719
|
try {
|
|
1680
|
-
let
|
|
1681
|
-
if (
|
|
1682
|
-
const
|
|
1683
|
-
if (
|
|
1684
|
-
let
|
|
1685
|
-
const
|
|
1686
|
-
module:
|
|
1687
|
-
threadId:
|
|
1688
|
-
question:
|
|
1689
|
-
pageContext:
|
|
1720
|
+
let P = Rt(X);
|
|
1721
|
+
if (P || (P = await q.createThread({ module: X }), xt(P, X)), L !== y) return;
|
|
1722
|
+
const se = await _t();
|
|
1723
|
+
if (L !== y) return;
|
|
1724
|
+
let ee = "";
|
|
1725
|
+
const Z = q.chatStream ? await q.chatStream({
|
|
1726
|
+
module: X,
|
|
1727
|
+
threadId: P,
|
|
1728
|
+
question: m,
|
|
1729
|
+
pageContext: se,
|
|
1690
1730
|
signal: D.signal,
|
|
1691
|
-
onMeta: (
|
|
1692
|
-
|
|
1731
|
+
onMeta: (Oe) => {
|
|
1732
|
+
Oe != null && Oe.threadId && xt(Oe.threadId, X);
|
|
1693
1733
|
},
|
|
1694
|
-
onDelta: (
|
|
1695
|
-
|
|
1734
|
+
onDelta: (Oe) => {
|
|
1735
|
+
ee += Oe, oe = ee, Q();
|
|
1696
1736
|
},
|
|
1697
|
-
onEvent:
|
|
1698
|
-
}) : await
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1701
|
-
const
|
|
1702
|
-
if (
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1737
|
+
onEvent: fe
|
|
1738
|
+
}) : await q.chat({ module: X, threadId: P, question: m, pageContext: se });
|
|
1739
|
+
if (L !== y) return;
|
|
1740
|
+
Z != null && Z.threadId && xt(Z.threadId, X), p(), ve();
|
|
1741
|
+
const _e = Bs((Z == null ? void 0 : Z.content) || ee), Re = c();
|
|
1742
|
+
if (Re < 0) return;
|
|
1743
|
+
const Ne = [...t.value], be = Ne[Re];
|
|
1744
|
+
Ne[Re] = {
|
|
1705
1745
|
type: "ai",
|
|
1706
|
-
content:
|
|
1707
|
-
status:
|
|
1708
|
-
actions:
|
|
1709
|
-
suggestions:
|
|
1710
|
-
files: (
|
|
1746
|
+
content: _e.answer,
|
|
1747
|
+
status: r.COMPLETED,
|
|
1748
|
+
actions: _e.actions,
|
|
1749
|
+
suggestions: _e.suggestions,
|
|
1750
|
+
files: (Z == null ? void 0 : Z.files) ?? [],
|
|
1711
1751
|
// 图表始终并入当前回答消息,不新开气泡
|
|
1712
|
-
charts: (
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1752
|
+
charts: (ne = Z == null ? void 0 : Z.charts) != null && ne.length ? Z.charts : (be == null ? void 0 : be.charts) || [],
|
|
1753
|
+
// 结束时收掉「正在…(已用 Ns)」状态,避免 spinner 一直转
|
|
1754
|
+
toolState: be != null && be.toolState ? {
|
|
1755
|
+
...be.toolState,
|
|
1756
|
+
status: be.toolState.status === "running" ? "done" : be.toolState.status,
|
|
1757
|
+
message: (be.toolState.message || "").replace(/(已用 \d+s)$/, "")
|
|
1758
|
+
} : void 0
|
|
1759
|
+
}, t.value = Ne;
|
|
1760
|
+
} catch (P) {
|
|
1761
|
+
if (L !== y) return;
|
|
1762
|
+
p(), W();
|
|
1763
|
+
const se = c();
|
|
1764
|
+
if (se < 0) return;
|
|
1765
|
+
if ((P == null ? void 0 : P.name) === "AbortError" || (P == null ? void 0 : P.code) === "ABORT_ERR") {
|
|
1766
|
+
const Z = [...t.value];
|
|
1767
|
+
Z[se] = { ...Z[se], status: r.STOP }, t.value = Z;
|
|
1722
1768
|
return;
|
|
1723
1769
|
}
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1770
|
+
const ee = [...t.value];
|
|
1771
|
+
ee[se] = {
|
|
1726
1772
|
type: "ai",
|
|
1727
|
-
content: (
|
|
1728
|
-
status:
|
|
1729
|
-
}, t.value =
|
|
1773
|
+
content: (P == null ? void 0 : P.message) || "AI 服务连接失败,请稍后重试",
|
|
1774
|
+
status: r.ERROR
|
|
1775
|
+
}, t.value = ee;
|
|
1730
1776
|
} finally {
|
|
1731
|
-
|
|
1777
|
+
p(), W(), L === y && (e.value = !1, N = null);
|
|
1732
1778
|
}
|
|
1733
1779
|
}
|
|
1734
|
-
async function
|
|
1735
|
-
var
|
|
1736
|
-
if (
|
|
1737
|
-
let
|
|
1738
|
-
if (!
|
|
1780
|
+
async function V(m, O) {
|
|
1781
|
+
var X;
|
|
1782
|
+
if (j() || !M.titleGenerateApp || !E.updateConversationApi || I.value) return;
|
|
1783
|
+
let q = a.value;
|
|
1784
|
+
if (!q)
|
|
1739
1785
|
try {
|
|
1740
|
-
const
|
|
1741
|
-
(
|
|
1742
|
-
} catch (
|
|
1743
|
-
console.error("[ai-assist-sdk] 创建会话失败:",
|
|
1786
|
+
const L = await en(E);
|
|
1787
|
+
(X = L == null ? void 0 : L.conversation) != null && X.appConversationID && (q = L.conversation.appConversationID, a.value = q);
|
|
1788
|
+
} catch (L) {
|
|
1789
|
+
console.error("[ai-assist-sdk] 创建会话失败:", L);
|
|
1744
1790
|
return;
|
|
1745
1791
|
}
|
|
1746
|
-
if (
|
|
1792
|
+
if (q)
|
|
1747
1793
|
try {
|
|
1748
|
-
const
|
|
1749
|
-
if (!
|
|
1750
|
-
const D =
|
|
1751
|
-
AI回答:${D}`,
|
|
1794
|
+
const L = await us(E, M.titleGenerateApp);
|
|
1795
|
+
if (!L) return;
|
|
1796
|
+
const D = O.length > 500 ? O.slice(0, 500) : O, c = `用户提问:${m}
|
|
1797
|
+
AI回答:${D}`, x = await tn().post(E.chatQueryApi, {
|
|
1752
1798
|
app: M.titleGenerateApp,
|
|
1753
|
-
data: { Query:
|
|
1754
|
-
}),
|
|
1755
|
-
|
|
1756
|
-
} catch (
|
|
1757
|
-
console.error("[ai-assist-sdk] 生成对话标题失败:",
|
|
1799
|
+
data: { Query: c, AppConversationID: L }
|
|
1800
|
+
}), H = cs(nn(x.data));
|
|
1801
|
+
H && (await ds(E, q, H), I.value = !0, C == null || C(H));
|
|
1802
|
+
} catch (L) {
|
|
1803
|
+
console.error("[ai-assist-sdk] 生成对话标题失败:", L);
|
|
1758
1804
|
}
|
|
1759
1805
|
}
|
|
1760
|
-
async function
|
|
1806
|
+
async function le() {
|
|
1761
1807
|
var D;
|
|
1762
|
-
const
|
|
1763
|
-
if (!
|
|
1764
|
-
const
|
|
1765
|
-
if (!
|
|
1766
|
-
|
|
1808
|
+
const m = w.value.trim();
|
|
1809
|
+
if (!m || e.value) return;
|
|
1810
|
+
const O = j();
|
|
1811
|
+
if (!O && !a.value && (await de(), !a.value)) {
|
|
1812
|
+
Fe("创建会话失败,请重试");
|
|
1767
1813
|
return;
|
|
1768
1814
|
}
|
|
1769
|
-
const
|
|
1815
|
+
const q = t.value.length === 0;
|
|
1770
1816
|
try {
|
|
1771
|
-
(D = M.onMessageSend) == null || D.call(M, { text:
|
|
1817
|
+
(D = M.onMessageSend) == null || D.call(M, { text: m, isFirstMessage: q, conversationId: a.value });
|
|
1772
1818
|
} catch {
|
|
1773
1819
|
}
|
|
1774
|
-
const
|
|
1820
|
+
const X = [
|
|
1775
1821
|
...t.value,
|
|
1776
|
-
{ type: "user", content:
|
|
1822
|
+
{ type: "user", content: m },
|
|
1777
1823
|
// streamed:标记该条由实时流产生,前端按序逐字揭示(后端批量转发,终态可能早于渲染)
|
|
1778
|
-
{ type: "ai", content: "", status:
|
|
1824
|
+
{ type: "ai", content: "", status: r.THINKING, streamed: !0 }
|
|
1779
1825
|
];
|
|
1780
|
-
t.value =
|
|
1781
|
-
const
|
|
1782
|
-
if (
|
|
1783
|
-
|
|
1826
|
+
t.value = X, w.value = "", l();
|
|
1827
|
+
const L = X.length - 1;
|
|
1828
|
+
if (O) {
|
|
1829
|
+
R.value = m, await A(m, L);
|
|
1784
1830
|
return;
|
|
1785
1831
|
}
|
|
1786
1832
|
if (E.chatQueryStreamApi) {
|
|
1787
|
-
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await
|
|
1788
|
-
Query:
|
|
1833
|
+
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await f(E.chatQueryStreamApi, {
|
|
1834
|
+
Query: m,
|
|
1789
1835
|
AppConversationID: a.value,
|
|
1790
1836
|
ResponseMode: "streaming"
|
|
1791
|
-
},
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1837
|
+
}, L, T.first.signal), q && !I.value) {
|
|
1838
|
+
const c = t.value[L];
|
|
1839
|
+
c && c.status !== r.ERROR && V(m, c.content);
|
|
1794
1840
|
}
|
|
1795
1841
|
return;
|
|
1796
1842
|
}
|
|
1797
1843
|
console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
|
|
1798
1844
|
try {
|
|
1799
|
-
const b = await
|
|
1845
|
+
const b = await tn().post(E.chatQueryApi, {
|
|
1800
1846
|
app: M.app ?? 1,
|
|
1801
|
-
data: { Query:
|
|
1802
|
-
}),
|
|
1847
|
+
data: { Query: m, AppConversationID: a.value }
|
|
1848
|
+
}), x = nn(b.data);
|
|
1803
1849
|
t.value = [
|
|
1804
1850
|
...t.value.slice(0, -1),
|
|
1805
|
-
{ type: "ai", content:
|
|
1806
|
-
],
|
|
1807
|
-
} catch (
|
|
1808
|
-
t.value = [...t.value.slice(0, -1), { type: "ai", content: (
|
|
1851
|
+
{ type: "ai", content: x || "未获取到回答内容,请稍后重试", status: r.COMPLETED }
|
|
1852
|
+
], q && !I.value && x && V(m, x);
|
|
1853
|
+
} catch (c) {
|
|
1854
|
+
t.value = [...t.value.slice(0, -1), { type: "ai", content: (c == null ? void 0 : c.message) || "服务连接失败,请稍后重试", status: r.ERROR }];
|
|
1809
1855
|
}
|
|
1810
1856
|
}
|
|
1811
1857
|
async function s() {
|
|
1812
|
-
if (
|
|
1813
|
-
if (!
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1858
|
+
if (j()) {
|
|
1859
|
+
if (!R.value || e.value) return;
|
|
1860
|
+
const X = [...t.value];
|
|
1861
|
+
X.length > 0 && X[X.length - 1].type === "ai" && X.pop(), X.push({ type: "ai", content: "", status: r.RETHINKING, streamed: !0 }), t.value = X, l(), await A(R.value, t.value.length - 1);
|
|
1816
1862
|
return;
|
|
1817
1863
|
}
|
|
1818
|
-
if (!
|
|
1819
|
-
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
const
|
|
1823
|
-
await
|
|
1824
|
-
MessageID:
|
|
1864
|
+
if (!v.value || e.value) return;
|
|
1865
|
+
T.again.abort(), T.again = new AbortController();
|
|
1866
|
+
const m = [...t.value];
|
|
1867
|
+
m.length > 0 && m[m.length - 1].type === "ai" && m.pop(), m.push({ type: "ai", content: "", status: r.RETHINKING, streamed: !0 }), t.value = m, l();
|
|
1868
|
+
const O = t.value.length - 1, q = $o(E);
|
|
1869
|
+
await f(q, {
|
|
1870
|
+
MessageID: v.value,
|
|
1825
1871
|
AppConversationID: a.value,
|
|
1826
1872
|
ResponseMode: "streaming"
|
|
1827
|
-
},
|
|
1873
|
+
}, O, T.again.signal, !0);
|
|
1828
1874
|
}
|
|
1829
|
-
async function
|
|
1830
|
-
var
|
|
1875
|
+
async function ae() {
|
|
1876
|
+
var q;
|
|
1831
1877
|
if (!e.value) return;
|
|
1832
|
-
const
|
|
1833
|
-
if (
|
|
1834
|
-
y++,
|
|
1835
|
-
const
|
|
1836
|
-
if (
|
|
1878
|
+
const m = t.value.length - 1;
|
|
1879
|
+
if (j()) {
|
|
1880
|
+
y++, N == null || N.abort(), N = null;
|
|
1881
|
+
const X = (q = Ve()) == null ? void 0 : q.api, L = We(), D = Rt(L);
|
|
1882
|
+
if (X != null && X.stop && D)
|
|
1837
1883
|
try {
|
|
1838
|
-
await
|
|
1884
|
+
await X.stop({ module: L, threadId: D });
|
|
1839
1885
|
} catch (b) {
|
|
1840
1886
|
console.error("[ai-assist-sdk] page stop failed:", b);
|
|
1841
1887
|
}
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
-
...
|
|
1845
|
-
content:
|
|
1846
|
-
status:
|
|
1847
|
-
}), t.value =
|
|
1888
|
+
const c = [...t.value];
|
|
1889
|
+
c[m] && (c[m] = {
|
|
1890
|
+
...c[m],
|
|
1891
|
+
content: c[m].content || "已停止回答",
|
|
1892
|
+
status: r.STOP
|
|
1893
|
+
}), t.value = c, e.value = !1, g.value = !0;
|
|
1848
1894
|
return;
|
|
1849
1895
|
}
|
|
1850
|
-
if (
|
|
1896
|
+
if (v.value && E.stopMessageApi)
|
|
1851
1897
|
try {
|
|
1852
|
-
await
|
|
1853
|
-
} catch (
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1898
|
+
await rs(E, v.value);
|
|
1899
|
+
} catch (X) {
|
|
1900
|
+
const L = [...t.value];
|
|
1901
|
+
L[m] && (L[m] = { ...L[m], content: (X == null ? void 0 : X.message) || "系统繁忙,请稍后再试", status: r.ERROR }), t.value = L;
|
|
1856
1902
|
return;
|
|
1857
1903
|
}
|
|
1858
|
-
const
|
|
1859
|
-
|
|
1904
|
+
const O = [...t.value];
|
|
1905
|
+
O[m] && (O[m] = { ...O[m], content: O[m].content || "已停止回答", status: r.STOP }), t.value = O, e.value = !1, T.first.abort(), T.first = new AbortController(), T.again.abort(), T.again = new AbortController(), g.value = !0;
|
|
1860
1906
|
}
|
|
1861
|
-
async function
|
|
1862
|
-
var
|
|
1863
|
-
a.value =
|
|
1907
|
+
async function re(m) {
|
|
1908
|
+
var O;
|
|
1909
|
+
a.value = m, I.value = !0;
|
|
1864
1910
|
try {
|
|
1865
|
-
const
|
|
1866
|
-
for (const D of
|
|
1867
|
-
D.query &&
|
|
1868
|
-
t.value =
|
|
1869
|
-
} catch (
|
|
1870
|
-
|
|
1911
|
+
const q = await is(E, m), X = [], L = ls(q == null ? void 0 : q.messages);
|
|
1912
|
+
for (const D of L)
|
|
1913
|
+
D.query && X.push({ type: "user", content: D.query }), (O = D.answerInfo) != null && O.answer && X.push({ type: "ai", content: D.answerInfo.answer, status: r.COMPLETED });
|
|
1914
|
+
t.value = X, l();
|
|
1915
|
+
} catch (q) {
|
|
1916
|
+
Fe((q == null ? void 0 : q.message) || "加载历史会话失败");
|
|
1871
1917
|
}
|
|
1872
1918
|
}
|
|
1873
|
-
async function
|
|
1874
|
-
var
|
|
1919
|
+
async function de() {
|
|
1920
|
+
var m;
|
|
1875
1921
|
I.value = !1;
|
|
1876
1922
|
try {
|
|
1877
|
-
const
|
|
1878
|
-
(
|
|
1879
|
-
} catch (
|
|
1880
|
-
|
|
1923
|
+
const O = await en(E);
|
|
1924
|
+
(m = O == null ? void 0 : O.conversation) != null && m.appConversationID && (a.value = O.conversation.appConversationID);
|
|
1925
|
+
} catch (O) {
|
|
1926
|
+
Fe((O == null ? void 0 : O.message) || "创建会话失败");
|
|
1881
1927
|
}
|
|
1882
1928
|
}
|
|
1883
1929
|
function k() {
|
|
1884
|
-
a.value = "", I.value = !1,
|
|
1930
|
+
a.value = "", I.value = !1, R.value = "", y++, N == null || N.abort(), N = null, os();
|
|
1885
1931
|
}
|
|
1886
|
-
function
|
|
1887
|
-
y++,
|
|
1932
|
+
function U() {
|
|
1933
|
+
y++, N == null || N.abort(), N = null, e.value = !1, R.value = "", t.value = [], w.value = "", g.value = !0;
|
|
1888
1934
|
}
|
|
1889
1935
|
return {
|
|
1890
|
-
sendMessage:
|
|
1936
|
+
sendMessage: le,
|
|
1891
1937
|
regenerateResponse: s,
|
|
1892
|
-
toggleStop:
|
|
1893
|
-
goHistoryMessage:
|
|
1894
|
-
initConversation:
|
|
1938
|
+
toggleStop: ae,
|
|
1939
|
+
goHistoryMessage: re,
|
|
1940
|
+
initConversation: de,
|
|
1895
1941
|
resetConversation: k,
|
|
1896
|
-
clearMessagesKeepingThread:
|
|
1897
|
-
controllers:
|
|
1942
|
+
clearMessagesKeepingThread: U,
|
|
1943
|
+
controllers: T
|
|
1898
1944
|
};
|
|
1899
1945
|
}
|
|
1900
|
-
function
|
|
1946
|
+
function To({
|
|
1901
1947
|
cfg: t,
|
|
1902
1948
|
STATUS: w,
|
|
1903
1949
|
userInput: e,
|
|
1904
|
-
isActive:
|
|
1950
|
+
isActive: v,
|
|
1905
1951
|
scrollToBottom: a,
|
|
1906
|
-
onSessionTitle:
|
|
1952
|
+
onSessionTitle: f
|
|
1907
1953
|
}) {
|
|
1908
|
-
const
|
|
1909
|
-
let
|
|
1954
|
+
const g = ns([]), l = _("");
|
|
1955
|
+
let r = 0;
|
|
1910
1956
|
const M = S(
|
|
1911
|
-
() =>
|
|
1957
|
+
() => g.value.find((k) => k.uid === l.value) ?? null
|
|
1912
1958
|
), C = S(() => {
|
|
1913
1959
|
var k;
|
|
1914
1960
|
return ((k = M.value) == null ? void 0 : k.messages.value) ?? [];
|
|
1915
1961
|
}), E = S(() => {
|
|
1916
1962
|
var k;
|
|
1917
1963
|
return ((k = M.value) == null ? void 0 : k.isGenerating.value) ?? !1;
|
|
1918
|
-
}),
|
|
1964
|
+
}), T = S(
|
|
1919
1965
|
() => {
|
|
1920
1966
|
var k;
|
|
1921
1967
|
return (((k = M.value) == null ? void 0 : k.messages.value.length) ?? 0) === 0;
|
|
1922
1968
|
}
|
|
1923
1969
|
), I = S(
|
|
1924
|
-
() =>
|
|
1970
|
+
() => g.value.filter((k) => !!k.conversationId.value).map((k) => ({
|
|
1925
1971
|
conversationId: k.conversationId.value,
|
|
1926
1972
|
title: k.title.value,
|
|
1927
1973
|
generating: k.isGenerating.value,
|
|
1928
1974
|
updatedAt: k.updatedAt.value
|
|
1929
1975
|
}))
|
|
1930
1976
|
);
|
|
1931
|
-
function
|
|
1932
|
-
const
|
|
1933
|
-
messages:
|
|
1934
|
-
isGenerating:
|
|
1935
|
-
lastUserMessage:
|
|
1977
|
+
function R(k = "") {
|
|
1978
|
+
const U = k || `draft-${++r}`, m = _([]), O = _(!1), q = _(""), X = _(k), L = _(""), D = _(Date.now()), c = /* @__PURE__ */ new Map(), { batchMessagesUpdate: b, flushMessagesBatch: x } = bo(m), { doStreamRequest: H, issTop: F } = Mo({
|
|
1979
|
+
messages: m,
|
|
1980
|
+
isGenerating: O,
|
|
1981
|
+
lastUserMessage: q,
|
|
1936
1982
|
batchMessagesUpdate: b,
|
|
1937
|
-
flushMessagesBatch:
|
|
1983
|
+
flushMessagesBatch: x,
|
|
1938
1984
|
STATUS: w,
|
|
1939
1985
|
cfg: t
|
|
1940
|
-
}),
|
|
1941
|
-
messages:
|
|
1986
|
+
}), Y = So({
|
|
1987
|
+
messages: m,
|
|
1942
1988
|
userInput: e,
|
|
1943
|
-
isGenerating:
|
|
1944
|
-
lastUserMessage:
|
|
1945
|
-
conversationId:
|
|
1946
|
-
doStreamRequest: async (
|
|
1989
|
+
isGenerating: O,
|
|
1990
|
+
lastUserMessage: q,
|
|
1991
|
+
conversationId: X,
|
|
1992
|
+
doStreamRequest: async (oe, J, B, W, ue) => {
|
|
1947
1993
|
D.value = Date.now();
|
|
1948
1994
|
try {
|
|
1949
|
-
return await
|
|
1995
|
+
return await H(oe, J, B, W, ue);
|
|
1950
1996
|
} finally {
|
|
1951
1997
|
D.value = Date.now();
|
|
1952
1998
|
}
|
|
1953
1999
|
},
|
|
1954
|
-
issTop:
|
|
2000
|
+
issTop: F,
|
|
1955
2001
|
scrollToBottom: () => {
|
|
1956
|
-
|
|
2002
|
+
v(U) && a();
|
|
1957
2003
|
},
|
|
1958
2004
|
STATUS: w,
|
|
1959
2005
|
cfg: t,
|
|
1960
|
-
onTitleGenerated: (
|
|
1961
|
-
|
|
2006
|
+
onTitleGenerated: (oe) => {
|
|
2007
|
+
L.value = oe, D.value = Date.now(), f == null || f(U, oe);
|
|
1962
2008
|
}
|
|
1963
2009
|
});
|
|
1964
2010
|
return {
|
|
1965
|
-
uid:
|
|
1966
|
-
conversationId:
|
|
1967
|
-
messages:
|
|
1968
|
-
isGenerating:
|
|
1969
|
-
lastUserMessage:
|
|
1970
|
-
title:
|
|
2011
|
+
uid: U,
|
|
2012
|
+
conversationId: X,
|
|
2013
|
+
messages: m,
|
|
2014
|
+
isGenerating: O,
|
|
2015
|
+
lastUserMessage: q,
|
|
2016
|
+
title: L,
|
|
1971
2017
|
updatedAt: D,
|
|
1972
|
-
reveal:
|
|
1973
|
-
sendMessage:
|
|
1974
|
-
regenerateResponse:
|
|
1975
|
-
toggleStop:
|
|
1976
|
-
loadHistory:
|
|
1977
|
-
resetConversation:
|
|
1978
|
-
clearMessages:
|
|
2018
|
+
reveal: c,
|
|
2019
|
+
sendMessage: Y.sendMessage,
|
|
2020
|
+
regenerateResponse: Y.regenerateResponse,
|
|
2021
|
+
toggleStop: Y.toggleStop,
|
|
2022
|
+
loadHistory: Y.goHistoryMessage,
|
|
2023
|
+
resetConversation: Y.resetConversation,
|
|
2024
|
+
clearMessages: Y.clearMessagesKeepingThread
|
|
1979
2025
|
};
|
|
1980
2026
|
}
|
|
1981
2027
|
function y(k) {
|
|
1982
|
-
|
|
2028
|
+
l.value = k, a();
|
|
1983
2029
|
}
|
|
1984
|
-
function
|
|
1985
|
-
let k =
|
|
1986
|
-
(
|
|
2030
|
+
function N() {
|
|
2031
|
+
let k = g.value.find(
|
|
2032
|
+
(U) => !U.conversationId.value && !U.isGenerating.value && U.messages.value.length === 0
|
|
1987
2033
|
);
|
|
1988
|
-
k || (k =
|
|
2034
|
+
k || (k = R(""), g.value = [...g.value, k]), k.resetConversation(), y(k.uid);
|
|
1989
2035
|
}
|
|
1990
|
-
function
|
|
1991
|
-
const
|
|
1992
|
-
if (
|
|
1993
|
-
y(
|
|
2036
|
+
function j(k) {
|
|
2037
|
+
const U = g.value.find((O) => O.conversationId.value === k);
|
|
2038
|
+
if (U) {
|
|
2039
|
+
y(U.uid);
|
|
1994
2040
|
return;
|
|
1995
2041
|
}
|
|
1996
|
-
const
|
|
1997
|
-
|
|
2042
|
+
const m = R(k);
|
|
2043
|
+
g.value = [...g.value, m], y(m.uid), m.loadHistory(k);
|
|
1998
2044
|
}
|
|
1999
|
-
function
|
|
2045
|
+
function A() {
|
|
2000
2046
|
return M.value;
|
|
2001
2047
|
}
|
|
2002
|
-
async function
|
|
2048
|
+
async function V() {
|
|
2003
2049
|
var k;
|
|
2004
|
-
await ((k =
|
|
2050
|
+
await ((k = A()) == null ? void 0 : k.sendMessage());
|
|
2005
2051
|
}
|
|
2006
|
-
async function
|
|
2052
|
+
async function le() {
|
|
2007
2053
|
var k;
|
|
2008
|
-
await ((k =
|
|
2054
|
+
await ((k = A()) == null ? void 0 : k.toggleStop());
|
|
2009
2055
|
}
|
|
2010
2056
|
async function s() {
|
|
2011
2057
|
var k;
|
|
2012
|
-
await ((k =
|
|
2058
|
+
await ((k = A()) == null ? void 0 : k.regenerateResponse());
|
|
2013
2059
|
}
|
|
2014
|
-
function
|
|
2060
|
+
function ae() {
|
|
2015
2061
|
var k;
|
|
2016
|
-
(k =
|
|
2062
|
+
(k = A()) == null || k.clearMessages();
|
|
2017
2063
|
}
|
|
2018
|
-
async function
|
|
2019
|
-
var
|
|
2020
|
-
if (
|
|
2021
|
-
const
|
|
2022
|
-
if (!
|
|
2023
|
-
const
|
|
2024
|
-
if (!(
|
|
2025
|
-
const
|
|
2026
|
-
if (
|
|
2064
|
+
async function re(k) {
|
|
2065
|
+
var X;
|
|
2066
|
+
if (Ct() !== "page") return;
|
|
2067
|
+
const U = k ?? M.value;
|
|
2068
|
+
if (!U || U.messages.value.length) return;
|
|
2069
|
+
const m = (X = Ve()) == null ? void 0 : X.api;
|
|
2070
|
+
if (!(m != null && m.state)) return;
|
|
2071
|
+
const O = We(), q = Rt(O);
|
|
2072
|
+
if (q)
|
|
2027
2073
|
try {
|
|
2028
|
-
const
|
|
2074
|
+
const L = await m.state({ module: O, threadId: q }), D = ((L == null ? void 0 : L.messages) || []).filter((c) => {
|
|
2029
2075
|
var b;
|
|
2030
|
-
return !(
|
|
2031
|
-
}).map((
|
|
2032
|
-
type:
|
|
2033
|
-
content:
|
|
2034
|
-
status:
|
|
2035
|
-
files:
|
|
2036
|
-
charts:
|
|
2076
|
+
return !(c.role === "assistant" && !c.content && !((b = c.charts) != null && b.length));
|
|
2077
|
+
}).map((c) => ({
|
|
2078
|
+
type: c.role === "user" ? "user" : "ai",
|
|
2079
|
+
content: c.content,
|
|
2080
|
+
status: c.role === "assistant" ? w.COMPLETED : void 0,
|
|
2081
|
+
files: c.role === "assistant" ? c.files ?? [] : void 0,
|
|
2082
|
+
charts: c.role === "assistant" ? c.charts ?? [] : void 0
|
|
2037
2083
|
}));
|
|
2038
2084
|
if (!D.length) return;
|
|
2039
|
-
|
|
2040
|
-
} catch (
|
|
2041
|
-
console.warn("[ai-assist-sdk] 恢复页面会话失败:",
|
|
2085
|
+
U.conversationId.value = L.threadId || q, U.messages.value = D, v(U.uid) && a();
|
|
2086
|
+
} catch (L) {
|
|
2087
|
+
console.warn("[ai-assist-sdk] 恢复页面会话失败:", L);
|
|
2042
2088
|
}
|
|
2043
2089
|
}
|
|
2044
|
-
const
|
|
2045
|
-
return
|
|
2046
|
-
sessions:
|
|
2047
|
-
activeUid:
|
|
2090
|
+
const de = R("");
|
|
2091
|
+
return g.value = [de], l.value = de.uid, re(de), {
|
|
2092
|
+
sessions: g,
|
|
2093
|
+
activeUid: l,
|
|
2048
2094
|
activeSession: M,
|
|
2049
2095
|
messages: C,
|
|
2050
2096
|
isGenerating: E,
|
|
2051
|
-
isEmptyConversation:
|
|
2097
|
+
isEmptyConversation: T,
|
|
2052
2098
|
sessionMetas: I,
|
|
2053
|
-
sendMessage:
|
|
2054
|
-
toggleStop:
|
|
2099
|
+
sendMessage: V,
|
|
2100
|
+
toggleStop: le,
|
|
2055
2101
|
regenerateResponse: s,
|
|
2056
|
-
goHistoryMessage:
|
|
2057
|
-
createNewConversation:
|
|
2058
|
-
clearActiveMessages:
|
|
2102
|
+
goHistoryMessage: j,
|
|
2103
|
+
createNewConversation: N,
|
|
2104
|
+
clearActiveMessages: ae,
|
|
2059
2105
|
/** page 模式:打开侧栏时按 threadId 恢复历史(幂等,已有消息直接返回) */
|
|
2060
|
-
restorePageHistory:
|
|
2106
|
+
restorePageHistory: re
|
|
2061
2107
|
};
|
|
2062
2108
|
}
|
|
2063
|
-
const
|
|
2109
|
+
const xo = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "message ai-message greet-message" }, Ao = { class: "ai-greet" }, Ro = ["src"], Po = {
|
|
2064
2110
|
key: 0,
|
|
2065
2111
|
class: "message ai-message recommend-message"
|
|
2066
|
-
}, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */
|
|
2112
|
+
}, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */ $e({
|
|
2067
2113
|
__name: "Answer",
|
|
2068
2114
|
props: {
|
|
2069
2115
|
defaultSayhello: {},
|
|
@@ -2071,7 +2117,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2071
2117
|
},
|
|
2072
2118
|
emits: ["title-generated", "sessions-change"],
|
|
2073
2119
|
setup(t, { expose: w, emit: e }) {
|
|
2074
|
-
const
|
|
2120
|
+
const v = {
|
|
2075
2121
|
THINKING: "thinking",
|
|
2076
2122
|
RETHINKING: "rethinking",
|
|
2077
2123
|
ANSWERING: "answering",
|
|
@@ -2079,313 +2125,313 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2079
2125
|
COMPLETED: "completed",
|
|
2080
2126
|
STOP: "stop",
|
|
2081
2127
|
ERROR: "error"
|
|
2082
|
-
}, a = t,
|
|
2128
|
+
}, a = t, f = e, g = lt(), l = _(""), r = _(null), M = He({ text1: "", text2: "" }), C = _([]), E = _(0), T = S(
|
|
2083
2129
|
() => C.value[E.value % (C.value.length || 1)]
|
|
2084
2130
|
);
|
|
2085
2131
|
function I() {
|
|
2086
2132
|
E.value++;
|
|
2087
2133
|
}
|
|
2088
|
-
const
|
|
2089
|
-
|
|
2134
|
+
const R = S(() => yn());
|
|
2135
|
+
ge(
|
|
2090
2136
|
() => a.defaultRecommend,
|
|
2091
|
-
(
|
|
2092
|
-
C.value =
|
|
2137
|
+
(G) => {
|
|
2138
|
+
C.value = sn(G || []), E.value = 0;
|
|
2093
2139
|
},
|
|
2094
2140
|
{ deep: !0 }
|
|
2095
2141
|
);
|
|
2096
|
-
function y(
|
|
2097
|
-
|
|
2142
|
+
function y(G) {
|
|
2143
|
+
l.value = G;
|
|
2098
2144
|
}
|
|
2099
|
-
function
|
|
2100
|
-
|
|
2145
|
+
function N(G) {
|
|
2146
|
+
G && (l.value = G, O());
|
|
2101
2147
|
}
|
|
2102
|
-
const { isAtBottom:
|
|
2103
|
-
let
|
|
2148
|
+
const { isAtBottom: j, hasScroll: A, scrollToBottom: V, checkScrollStatus: le } = _o(r), { enhanceCodeBlocks: s } = Co();
|
|
2149
|
+
let ae = (G) => !1;
|
|
2104
2150
|
const {
|
|
2105
|
-
activeSession:
|
|
2106
|
-
messages:
|
|
2151
|
+
activeSession: re,
|
|
2152
|
+
messages: de,
|
|
2107
2153
|
isGenerating: k,
|
|
2108
|
-
isEmptyConversation:
|
|
2109
|
-
sessionMetas:
|
|
2110
|
-
sendMessage:
|
|
2111
|
-
regenerateResponse:
|
|
2112
|
-
toggleStop:
|
|
2113
|
-
goHistoryMessage:
|
|
2154
|
+
isEmptyConversation: U,
|
|
2155
|
+
sessionMetas: m,
|
|
2156
|
+
sendMessage: O,
|
|
2157
|
+
regenerateResponse: q,
|
|
2158
|
+
toggleStop: X,
|
|
2159
|
+
goHistoryMessage: L,
|
|
2114
2160
|
createNewConversation: D,
|
|
2115
|
-
clearActiveMessages:
|
|
2161
|
+
clearActiveMessages: c,
|
|
2116
2162
|
restorePageHistory: b
|
|
2117
|
-
} =
|
|
2118
|
-
cfg:
|
|
2119
|
-
STATUS:
|
|
2120
|
-
userInput:
|
|
2121
|
-
isActive: (
|
|
2122
|
-
scrollToBottom:
|
|
2123
|
-
onSessionTitle: (
|
|
2124
|
-
|
|
2163
|
+
} = To({
|
|
2164
|
+
cfg: g,
|
|
2165
|
+
STATUS: v,
|
|
2166
|
+
userInput: l,
|
|
2167
|
+
isActive: (G) => ae(G),
|
|
2168
|
+
scrollToBottom: V,
|
|
2169
|
+
onSessionTitle: (G, ne) => {
|
|
2170
|
+
ae(G) && f("title-generated", ne);
|
|
2125
2171
|
}
|
|
2126
2172
|
});
|
|
2127
|
-
|
|
2128
|
-
var
|
|
2129
|
-
return ((
|
|
2130
|
-
},
|
|
2131
|
-
|
|
2132
|
-
}),
|
|
2133
|
-
function
|
|
2134
|
-
var
|
|
2135
|
-
(
|
|
2173
|
+
ae = (G) => {
|
|
2174
|
+
var ne;
|
|
2175
|
+
return ((ne = re.value) == null ? void 0 : ne.uid) === G;
|
|
2176
|
+
}, ge(re, (G) => {
|
|
2177
|
+
f("title-generated", (G == null ? void 0 : G.title.value) ?? "");
|
|
2178
|
+
}), ge(m, (G) => f("sessions-change", G), { immediate: !0 });
|
|
2179
|
+
function x(G, ne) {
|
|
2180
|
+
var P;
|
|
2181
|
+
(P = re.value) == null || P.reveal.set(G, ne);
|
|
2136
2182
|
}
|
|
2137
2183
|
w({
|
|
2138
|
-
goHistoryMessage:
|
|
2184
|
+
goHistoryMessage: L,
|
|
2139
2185
|
createNewConversation: D,
|
|
2140
|
-
clearActiveMessages:
|
|
2141
|
-
isEmptyConversation:
|
|
2186
|
+
clearActiveMessages: c,
|
|
2187
|
+
isEmptyConversation: U,
|
|
2142
2188
|
restorePageHistory: b
|
|
2143
2189
|
});
|
|
2144
|
-
const
|
|
2145
|
-
function
|
|
2146
|
-
|
|
2147
|
-
}
|
|
2148
|
-
de
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
s(
|
|
2152
|
-
}),
|
|
2190
|
+
const H = _(/* @__PURE__ */ new Map());
|
|
2191
|
+
function F(G, ne) {
|
|
2192
|
+
G ? H.value.set(ne, G) : H.value.delete(ne);
|
|
2193
|
+
}
|
|
2194
|
+
ge(de, () => {
|
|
2195
|
+
Se(() => {
|
|
2196
|
+
H.value.forEach((G) => {
|
|
2197
|
+
s(G);
|
|
2198
|
+
}), le();
|
|
2153
2199
|
});
|
|
2154
2200
|
}, { deep: !0 });
|
|
2155
|
-
let
|
|
2156
|
-
|
|
2157
|
-
a.defaultSayhello && (M.text1 = a.defaultSayhello.text1, M.text2 = a.defaultSayhello.text2), a.defaultRecommend && (C.value =
|
|
2158
|
-
}),
|
|
2159
|
-
|
|
2201
|
+
let u = null;
|
|
2202
|
+
Pe(() => {
|
|
2203
|
+
a.defaultSayhello && (M.text1 = a.defaultSayhello.text1, M.text2 = a.defaultSayhello.text2), a.defaultRecommend && (C.value = sn(a.defaultRecommend));
|
|
2204
|
+
}), Pe(() => {
|
|
2205
|
+
r.value && (u = () => le(), r.value.addEventListener("scroll", u), le());
|
|
2160
2206
|
});
|
|
2161
|
-
const
|
|
2162
|
-
let
|
|
2163
|
-
function
|
|
2164
|
-
var
|
|
2165
|
-
const
|
|
2166
|
-
return parseFloat((
|
|
2167
|
-
}
|
|
2168
|
-
function W(
|
|
2169
|
-
return "touches" in
|
|
2170
|
-
}
|
|
2171
|
-
function
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
}
|
|
2175
|
-
function
|
|
2176
|
-
const
|
|
2177
|
-
if (!
|
|
2178
|
-
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2181
|
-
}
|
|
2182
|
-
function
|
|
2183
|
-
|
|
2184
|
-
}
|
|
2185
|
-
function
|
|
2186
|
-
const
|
|
2187
|
-
if (!
|
|
2188
|
-
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
}
|
|
2192
|
-
return
|
|
2193
|
-
|
|
2194
|
-
}), (
|
|
2195
|
-
var
|
|
2196
|
-
return i(),
|
|
2207
|
+
const p = _(null);
|
|
2208
|
+
let Y = !1, oe = 0, J = 0;
|
|
2209
|
+
function B(G) {
|
|
2210
|
+
var P;
|
|
2211
|
+
const ne = (P = r.value) == null ? void 0 : P.closest(".chat-wrap");
|
|
2212
|
+
return parseFloat((ne == null ? void 0 : ne.style.getPropertyValue(G)) ?? "") || 0;
|
|
2213
|
+
}
|
|
2214
|
+
function W(G) {
|
|
2215
|
+
return "touches" in G ? G.touches[0].clientY : G.clientY;
|
|
2216
|
+
}
|
|
2217
|
+
function ue(G) {
|
|
2218
|
+
const ne = r.value;
|
|
2219
|
+
ne && (G.preventDefault(), Y = !0, oe = W(G), ne.scrollTop, J = B("--ai-thumb-top"), window.addEventListener("mousemove", Q), window.addEventListener("mouseup", ve), window.addEventListener("touchmove", Q, { passive: !1 }), window.addEventListener("touchend", ve));
|
|
2220
|
+
}
|
|
2221
|
+
function Q(G) {
|
|
2222
|
+
const ne = r.value;
|
|
2223
|
+
if (!Y || !ne) return;
|
|
2224
|
+
G.preventDefault();
|
|
2225
|
+
const P = W(G) - oe, se = ne.clientHeight, ee = ne.scrollHeight, Z = B("--ai-thumb-height"), _e = se - Z, Re = Math.min(Math.max(J + P, 0), _e);
|
|
2226
|
+
ne.scrollTop = Re / _e * (ee - se);
|
|
2227
|
+
}
|
|
2228
|
+
function ve() {
|
|
2229
|
+
Y = !1, window.removeEventListener("mousemove", Q), window.removeEventListener("mouseup", ve), window.removeEventListener("touchmove", Q), window.removeEventListener("touchend", ve);
|
|
2230
|
+
}
|
|
2231
|
+
function fe(G) {
|
|
2232
|
+
const ne = r.value, P = p.value;
|
|
2233
|
+
if (!ne || !P) return;
|
|
2234
|
+
G.preventDefault();
|
|
2235
|
+
const se = P.getBoundingClientRect(), Z = (W(G) - se.top) / se.height;
|
|
2236
|
+
ne.scrollTop = Z * (ne.scrollHeight - ne.clientHeight);
|
|
2237
|
+
}
|
|
2238
|
+
return Be(() => {
|
|
2239
|
+
r.value && u && r.value.removeEventListener("scroll", u), ve();
|
|
2240
|
+
}), (G, ne) => {
|
|
2241
|
+
var P;
|
|
2242
|
+
return i(), h("div", xo, [
|
|
2197
2243
|
o("div", Do, [
|
|
2198
2244
|
o("div", {
|
|
2199
2245
|
class: "chat-box scrollWrap",
|
|
2200
2246
|
ref_key: "chatBoxRef",
|
|
2201
|
-
ref:
|
|
2247
|
+
ref: r
|
|
2202
2248
|
}, [
|
|
2203
2249
|
o("div", Eo, [
|
|
2204
2250
|
o("div", Ao, [
|
|
2205
|
-
o("img", { src:
|
|
2206
|
-
o("h1", null,
|
|
2207
|
-
o("p", null,
|
|
2251
|
+
o("img", { src: ie(_n) }, null, 8, Ro),
|
|
2252
|
+
o("h1", null, te(M.text1), 1),
|
|
2253
|
+
o("p", null, te(M.text2), 1)
|
|
2208
2254
|
])
|
|
2209
2255
|
]),
|
|
2210
|
-
(
|
|
2256
|
+
(P = T.value) != null && P.length && (!R.value || ie(de).length === 0) ? (i(), h("div", Po, [
|
|
2211
2257
|
o("div", Lo, [
|
|
2212
2258
|
o("div", Ho, [
|
|
2213
|
-
|
|
2259
|
+
ne[2] || (ne[2] = o("span", null, "你可以尝试这样问我:", -1)),
|
|
2214
2260
|
o("p", {
|
|
2215
2261
|
class: "refresh-btn",
|
|
2216
2262
|
onClick: I
|
|
2217
2263
|
}, [
|
|
2218
|
-
|
|
2264
|
+
ke(Te, {
|
|
2219
2265
|
name: "refresh",
|
|
2220
2266
|
class: "refresh-icon"
|
|
2221
2267
|
}),
|
|
2222
|
-
|
|
2268
|
+
ne[1] || (ne[1] = o("span", null, "换一换", -1))
|
|
2223
2269
|
])
|
|
2224
2270
|
]),
|
|
2225
2271
|
o("ul", null, [
|
|
2226
|
-
(i(!0),
|
|
2227
|
-
key:
|
|
2228
|
-
onClick: (
|
|
2229
|
-
},
|
|
2272
|
+
(i(!0), h(Ce, null, Ae(T.value, (se, ee) => (i(), h("li", {
|
|
2273
|
+
key: ee,
|
|
2274
|
+
onClick: (Z) => y(se)
|
|
2275
|
+
}, te(se), 9, No))), 128))
|
|
2230
2276
|
])
|
|
2231
2277
|
])
|
|
2232
|
-
])) :
|
|
2233
|
-
(i(!0),
|
|
2234
|
-
var
|
|
2235
|
-
return i(),
|
|
2236
|
-
key: `${((
|
|
2237
|
-
msg:
|
|
2238
|
-
index:
|
|
2239
|
-
STATUS:
|
|
2240
|
-
setMessageRef:
|
|
2241
|
-
scrollToBottom:
|
|
2242
|
-
initialReveal: (
|
|
2243
|
-
onRegenerate:
|
|
2244
|
-
onAsk:
|
|
2245
|
-
onRevealProgress: (
|
|
2278
|
+
])) : z("", !0),
|
|
2279
|
+
(i(!0), h(Ce, null, Ae(ie(de), (se, ee) => {
|
|
2280
|
+
var Z, _e;
|
|
2281
|
+
return i(), we(ao, {
|
|
2282
|
+
key: `${((Z = ie(re)) == null ? void 0 : Z.uid) ?? ""}-${ee}`,
|
|
2283
|
+
msg: se,
|
|
2284
|
+
index: ee,
|
|
2285
|
+
STATUS: v,
|
|
2286
|
+
setMessageRef: F,
|
|
2287
|
+
scrollToBottom: ie(V),
|
|
2288
|
+
initialReveal: (_e = ie(re)) == null ? void 0 : _e.reveal.get(ee),
|
|
2289
|
+
onRegenerate: ie(q),
|
|
2290
|
+
onAsk: N,
|
|
2291
|
+
onRevealProgress: (Re) => x(ee, Re)
|
|
2246
2292
|
}, null, 8, ["msg", "index", "scrollToBottom", "initialReveal", "onRegenerate", "onRevealProgress"]);
|
|
2247
2293
|
}), 128))
|
|
2248
2294
|
], 512),
|
|
2249
2295
|
o("div", {
|
|
2250
2296
|
ref_key: "scrollbarRef",
|
|
2251
|
-
ref:
|
|
2297
|
+
ref: p,
|
|
2252
2298
|
class: "chat-box__scrollbar",
|
|
2253
|
-
onMousedown:
|
|
2254
|
-
onTouchstart:
|
|
2299
|
+
onMousedown: Le(fe, ["prevent"]),
|
|
2300
|
+
onTouchstart: Le(fe, ["prevent"])
|
|
2255
2301
|
}, [
|
|
2256
2302
|
o("div", {
|
|
2257
2303
|
class: "chat-box__scrollbar-thumb",
|
|
2258
|
-
onMousedown:
|
|
2259
|
-
onTouchstart:
|
|
2304
|
+
onMousedown: Le(ue, ["stop", "prevent"]),
|
|
2305
|
+
onTouchstart: Le(ue, ["stop", "prevent"])
|
|
2260
2306
|
}, null, 32)
|
|
2261
2307
|
], 544)
|
|
2262
2308
|
]),
|
|
2263
|
-
|
|
2264
|
-
modelValue:
|
|
2265
|
-
"onUpdate:modelValue":
|
|
2266
|
-
isGenerating:
|
|
2267
|
-
hasScroll:
|
|
2268
|
-
isAtBottom:
|
|
2269
|
-
onSend:
|
|
2270
|
-
onRegenerate:
|
|
2271
|
-
onStop:
|
|
2272
|
-
onScrollToBottom:
|
|
2309
|
+
ke(ko, {
|
|
2310
|
+
modelValue: l.value,
|
|
2311
|
+
"onUpdate:modelValue": ne[0] || (ne[0] = (se) => l.value = se),
|
|
2312
|
+
isGenerating: ie(k),
|
|
2313
|
+
hasScroll: ie(A),
|
|
2314
|
+
isAtBottom: ie(j),
|
|
2315
|
+
onSend: ie(O),
|
|
2316
|
+
onRegenerate: ie(q),
|
|
2317
|
+
onStop: ie(X),
|
|
2318
|
+
onScrollToBottom: ie(V)
|
|
2273
2319
|
}, null, 8, ["modelValue", "isGenerating", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
|
|
2274
|
-
|
|
2320
|
+
ne[3] || (ne[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
|
|
2275
2321
|
]);
|
|
2276
2322
|
};
|
|
2277
2323
|
}
|
|
2278
2324
|
}), Oo = { class: "ai-history" }, Wo = { class: "content" }, Bo = {
|
|
2279
2325
|
key: 0,
|
|
2280
2326
|
class: "ai-history-loading"
|
|
2281
|
-
}, Fo = { class: "ai-history-group-title" },
|
|
2327
|
+
}, Fo = { class: "ai-history-group-title" }, Io = ["onClick"], Xo = { class: "ai-history-item-title" }, zo = {
|
|
2282
2328
|
key: 0,
|
|
2283
2329
|
class: "ai-history-item-badge"
|
|
2284
2330
|
}, qo = ["onClick"], Go = {
|
|
2285
2331
|
key: 2,
|
|
2286
2332
|
class: "ai-history-empty"
|
|
2287
|
-
}, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */
|
|
2333
|
+
}, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */ $e({
|
|
2288
2334
|
__name: "History",
|
|
2289
2335
|
props: {
|
|
2290
2336
|
localSessions: {}
|
|
2291
2337
|
},
|
|
2292
2338
|
emits: ["history-detail", "new-conversation"],
|
|
2293
2339
|
setup(t, { emit: w }) {
|
|
2294
|
-
const e = t, a =
|
|
2295
|
-
const
|
|
2340
|
+
const e = t, a = lt().apis, f = _([]), g = _(!0), l = _(!1), r = _(""), M = S(() => {
|
|
2341
|
+
const R = f.value.map((y) => ({ ...y }));
|
|
2296
2342
|
for (const y of e.localSessions ?? []) {
|
|
2297
2343
|
if (!y.conversationId) continue;
|
|
2298
|
-
const
|
|
2299
|
-
if (
|
|
2300
|
-
|
|
2301
|
-
...
|
|
2344
|
+
const N = R.findIndex((A) => A.appConversationID === y.conversationId);
|
|
2345
|
+
if (N >= 0) {
|
|
2346
|
+
R[N] = {
|
|
2347
|
+
...R[N],
|
|
2302
2348
|
// 本地标题(标题生成完成)优先于服务端默认名
|
|
2303
|
-
conversationName: y.title ||
|
|
2349
|
+
conversationName: y.title || R[N].conversationName,
|
|
2304
2350
|
generating: y.generating
|
|
2305
2351
|
};
|
|
2306
2352
|
continue;
|
|
2307
2353
|
}
|
|
2308
|
-
const
|
|
2309
|
-
|
|
2354
|
+
const j = Math.floor(y.updatedAt / 1e3);
|
|
2355
|
+
R.push({
|
|
2310
2356
|
appConversationID: y.conversationId,
|
|
2311
2357
|
conversationID: y.conversationId,
|
|
2312
2358
|
conversationName: y.title || "新对话",
|
|
2313
2359
|
createTime: "",
|
|
2314
|
-
createTimestamp:
|
|
2360
|
+
createTimestamp: j,
|
|
2315
2361
|
lastChatTime: "",
|
|
2316
|
-
lastChatTimestamp:
|
|
2362
|
+
lastChatTimestamp: j,
|
|
2317
2363
|
emptyConversation: !1,
|
|
2318
2364
|
isPinned: !1,
|
|
2319
2365
|
selected: !1,
|
|
2320
2366
|
generating: y.generating
|
|
2321
2367
|
});
|
|
2322
2368
|
}
|
|
2323
|
-
return
|
|
2369
|
+
return R.map((y) => ({
|
|
2324
2370
|
...y,
|
|
2325
|
-
conversationName:
|
|
2371
|
+
conversationName: vs(y.conversationName) ? "新的对话" : y.conversationName
|
|
2326
2372
|
}));
|
|
2327
|
-
}), C = S(() =>
|
|
2373
|
+
}), C = S(() => hs(M.value));
|
|
2328
2374
|
async function E() {
|
|
2329
2375
|
try {
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2332
|
-
} catch (
|
|
2333
|
-
|
|
2376
|
+
const R = await fs(a);
|
|
2377
|
+
R != null && R.conversationList && (f.value = R.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
|
|
2378
|
+
} catch (R) {
|
|
2379
|
+
Fe((R == null ? void 0 : R.message) || "获取历史记录失败");
|
|
2334
2380
|
} finally {
|
|
2335
|
-
|
|
2381
|
+
g.value = !1;
|
|
2336
2382
|
}
|
|
2337
2383
|
}
|
|
2338
|
-
function
|
|
2339
|
-
|
|
2384
|
+
function T(R) {
|
|
2385
|
+
r.value = R, l.value = !0;
|
|
2340
2386
|
}
|
|
2341
2387
|
async function I() {
|
|
2342
|
-
|
|
2388
|
+
l.value = !1;
|
|
2343
2389
|
try {
|
|
2344
|
-
await
|
|
2345
|
-
} catch (
|
|
2346
|
-
|
|
2390
|
+
await ms(a, r.value), await E();
|
|
2391
|
+
} catch (R) {
|
|
2392
|
+
Fe((R == null ? void 0 : R.message) || "删除失败"), await E();
|
|
2347
2393
|
}
|
|
2348
2394
|
}
|
|
2349
|
-
return
|
|
2395
|
+
return Pe(() => {
|
|
2350
2396
|
E();
|
|
2351
|
-
}), (
|
|
2397
|
+
}), (R, y) => (i(), h("div", Oo, [
|
|
2352
2398
|
o("div", Wo, [
|
|
2353
|
-
|
|
2399
|
+
g.value ? (i(), h("div", Bo, [...y[3] || (y[3] = [
|
|
2354
2400
|
o("div", { class: "ai-history-spinner" }, null, -1)
|
|
2355
|
-
])])) : C.value.length > 0 ? (i(!0),
|
|
2356
|
-
key:
|
|
2401
|
+
])])) : C.value.length > 0 ? (i(!0), h(Ce, { key: 1 }, Ae(C.value, (N) => (i(), h("div", {
|
|
2402
|
+
key: N.label,
|
|
2357
2403
|
class: "ai-history-group"
|
|
2358
2404
|
}, [
|
|
2359
|
-
o("div", Fo,
|
|
2360
|
-
(i(!0),
|
|
2361
|
-
key:
|
|
2405
|
+
o("div", Fo, te(N.label), 1),
|
|
2406
|
+
(i(!0), h(Ce, null, Ae(N.items, (j, A) => (i(), h("div", {
|
|
2407
|
+
key: j.appConversationID,
|
|
2362
2408
|
class: "ai-history-item",
|
|
2363
|
-
style:
|
|
2364
|
-
onClick: (
|
|
2409
|
+
style: kt({ "--i": A }),
|
|
2410
|
+
onClick: (V) => R.$emit("history-detail", j.appConversationID)
|
|
2365
2411
|
}, [
|
|
2366
|
-
o("div",
|
|
2367
|
-
|
|
2368
|
-
|
|
2412
|
+
o("div", Xo, [
|
|
2413
|
+
fn(te(j.conversationName) + " ", 1),
|
|
2414
|
+
j.generating ? (i(), h("span", zo, "生成中")) : z("", !0)
|
|
2369
2415
|
]),
|
|
2370
2416
|
o("div", {
|
|
2371
2417
|
class: "ai-history-item-delete",
|
|
2372
|
-
onClick:
|
|
2418
|
+
onClick: Le((V) => T(j.appConversationID), ["stop"])
|
|
2373
2419
|
}, "删除", 8, qo)
|
|
2374
|
-
], 12,
|
|
2375
|
-
]))), 128)) : (i(),
|
|
2420
|
+
], 12, Io))), 128))
|
|
2421
|
+
]))), 128)) : (i(), h("div", Go, "暂无历史记录"))
|
|
2376
2422
|
]),
|
|
2377
2423
|
o("div", {
|
|
2378
2424
|
class: "ai-add",
|
|
2379
|
-
onClick: y[0] || (y[0] = (
|
|
2425
|
+
onClick: y[0] || (y[0] = (N) => R.$emit("new-conversation"))
|
|
2380
2426
|
}, [
|
|
2381
|
-
o("img", { src:
|
|
2427
|
+
o("img", { src: ie(Rs) }, null, 8, Ko),
|
|
2382
2428
|
y[4] || (y[4] = o("span", null, "新建AI对话", -1))
|
|
2383
2429
|
]),
|
|
2384
|
-
(i(),
|
|
2385
|
-
|
|
2430
|
+
(i(), we(mn, { to: "#ai-assist-root" }, [
|
|
2431
|
+
l.value ? (i(), h("div", {
|
|
2386
2432
|
key: 0,
|
|
2387
2433
|
class: "ai-modal-overlay",
|
|
2388
|
-
onClick: y[2] || (y[2] =
|
|
2434
|
+
onClick: y[2] || (y[2] = Le((N) => l.value = !1, ["self"]))
|
|
2389
2435
|
}, [
|
|
2390
2436
|
o("div", Yo, [
|
|
2391
2437
|
y[5] || (y[5] = o("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
|
|
@@ -2393,7 +2439,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2393
2439
|
o("div", Qo, [
|
|
2394
2440
|
o("button", {
|
|
2395
2441
|
class: "ai-modal-btn cancel",
|
|
2396
|
-
onClick: y[1] || (y[1] = (
|
|
2442
|
+
onClick: y[1] || (y[1] = (N) => l.value = !1)
|
|
2397
2443
|
}, "取消"),
|
|
2398
2444
|
o("button", {
|
|
2399
2445
|
class: "ai-modal-btn confirm",
|
|
@@ -2401,23 +2447,23 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2401
2447
|
}, "确定")
|
|
2402
2448
|
])
|
|
2403
2449
|
])
|
|
2404
|
-
])) :
|
|
2450
|
+
])) : z("", !0)
|
|
2405
2451
|
]))
|
|
2406
2452
|
]));
|
|
2407
2453
|
}
|
|
2408
|
-
}), Jo = { class: "container info" }, Zo = { class: "info-item" }, Uo = { class: "basic-content" }, ei = { class: "basic-content-text" }, ti = { class: "basic-content" }, ni = { class: "basic-content-text" }, si = { class: "info-item" }, ai = { class: "permission-content" }, oi = { class: "info-item" }, ii = { class: "basic-content" }, li = { class: "basic-content-text" }, ri = { class: "basic-content" }, ui = { class: "basic-content-text" }, ci = /* @__PURE__ */
|
|
2454
|
+
}), Jo = { class: "container info" }, Zo = { class: "info-item" }, Uo = { class: "basic-content" }, ei = { class: "basic-content-text" }, ti = { class: "basic-content" }, ni = { class: "basic-content-text" }, si = { class: "info-item" }, ai = { class: "permission-content" }, oi = { class: "info-item" }, ii = { class: "basic-content" }, li = { class: "basic-content-text" }, ri = { class: "basic-content" }, ui = { class: "basic-content-text" }, ci = /* @__PURE__ */ $e({
|
|
2409
2455
|
__name: "Info",
|
|
2410
2456
|
setup(t) {
|
|
2411
|
-
const w =
|
|
2412
|
-
return
|
|
2457
|
+
const w = lt(), e = _(null);
|
|
2458
|
+
return Pe(async () => {
|
|
2413
2459
|
try {
|
|
2414
|
-
e.value = await
|
|
2415
|
-
} catch (
|
|
2416
|
-
|
|
2460
|
+
e.value = await gs(w.apis);
|
|
2461
|
+
} catch (v) {
|
|
2462
|
+
Fe((v == null ? void 0 : v.message) || "获取个人信息失败");
|
|
2417
2463
|
}
|
|
2418
|
-
}), (
|
|
2419
|
-
var
|
|
2420
|
-
return i(),
|
|
2464
|
+
}), (v, a) => {
|
|
2465
|
+
var f, g, l, r, M;
|
|
2466
|
+
return i(), h("div", Jo, [
|
|
2421
2467
|
o("div", Zo, [
|
|
2422
2468
|
a[2] || (a[2] = o("div", { class: "heading" }, [
|
|
2423
2469
|
o("div", { class: "heading-column" }),
|
|
@@ -2425,11 +2471,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2425
2471
|
], -1)),
|
|
2426
2472
|
o("div", Uo, [
|
|
2427
2473
|
a[0] || (a[0] = o("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
|
|
2428
|
-
o("div", ei,
|
|
2474
|
+
o("div", ei, te(((f = e.value) == null ? void 0 : f.name) || ""), 1)
|
|
2429
2475
|
]),
|
|
2430
2476
|
o("div", ti, [
|
|
2431
2477
|
a[1] || (a[1] = o("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
|
|
2432
|
-
o("div", ni,
|
|
2478
|
+
o("div", ni, te(((g = e.value) == null ? void 0 : g.userName) || ""), 1)
|
|
2433
2479
|
])
|
|
2434
2480
|
]),
|
|
2435
2481
|
o("div", si, [
|
|
@@ -2438,10 +2484,10 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2438
2484
|
o("div", { class: "heading-title" }, "数据权限")
|
|
2439
2485
|
], -1)),
|
|
2440
2486
|
o("div", ai, [
|
|
2441
|
-
(i(!0),
|
|
2487
|
+
(i(!0), h(Ce, null, Ae((l = e.value) == null ? void 0 : l.ptnameList, (C, E) => (i(), h("div", {
|
|
2442
2488
|
key: E,
|
|
2443
2489
|
class: "permission-content-text"
|
|
2444
|
-
},
|
|
2490
|
+
}, te(C), 1))), 128))
|
|
2445
2491
|
])
|
|
2446
2492
|
]),
|
|
2447
2493
|
o("div", oi, [
|
|
@@ -2451,11 +2497,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2451
2497
|
], -1)),
|
|
2452
2498
|
o("div", ii, [
|
|
2453
2499
|
a[4] || (a[4] = o("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
|
|
2454
|
-
o("div", li,
|
|
2500
|
+
o("div", li, te(((r = e.value) == null ? void 0 : r.dept) || ""), 1)
|
|
2455
2501
|
]),
|
|
2456
2502
|
o("div", ri, [
|
|
2457
2503
|
a[5] || (a[5] = o("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
|
|
2458
|
-
o("div", ui,
|
|
2504
|
+
o("div", ui, te(((M = e.value) == null ? void 0 : M.email) || ""), 1)
|
|
2459
2505
|
])
|
|
2460
2506
|
])
|
|
2461
2507
|
]);
|
|
@@ -2464,219 +2510,219 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2464
2510
|
}), di = {
|
|
2465
2511
|
key: 0,
|
|
2466
2512
|
class: "ai-context-chips"
|
|
2467
|
-
}, vi = ["title"], hi = /* @__PURE__ */
|
|
2513
|
+
}, vi = ["title"], hi = /* @__PURE__ */ $e({
|
|
2468
2514
|
__name: "AiContextChips",
|
|
2469
2515
|
props: {
|
|
2470
2516
|
context: {}
|
|
2471
2517
|
},
|
|
2472
2518
|
setup(t) {
|
|
2473
2519
|
const w = t, e = S(() => {
|
|
2474
|
-
const
|
|
2475
|
-
return a.platform &&
|
|
2520
|
+
const v = w.context || {}, a = v.filters || {}, f = v.status || {}, g = v.summary || {}, l = [];
|
|
2521
|
+
return a.platform && l.push(String(a.platform)), a.year && a.period ? l.push(`${a.year}年${a.period}月`) : a.year && l.push(`${a.year}年`), a.company && l.push(String(a.company)), v.module === "turnover_detail" && l.push(f.isCompanyView ? "公司维度" : "平台维度"), f.isLocked && l.push("已锁定"), typeof g.rowCount == "number" && l.push(`${g.rowCount} 条`), g.totalAmount && l.push(`当年完成 ${g.totalAmount}${g.unit || ""}`), l;
|
|
2476
2522
|
});
|
|
2477
|
-
return (
|
|
2478
|
-
(i(!0),
|
|
2479
|
-
key:
|
|
2523
|
+
return (v, a) => e.value.length ? (i(), h("div", di, [
|
|
2524
|
+
(i(!0), h(Ce, null, Ae(e.value, (f, g) => (i(), h("span", {
|
|
2525
|
+
key: g,
|
|
2480
2526
|
class: "ai-context-chip",
|
|
2481
|
-
title:
|
|
2482
|
-
},
|
|
2483
|
-
])) :
|
|
2527
|
+
title: f
|
|
2528
|
+
}, te(f), 9, vi))), 128))
|
|
2529
|
+
])) : z("", !0);
|
|
2484
2530
|
}
|
|
2485
|
-
}), fi = { key: 1 }, mi = ["src"], gi = { class: "header-title" }, pi = ["title"], yi = { class: "ai-history-drawer-panel" }, wi = { class: "ai-history-drawer-header" }, ki = { class: "setTitle" }, _i = { class: "content" }, Ci = { class: "main" }, bi = { class: "btn" }, Mi = ["src"], $i = 78,
|
|
2531
|
+
}), fi = { key: 1 }, mi = ["src"], gi = { class: "header-title" }, pi = ["title"], yi = { class: "ai-history-drawer-panel" }, wi = { class: "ai-history-drawer-header" }, ki = { class: "setTitle" }, _i = { class: "content" }, Ci = { class: "main" }, bi = { class: "btn" }, Mi = ["src"], $i = 78, st = 78, Ee = 8, at = 26, ze = 490, dn = "aiPanelPosition", vn = "aiPanelDocked", Si = "aiDockWidth", Ti = 60, xi = 150, hn = 400, Di = 320, Ei = "aiDockWidth:page", Mn = /* @__PURE__ */ $e({
|
|
2486
2532
|
__name: "AiAssist",
|
|
2487
2533
|
setup(t) {
|
|
2488
|
-
var
|
|
2489
|
-
const w = $i / 2, e =
|
|
2490
|
-
var $,
|
|
2534
|
+
var Zt, Ut;
|
|
2535
|
+
const w = $i / 2, e = lt(), v = _(Ct()), a = S(() => v.value === "page"), f = _({}), g = S(() => {
|
|
2536
|
+
var $, K, ce;
|
|
2491
2537
|
const n = e.name || "AI 助手";
|
|
2492
|
-
return a.value ? ((
|
|
2493
|
-
}),
|
|
2494
|
-
var
|
|
2538
|
+
return a.value ? ((K = ($ = e.pageMode) == null ? void 0 : $.titles) == null ? void 0 : K[We()]) || ((ce = e.pageMode) == null ? void 0 : ce.title) || n || "AI 助手" : n;
|
|
2539
|
+
}), l = S(() => {
|
|
2540
|
+
var d, $;
|
|
2495
2541
|
if (!a.value) return e.defaultRecommend;
|
|
2496
|
-
const n = ($ = (
|
|
2542
|
+
const n = ($ = (d = e.pageMode) == null ? void 0 : d.recommend) == null ? void 0 : $[We()];
|
|
2497
2543
|
return n != null && n.length ? n : e.defaultRecommend;
|
|
2498
2544
|
});
|
|
2499
|
-
let
|
|
2545
|
+
let r = "", M = We();
|
|
2500
2546
|
const C = _(!1);
|
|
2501
2547
|
let E = null;
|
|
2502
|
-
const
|
|
2548
|
+
const T = _(!1), I = _("idle"), R = _(!1), y = He({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), N = _(!1), j = _(window.innerWidth < 768), A = _(window.innerWidth < 768), V = _("answer"), le = _(!1), s = _(""), ae = _(""), re = _(""), de = _(!1), k = _(!1), U = _([]), m = He({
|
|
2503
2549
|
x: window.innerWidth - w,
|
|
2504
|
-
y: window.innerHeight / 2 -
|
|
2505
|
-
}),
|
|
2550
|
+
y: window.innerHeight / 2 - st / 2
|
|
2551
|
+
}), O = _(!1), q = _(!1), X = _("right"), L = _("left"), D = _(null), c = He({ x: 0, y: 0 }), b = _(!1), x = _(!1), H = He({ x: 0, y: 0 }), F = _(!1), u = He({ x: 0, y: 0 }), p = _(!1), Y = _(!1), oe = _(!1), J = He({ x: 0, width: 0 }), B = _(!1);
|
|
2506
2552
|
let W = 0;
|
|
2507
|
-
const
|
|
2508
|
-
let
|
|
2509
|
-
const
|
|
2510
|
-
let
|
|
2511
|
-
const
|
|
2553
|
+
const ue = _("idle"), Q = _(!1), ve = _("none"), fe = He({ x: 0, y: 0, w: ze, h: 0, radius: "14px" });
|
|
2554
|
+
let G = null, ne = !1, P = !1;
|
|
2555
|
+
const se = He({ x: 0, y: 0 }), ee = _(!1), Z = _(null);
|
|
2556
|
+
let _e = null, Re = null, Ne = null;
|
|
2557
|
+
const be = S(() => {
|
|
2512
2558
|
const n = window.innerWidth / 2;
|
|
2513
|
-
return
|
|
2514
|
-
}),
|
|
2559
|
+
return m.x + w < n ? 5 : -5;
|
|
2560
|
+
}), Oe = S(() => A.value || p.value || a.value || ue.value !== "idle" ? "" : `panel-${X.value}`), Ie = S(() => {
|
|
2515
2561
|
var n;
|
|
2516
|
-
return !!((n = e.dock) != null && n.containerId) && !
|
|
2517
|
-
}),
|
|
2518
|
-
a.value ? ((
|
|
2519
|
-
),
|
|
2562
|
+
return !!((n = e.dock) != null && n.containerId) && !j.value;
|
|
2563
|
+
}), pe = _(
|
|
2564
|
+
a.value ? ((Zt = e.pageMode) == null ? void 0 : Zt.width) || 440 : ((Ut = e.dock) == null ? void 0 : Ut.width) || ze
|
|
2565
|
+
), Ht = () => a.value ? Ei : Si, Nt = S(() => e.panelDraggable !== !1), $n = S(() => {
|
|
2520
2566
|
var n;
|
|
2521
|
-
return !((n =
|
|
2522
|
-
}),
|
|
2523
|
-
left: `${
|
|
2524
|
-
top: `${
|
|
2525
|
-
transition:
|
|
2526
|
-
"--direction": String(
|
|
2527
|
-
})),
|
|
2567
|
+
return !((n = Z.value) != null && n.isEmptyConversation);
|
|
2568
|
+
}), Sn = S(() => ({
|
|
2569
|
+
left: `${m.x}px`,
|
|
2570
|
+
top: `${m.y}px`,
|
|
2571
|
+
transition: O.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
|
|
2572
|
+
"--direction": String(be.value)
|
|
2573
|
+
})), Tn = S(() => e.characterImage || Ps), xn = S(() => I.value === "idle" ? {} : {
|
|
2528
2574
|
left: `${y.x}px`,
|
|
2529
2575
|
top: `${y.y}px`,
|
|
2530
2576
|
width: `${y.w}px`,
|
|
2531
2577
|
height: `${y.h}px`,
|
|
2532
2578
|
borderRadius: y.radius
|
|
2533
|
-
}),
|
|
2579
|
+
}), Dn = S(() => {
|
|
2534
2580
|
const n = {};
|
|
2535
|
-
return b.value && !
|
|
2536
|
-
}),
|
|
2537
|
-
left: `${
|
|
2538
|
-
top: `${
|
|
2539
|
-
width: `${
|
|
2540
|
-
height: `${
|
|
2541
|
-
borderRadius:
|
|
2581
|
+
return b.value && !A.value && !j.value && !p.value && (n["--ai-panel-x"] = `${c.x}px`, n["--ai-panel-y"] = `${c.y}px`), (p.value || a.value) && (n["--ai-dock-width"] = `${pe.value}px`), n;
|
|
2582
|
+
}), En = S(() => ue.value === "idle" ? {} : {
|
|
2583
|
+
left: `${fe.x}px`,
|
|
2584
|
+
top: `${fe.y}px`,
|
|
2585
|
+
width: `${fe.w}px`,
|
|
2586
|
+
height: `${fe.h}px`,
|
|
2587
|
+
borderRadius: fe.radius
|
|
2542
2588
|
});
|
|
2543
|
-
function
|
|
2589
|
+
function Ye() {
|
|
2544
2590
|
const n = window.innerWidth / 2;
|
|
2545
|
-
|
|
2546
|
-
}
|
|
2547
|
-
function En() {
|
|
2548
|
-
const n = window.innerWidth, v = Math.max(0, Math.min(g.y, window.innerHeight - nt));
|
|
2549
|
-
return { x: g.x + w >= n / 2 ? n - w : -w, y: v };
|
|
2591
|
+
m.x + w < n ? (X.value = "left", L.value = "right") : (X.value = "right", L.value = "left");
|
|
2550
2592
|
}
|
|
2551
|
-
function
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2593
|
+
function An() {
|
|
2594
|
+
const n = window.innerWidth, d = Math.max(0, Math.min(m.y, window.innerHeight - st));
|
|
2595
|
+
return { x: m.x + w >= n / 2 ? n - w : -w, y: d };
|
|
2596
|
+
}
|
|
2597
|
+
function Vt() {
|
|
2598
|
+
q.value = !0;
|
|
2599
|
+
const n = An();
|
|
2600
|
+
m.x = n.x, m.y = n.y, setTimeout(() => {
|
|
2601
|
+
q.value = !1, Ye(), Rn();
|
|
2556
2602
|
}, 400);
|
|
2557
2603
|
}
|
|
2558
|
-
function
|
|
2604
|
+
function Rn() {
|
|
2559
2605
|
try {
|
|
2560
|
-
localStorage.setItem("characterPosition", JSON.stringify({ x:
|
|
2606
|
+
localStorage.setItem("characterPosition", JSON.stringify({ x: m.x, y: m.y })), localStorage.setItem("panelPosition", X.value), localStorage.setItem("backPosition", L.value);
|
|
2561
2607
|
} catch {
|
|
2562
2608
|
}
|
|
2563
2609
|
}
|
|
2564
|
-
function
|
|
2610
|
+
function Pn() {
|
|
2565
2611
|
const n = localStorage.getItem("characterPosition");
|
|
2566
2612
|
if (n) {
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2613
|
+
const K = JSON.parse(n);
|
|
2614
|
+
m.x = K.x, m.y = Math.min(Math.max(K.y, 0), window.innerHeight - st);
|
|
2569
2615
|
} else
|
|
2570
|
-
|
|
2571
|
-
const
|
|
2572
|
-
|
|
2616
|
+
m.x = window.innerWidth - w, m.y = window.innerHeight / 2 - st / 2;
|
|
2617
|
+
const d = localStorage.getItem("panelPosition"), $ = localStorage.getItem("backPosition");
|
|
2618
|
+
d && (X.value = d), $ && (L.value = $);
|
|
2573
2619
|
}
|
|
2574
|
-
function
|
|
2575
|
-
if (!
|
|
2576
|
-
const
|
|
2577
|
-
|
|
2620
|
+
function rt(n) {
|
|
2621
|
+
if (!O.value) return;
|
|
2622
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY, K = d - se.x, ce = Math.max(0, Math.min($ - se.y, window.innerHeight - st)), he = Math.abs(K - m.x), ye = Math.abs(ce - m.y);
|
|
2623
|
+
he + ye > 5 && (ee.value = !0), m.x = K, m.y = ce;
|
|
2578
2624
|
}
|
|
2579
|
-
function
|
|
2580
|
-
|
|
2625
|
+
function ut() {
|
|
2626
|
+
O.value && (O.value = !1, ee.value && (Vt(), ee.value = !1));
|
|
2581
2627
|
}
|
|
2582
|
-
function
|
|
2583
|
-
|
|
2584
|
-
const
|
|
2585
|
-
|
|
2628
|
+
function Ot(n) {
|
|
2629
|
+
q.value = !1, O.value = !0, ee.value = !1;
|
|
2630
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
2631
|
+
se.x = d - m.x, se.y = $ - m.y;
|
|
2586
2632
|
}
|
|
2587
|
-
function
|
|
2588
|
-
const n = D.value,
|
|
2633
|
+
function Ln() {
|
|
2634
|
+
const n = D.value, d = (n == null ? void 0 : n.offsetWidth) || ze, $ = (n == null ? void 0 : n.offsetHeight) || window.innerHeight - 78;
|
|
2589
2635
|
return {
|
|
2590
|
-
maxX: Math.max(
|
|
2591
|
-
maxY: Math.max(
|
|
2636
|
+
maxX: Math.max(Ee, window.innerWidth - d - Ee),
|
|
2637
|
+
maxY: Math.max(at, window.innerHeight - $ - Ee)
|
|
2592
2638
|
};
|
|
2593
2639
|
}
|
|
2594
|
-
function
|
|
2595
|
-
const $ = D.value,
|
|
2596
|
-
|
|
2640
|
+
function ct(n, d) {
|
|
2641
|
+
const $ = D.value, K = n ?? ($ == null ? void 0 : $.offsetWidth) ?? ze, ce = d ?? ($ == null ? void 0 : $.offsetHeight) ?? window.innerHeight - 78, he = Math.max(Ee, window.innerWidth - K - Ee), ye = Math.max(at, window.innerHeight - ce - Ee);
|
|
2642
|
+
c.x = Math.min(Math.max(c.x, Ee), he), c.y = Math.min(Math.max(c.y, at), ye);
|
|
2597
2643
|
}
|
|
2598
|
-
function
|
|
2599
|
-
if (!
|
|
2600
|
-
if (
|
|
2601
|
-
const
|
|
2602
|
-
if (
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2644
|
+
function Wt(n) {
|
|
2645
|
+
if (!Nt.value || A.value || j.value || p.value || I.value !== "idle") return;
|
|
2646
|
+
if (P = !1, x.value = !0, F.value = !1, !b.value) {
|
|
2647
|
+
const K = D.value;
|
|
2648
|
+
if (K) {
|
|
2649
|
+
const ce = K.getBoundingClientRect();
|
|
2650
|
+
c.x = ce.left, c.y = ce.top, b.value = !0;
|
|
2605
2651
|
}
|
|
2606
2652
|
}
|
|
2607
|
-
const
|
|
2608
|
-
|
|
2609
|
-
}
|
|
2610
|
-
function
|
|
2611
|
-
var
|
|
2612
|
-
if (!
|
|
2613
|
-
const
|
|
2614
|
-
if (!
|
|
2615
|
-
const
|
|
2616
|
-
if (
|
|
2617
|
-
|
|
2653
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
2654
|
+
u.x = d, u.y = $, H.x = d - c.x, H.y = $ - c.y;
|
|
2655
|
+
}
|
|
2656
|
+
function dt(n) {
|
|
2657
|
+
var Me, Xe;
|
|
2658
|
+
if (!x.value) return;
|
|
2659
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
2660
|
+
if (!F.value) {
|
|
2661
|
+
const Ke = Math.abs(d - u.x), wt = Math.abs($ - u.y);
|
|
2662
|
+
if (Ke + wt <= 5) return;
|
|
2663
|
+
F.value = !0;
|
|
2618
2664
|
}
|
|
2619
|
-
const { maxX:
|
|
2620
|
-
|
|
2665
|
+
const { maxX: K, maxY: ce } = Ln(), he = Ie.value ? K + xi : K, ye = Math.min(Math.max(d - H.x, Ee), he), xe = Math.min(Math.max($ - H.y, at), ce), De = Ie.value && ye > K + Ti;
|
|
2666
|
+
De !== P && (P = De, (Xe = (Me = e.dock) == null ? void 0 : Me.onDockChange) == null || Xe.call(Me, De)), Y.value = De, c.x = ye, c.y = xe;
|
|
2621
2667
|
}
|
|
2622
|
-
function
|
|
2623
|
-
var
|
|
2624
|
-
if (!
|
|
2625
|
-
|
|
2668
|
+
function vt() {
|
|
2669
|
+
var d, $;
|
|
2670
|
+
if (!x.value) return;
|
|
2671
|
+
x.value = !1;
|
|
2626
2672
|
let n = !1;
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
}, 0),
|
|
2673
|
+
F.value && (F.value = !1, ne = !0, setTimeout(() => {
|
|
2674
|
+
ne = !1;
|
|
2675
|
+
}, 0), Y.value && Ie.value ? (zt(), n = !0) : (ct(), Hn())), P && !n && (P = !1, ($ = (d = e.dock) == null ? void 0 : d.onDockChange) == null || $.call(d, !1)), Y.value = !1;
|
|
2630
2676
|
}
|
|
2631
|
-
function
|
|
2632
|
-
|
|
2677
|
+
function Bt(n) {
|
|
2678
|
+
ne && (n.preventDefault(), n.stopPropagation(), ne = !1);
|
|
2633
2679
|
}
|
|
2634
|
-
function
|
|
2680
|
+
function Hn() {
|
|
2635
2681
|
try {
|
|
2636
|
-
localStorage.setItem(
|
|
2682
|
+
localStorage.setItem(dn, JSON.stringify({ x: c.x, y: c.y }));
|
|
2637
2683
|
} catch {
|
|
2638
2684
|
}
|
|
2639
2685
|
}
|
|
2640
|
-
function
|
|
2686
|
+
function Nn() {
|
|
2641
2687
|
try {
|
|
2642
|
-
const n = localStorage.getItem(
|
|
2688
|
+
const n = localStorage.getItem(dn);
|
|
2643
2689
|
if (n) {
|
|
2644
|
-
const
|
|
2645
|
-
typeof
|
|
2690
|
+
const d = JSON.parse(n);
|
|
2691
|
+
typeof d.x == "number" && typeof d.y == "number" && (c.x = d.x, c.y = d.y, b.value = !0);
|
|
2646
2692
|
}
|
|
2647
2693
|
} catch {
|
|
2648
2694
|
}
|
|
2649
2695
|
}
|
|
2650
|
-
function
|
|
2696
|
+
function Ft() {
|
|
2651
2697
|
try {
|
|
2652
|
-
localStorage.setItem(
|
|
2698
|
+
localStorage.setItem(vn, p.value ? "1" : "0");
|
|
2653
2699
|
} catch {
|
|
2654
2700
|
}
|
|
2655
2701
|
}
|
|
2656
|
-
function
|
|
2702
|
+
function It() {
|
|
2657
2703
|
var n;
|
|
2658
2704
|
if (!a.value)
|
|
2659
2705
|
try {
|
|
2660
|
-
if (localStorage.getItem(
|
|
2706
|
+
if (localStorage.getItem(vn) === "1" && Ie.value) {
|
|
2661
2707
|
const $ = (n = e.dock) == null ? void 0 : n.containerId;
|
|
2662
|
-
$ && document.getElementById($) && (
|
|
2708
|
+
$ && document.getElementById($) && (p.value = !0);
|
|
2663
2709
|
}
|
|
2664
2710
|
} catch {
|
|
2665
2711
|
}
|
|
2666
2712
|
}
|
|
2667
|
-
function
|
|
2713
|
+
function ht() {
|
|
2668
2714
|
return {
|
|
2669
|
-
x: window.innerWidth -
|
|
2715
|
+
x: window.innerWidth - pe.value,
|
|
2670
2716
|
y: 0,
|
|
2671
|
-
w:
|
|
2717
|
+
w: pe.value,
|
|
2672
2718
|
h: window.innerHeight,
|
|
2673
2719
|
radius: "0px"
|
|
2674
2720
|
};
|
|
2675
2721
|
}
|
|
2676
|
-
function
|
|
2722
|
+
function Vn() {
|
|
2677
2723
|
return {
|
|
2678
|
-
x: Math.max(0, Math.min(window.innerWidth - 53,
|
|
2679
|
-
y:
|
|
2724
|
+
x: Math.max(0, Math.min(window.innerWidth - 53, m.x + be.value * 3)),
|
|
2725
|
+
y: m.y,
|
|
2680
2726
|
w: 53,
|
|
2681
2727
|
h: 53,
|
|
2682
2728
|
radius: "50%"
|
|
@@ -2692,132 +2738,132 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2692
2738
|
radius: "14px"
|
|
2693
2739
|
};
|
|
2694
2740
|
}
|
|
2695
|
-
function
|
|
2696
|
-
|
|
2741
|
+
function On() {
|
|
2742
|
+
A.value ? (Ge(Xt(), Kt()), A.value = !1) : (Ge(je(), Xt()), A.value = !0);
|
|
2697
2743
|
}
|
|
2698
|
-
function
|
|
2699
|
-
|
|
2744
|
+
function Ge(n, d, $, K = "none") {
|
|
2745
|
+
G && clearTimeout(G), ue.value = "switching", Q.value = !0, ve.value = K, fe.x = n.x, fe.y = n.y, fe.w = n.w, fe.h = n.h, fe.radius = n.radius, Se(() => {
|
|
2700
2746
|
requestAnimationFrame(() => {
|
|
2701
|
-
|
|
2747
|
+
Q.value = !1, fe.x = d.x, fe.y = d.y, fe.w = d.w, fe.h = d.h, fe.radius = d.radius;
|
|
2702
2748
|
});
|
|
2703
|
-
}),
|
|
2704
|
-
|
|
2749
|
+
}), G = setTimeout(() => {
|
|
2750
|
+
ue.value = "idle", ve.value = "none", G = null, $ == null || $();
|
|
2705
2751
|
}, 400);
|
|
2706
2752
|
}
|
|
2707
2753
|
function zt() {
|
|
2708
|
-
var
|
|
2709
|
-
if (!
|
|
2710
|
-
|
|
2711
|
-
const n = (
|
|
2754
|
+
var ce, he, ye, xe, De;
|
|
2755
|
+
if (!Ie.value || p.value) return;
|
|
2756
|
+
A.value && (A.value = !1);
|
|
2757
|
+
const n = (ce = e.dock) == null ? void 0 : ce.containerId;
|
|
2712
2758
|
if (n && !document.getElementById(n)) {
|
|
2713
2759
|
console.warn(`[ai-assist-sdk] dock container "#${n}" not found, dock feature disabled`);
|
|
2714
2760
|
return;
|
|
2715
2761
|
}
|
|
2716
|
-
const
|
|
2717
|
-
let $ =
|
|
2718
|
-
if (
|
|
2719
|
-
const
|
|
2720
|
-
$ = { x:
|
|
2762
|
+
const d = D.value;
|
|
2763
|
+
let $ = je();
|
|
2764
|
+
if (d) {
|
|
2765
|
+
const Me = d.getBoundingClientRect();
|
|
2766
|
+
$ = { x: Me.left, y: Me.top, w: Me.width, h: Me.height, radius: getComputedStyle(d).borderRadius };
|
|
2721
2767
|
}
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2768
|
+
const K = ht();
|
|
2769
|
+
Ge($, K), p.value = !0, I.value = "idle", Y.value = !1, Ft(), (ye = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ye.call(he, !0), (De = (xe = e.dock) == null ? void 0 : xe.onDockWidthChange) == null || De.call(xe, pe.value);
|
|
2724
2770
|
}
|
|
2725
|
-
function
|
|
2726
|
-
return Math.max(
|
|
2771
|
+
function Wn() {
|
|
2772
|
+
return Math.max(hn, window.innerWidth - Di);
|
|
2727
2773
|
}
|
|
2728
|
-
function
|
|
2774
|
+
function Qe(n) {
|
|
2729
2775
|
if (a.value) {
|
|
2730
|
-
const
|
|
2731
|
-
return Math.min(Math.max(n, 360),
|
|
2776
|
+
const d = Math.max(360, Math.min(720, Math.min(window.innerWidth * 0.6, window.innerWidth - 80)));
|
|
2777
|
+
return Math.min(Math.max(n, 360), d);
|
|
2732
2778
|
}
|
|
2733
|
-
return Math.min(Math.max(n,
|
|
2779
|
+
return Math.min(Math.max(n, hn), Wn());
|
|
2734
2780
|
}
|
|
2735
|
-
function
|
|
2781
|
+
function Bn() {
|
|
2736
2782
|
try {
|
|
2737
|
-
localStorage.setItem(
|
|
2783
|
+
localStorage.setItem(Ht(), String(pe.value));
|
|
2738
2784
|
} catch {
|
|
2739
2785
|
}
|
|
2740
2786
|
}
|
|
2741
|
-
function
|
|
2787
|
+
function bt() {
|
|
2742
2788
|
try {
|
|
2743
|
-
const n = localStorage.getItem(
|
|
2789
|
+
const n = localStorage.getItem(Ht());
|
|
2744
2790
|
if (n) {
|
|
2745
|
-
const
|
|
2746
|
-
Number.isFinite(
|
|
2791
|
+
const d = parseFloat(n);
|
|
2792
|
+
Number.isFinite(d) && (pe.value = Qe(d));
|
|
2747
2793
|
}
|
|
2748
2794
|
} catch {
|
|
2749
2795
|
}
|
|
2750
2796
|
}
|
|
2751
|
-
function
|
|
2752
|
-
if (!
|
|
2753
|
-
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
}
|
|
2757
|
-
function
|
|
2758
|
-
if (!
|
|
2759
|
-
const
|
|
2760
|
-
Math.abs($ -
|
|
2761
|
-
var
|
|
2762
|
-
W = 0, (
|
|
2797
|
+
function qt(n) {
|
|
2798
|
+
if (!p.value && !a.value) return;
|
|
2799
|
+
oe.value = !0, B.value = !1;
|
|
2800
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX;
|
|
2801
|
+
J.x = d, J.width = pe.value, document.body.style.userSelect = "none";
|
|
2802
|
+
}
|
|
2803
|
+
function ft(n) {
|
|
2804
|
+
if (!oe.value) return;
|
|
2805
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, $ = Qe(J.width + (J.x - d));
|
|
2806
|
+
Math.abs($ - J.width) > 3 && (B.value = !0), pe.value = $, W || (W = requestAnimationFrame(() => {
|
|
2807
|
+
var K, ce;
|
|
2808
|
+
W = 0, (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, pe.value);
|
|
2763
2809
|
}));
|
|
2764
2810
|
}
|
|
2765
|
-
function
|
|
2766
|
-
var n,
|
|
2767
|
-
|
|
2811
|
+
function mt() {
|
|
2812
|
+
var n, d;
|
|
2813
|
+
oe.value && (oe.value = !1, document.body.style.userSelect = "", B.value && (B.value = !1, Bn(), (d = (n = e.dock) == null ? void 0 : n.onDockWidthChange) == null || d.call(n, pe.value)));
|
|
2768
2814
|
}
|
|
2769
|
-
function
|
|
2770
|
-
var n,
|
|
2771
|
-
|
|
2815
|
+
function Gt() {
|
|
2816
|
+
var n, d;
|
|
2817
|
+
p.value && (b.value ? ct(ze, window.innerHeight - 78) : Ye(), Ge(ht(), je()), p.value = !1, Ft(), (d = (n = e.dock) == null ? void 0 : n.onDockChange) == null || d.call(n, !1));
|
|
2772
2818
|
}
|
|
2773
|
-
function
|
|
2774
|
-
var
|
|
2775
|
-
if (
|
|
2819
|
+
function Fn() {
|
|
2820
|
+
var d, $, K, ce, he, ye, xe, De;
|
|
2821
|
+
if (T.value) return;
|
|
2776
2822
|
if (E && (clearTimeout(E), E = null), C.value = !1, a.value) {
|
|
2777
|
-
|
|
2778
|
-
const
|
|
2779
|
-
if (
|
|
2780
|
-
|
|
2823
|
+
T.value = !0, I.value = "idle", pe.value = Qe(pe.value), ($ = (d = e.dock) == null ? void 0 : d.onDockChange) == null || $.call(d, !0), (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, pe.value), _t();
|
|
2824
|
+
const Me = We();
|
|
2825
|
+
if (r !== Me) {
|
|
2826
|
+
r = Me;
|
|
2781
2827
|
try {
|
|
2782
|
-
(
|
|
2783
|
-
} catch (
|
|
2784
|
-
console.warn("[ai-assist-sdk] 页面会话恢复失败:",
|
|
2828
|
+
(ye = (he = Z.value) == null ? void 0 : he.restorePageHistory) == null || ye.call(he);
|
|
2829
|
+
} catch (Xe) {
|
|
2830
|
+
console.warn("[ai-assist-sdk] 页面会话恢复失败:", Xe);
|
|
2785
2831
|
}
|
|
2786
2832
|
}
|
|
2787
2833
|
return;
|
|
2788
2834
|
}
|
|
2789
|
-
if (
|
|
2790
|
-
|
|
2791
|
-
{ x: window.innerWidth, y: 0, w:
|
|
2792
|
-
|
|
2835
|
+
if (p.value) {
|
|
2836
|
+
Ge(
|
|
2837
|
+
{ x: window.innerWidth, y: 0, w: pe.value, h: window.innerHeight, radius: "0px" },
|
|
2838
|
+
ht(),
|
|
2793
2839
|
void 0,
|
|
2794
2840
|
"in"
|
|
2795
|
-
),
|
|
2841
|
+
), T.value = !0, I.value = "idle", (De = (xe = e.dock) == null ? void 0 : xe.onDockChange) == null || De.call(xe, !0);
|
|
2796
2842
|
return;
|
|
2797
2843
|
}
|
|
2798
|
-
|
|
2799
|
-
const n =
|
|
2800
|
-
y.x = Math.max(0, Math.min(window.innerWidth - 53,
|
|
2844
|
+
Ye();
|
|
2845
|
+
const n = je();
|
|
2846
|
+
y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + be.value * 3)), y.y = m.y - be.value * 2, y.w = 53, y.h = 53, y.radius = "50%", R.value = !0, I.value = "expanding", T.value = !0, Se(() => {
|
|
2801
2847
|
requestAnimationFrame(() => {
|
|
2802
|
-
|
|
2848
|
+
R.value = !1, y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius;
|
|
2803
2849
|
});
|
|
2804
2850
|
}), setTimeout(() => {
|
|
2805
2851
|
I.value = "idle";
|
|
2806
2852
|
}, 400);
|
|
2807
2853
|
}
|
|
2808
|
-
function
|
|
2809
|
-
if (
|
|
2810
|
-
|
|
2854
|
+
function In() {
|
|
2855
|
+
if (ee.value || q.value) {
|
|
2856
|
+
ee.value = !1;
|
|
2811
2857
|
return;
|
|
2812
2858
|
}
|
|
2813
|
-
|
|
2859
|
+
on(!0);
|
|
2814
2860
|
}
|
|
2815
2861
|
function Xn() {
|
|
2816
|
-
|
|
2862
|
+
on(!1);
|
|
2817
2863
|
}
|
|
2818
|
-
function
|
|
2864
|
+
function je() {
|
|
2819
2865
|
if (window.innerWidth < 768)
|
|
2820
|
-
return
|
|
2866
|
+
return A.value ? {
|
|
2821
2867
|
x: 0,
|
|
2822
2868
|
y: 0,
|
|
2823
2869
|
w: window.innerWidth,
|
|
@@ -2830,352 +2876,352 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2830
2876
|
h: window.innerHeight - 16,
|
|
2831
2877
|
radius: "14px"
|
|
2832
2878
|
};
|
|
2833
|
-
const
|
|
2879
|
+
const d = window.innerHeight - 78;
|
|
2834
2880
|
let $ = 54;
|
|
2835
|
-
if (
|
|
2836
|
-
const
|
|
2881
|
+
if (A.value) {
|
|
2882
|
+
const K = window.innerWidth * 0.8;
|
|
2837
2883
|
return {
|
|
2838
|
-
x: (window.innerWidth -
|
|
2884
|
+
x: (window.innerWidth - K) / 2,
|
|
2839
2885
|
y: $,
|
|
2840
|
-
w:
|
|
2841
|
-
h:
|
|
2886
|
+
w: K,
|
|
2887
|
+
h: d,
|
|
2842
2888
|
radius: "14px"
|
|
2843
2889
|
};
|
|
2844
2890
|
}
|
|
2845
|
-
return
|
|
2891
|
+
return Kt();
|
|
2846
2892
|
}
|
|
2847
|
-
function
|
|
2848
|
-
const n =
|
|
2849
|
-
let $ = 54,
|
|
2850
|
-
return b.value ? (
|
|
2893
|
+
function Kt() {
|
|
2894
|
+
const n = ze, d = window.innerHeight - 78;
|
|
2895
|
+
let $ = 54, K;
|
|
2896
|
+
return b.value ? (K = Math.min(Math.max(c.x, Ee), Math.max(Ee, window.innerWidth - n - Ee)), $ = Math.min(Math.max(c.y, at), Math.max(Ee, d - Ee))) : K = X.value === "left" ? 24 : window.innerWidth - n - 24, { x: K, y: $, w: n, h: d, radius: "14px" };
|
|
2851
2897
|
}
|
|
2852
2898
|
function zn() {
|
|
2853
|
-
var
|
|
2899
|
+
var d, $, K, ce, he, ye;
|
|
2854
2900
|
if (a.value) {
|
|
2855
2901
|
if (C.value) return;
|
|
2856
|
-
C.value = !0, ($ = (
|
|
2857
|
-
E = null, C.value = !1,
|
|
2902
|
+
C.value = !0, ($ = (d = e.dock) == null ? void 0 : d.onDockChange) == null || $.call(d, !1), (ce = (K = e.pageMode) == null ? void 0 : K.onVisibleChange) == null || ce.call(K, !1), E && clearTimeout(E), E = setTimeout(() => {
|
|
2903
|
+
E = null, C.value = !1, T.value = !1, I.value = "idle", ks("default");
|
|
2858
2904
|
}, 300);
|
|
2859
2905
|
return;
|
|
2860
2906
|
}
|
|
2861
|
-
if (
|
|
2862
|
-
if (
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2907
|
+
if (ue.value !== "idle") return;
|
|
2908
|
+
if (p.value) {
|
|
2909
|
+
Ge(ht(), Vn(), () => {
|
|
2910
|
+
T.value = !1, I.value = "idle", N.value = !0, setTimeout(() => {
|
|
2911
|
+
N.value = !1;
|
|
2866
2912
|
}, 1400);
|
|
2867
|
-
}, "out"), (
|
|
2913
|
+
}, "out"), (ye = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ye.call(he, !1);
|
|
2868
2914
|
return;
|
|
2869
2915
|
}
|
|
2870
2916
|
if (I.value !== "idle") return;
|
|
2871
|
-
const n =
|
|
2872
|
-
y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius,
|
|
2917
|
+
const n = je();
|
|
2918
|
+
y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius, R.value = !0, I.value = "collapsing", Se(() => {
|
|
2873
2919
|
requestAnimationFrame(() => {
|
|
2874
|
-
|
|
2920
|
+
R.value = !1, y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + be.value * 3)), y.y = m.y + Math.abs(be.value) * 2, y.w = 53, y.h = 53, y.radius = "50%";
|
|
2875
2921
|
});
|
|
2876
2922
|
}), setTimeout(() => {
|
|
2877
|
-
|
|
2923
|
+
T.value = !1, I.value = "idle", N.value = !0;
|
|
2878
2924
|
}, 400), setTimeout(() => {
|
|
2879
|
-
|
|
2925
|
+
N.value = !1;
|
|
2880
2926
|
}, 1400);
|
|
2881
2927
|
}
|
|
2882
|
-
function
|
|
2883
|
-
|
|
2884
|
-
var
|
|
2885
|
-
(
|
|
2928
|
+
function qn(n) {
|
|
2929
|
+
Je(), V.value = "answer", Se(() => {
|
|
2930
|
+
var d;
|
|
2931
|
+
(d = Z.value) == null || d.goHistoryMessage(n);
|
|
2886
2932
|
});
|
|
2887
2933
|
}
|
|
2888
|
-
function
|
|
2889
|
-
|
|
2934
|
+
function Gn() {
|
|
2935
|
+
re.value = "", V.value = "answer", Se(() => {
|
|
2890
2936
|
var n;
|
|
2891
|
-
(n =
|
|
2937
|
+
(n = Z.value) == null || n.createNewConversation();
|
|
2892
2938
|
});
|
|
2893
2939
|
}
|
|
2894
|
-
function
|
|
2895
|
-
|
|
2940
|
+
function Kn() {
|
|
2941
|
+
Je(), re.value = "", Se(() => {
|
|
2896
2942
|
var n;
|
|
2897
|
-
(n =
|
|
2943
|
+
(n = Z.value) == null || n.createNewConversation();
|
|
2898
2944
|
});
|
|
2899
2945
|
}
|
|
2900
|
-
function
|
|
2901
|
-
k.value = !1,
|
|
2946
|
+
function Yn() {
|
|
2947
|
+
k.value = !1, de.value = !0;
|
|
2902
2948
|
}
|
|
2903
|
-
function
|
|
2949
|
+
function Je() {
|
|
2904
2950
|
k.value = !0, setTimeout(() => {
|
|
2905
|
-
|
|
2951
|
+
de.value = !1, k.value = !1;
|
|
2906
2952
|
}, 300);
|
|
2907
2953
|
}
|
|
2908
|
-
function
|
|
2909
|
-
|
|
2954
|
+
function Qn() {
|
|
2955
|
+
ae.value = s.value, le.value = !1;
|
|
2910
2956
|
}
|
|
2911
|
-
|
|
2912
|
-
n ?
|
|
2913
|
-
}),
|
|
2914
|
-
n && b.value &&
|
|
2957
|
+
ge(A, (n) => {
|
|
2958
|
+
n ? X.value = "center" : Ye();
|
|
2959
|
+
}), ge(T, (n) => {
|
|
2960
|
+
n && b.value && Se(() => ct());
|
|
2915
2961
|
});
|
|
2916
|
-
function
|
|
2917
|
-
var
|
|
2918
|
-
if (n !==
|
|
2919
|
-
|
|
2962
|
+
function jn(n) {
|
|
2963
|
+
var d, $, K, ce, he, ye, xe, De, Me, Xe, Ke, wt;
|
|
2964
|
+
if (n !== v.value) {
|
|
2965
|
+
v.value = n, b.value = !1, Y.value = !1, x.value = !1, oe.value = !1, I.value = "idle", P = !1, re.value = "", r = "";
|
|
2920
2966
|
try {
|
|
2921
|
-
($ = (
|
|
2922
|
-
} catch (
|
|
2923
|
-
console.warn("[ai-assist-sdk] 切换形态清空会话失败:",
|
|
2967
|
+
($ = (d = Z.value) == null ? void 0 : d.clearActiveMessages) == null || $.call(d);
|
|
2968
|
+
} catch (Zn) {
|
|
2969
|
+
console.warn("[ai-assist-sdk] 切换形态清空会话失败:", Zn);
|
|
2924
2970
|
}
|
|
2925
2971
|
if (n === "page") {
|
|
2926
|
-
|
|
2972
|
+
A.value = !1, p.value = !1, pe.value = Qe(((K = e.pageMode) == null ? void 0 : K.width) || 440), bt(), T.value && ((he = (ce = e.dock) == null ? void 0 : ce.onDockChange) == null || he.call(ce, !0), (xe = (ye = e.dock) == null ? void 0 : ye.onDockWidthChange) == null || xe.call(ye, pe.value), _t());
|
|
2927
2973
|
return;
|
|
2928
2974
|
}
|
|
2929
|
-
|
|
2975
|
+
A.value = window.innerWidth < 768, pe.value = ((De = e.dock) == null ? void 0 : De.width) || ze, It(), bt(), Ye(), T.value && ((Xe = (Me = e.dock) == null ? void 0 : Me.onDockChange) == null || Xe.call(Me, p.value), (wt = (Ke = e.dock) == null ? void 0 : Ke.onDockWidthChange) == null || wt.call(Ke, pe.value));
|
|
2930
2976
|
}
|
|
2931
2977
|
}
|
|
2932
|
-
function
|
|
2933
|
-
var $,
|
|
2934
|
-
const
|
|
2935
|
-
|
|
2936
|
-
}
|
|
2937
|
-
let
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
var
|
|
2941
|
-
|
|
2942
|
-
const n =
|
|
2943
|
-
n !== M && (M = n,
|
|
2944
|
-
}),
|
|
2945
|
-
}),
|
|
2946
|
-
|
|
2978
|
+
function Mt(n = 0) {
|
|
2979
|
+
var $, K, ce, he;
|
|
2980
|
+
const d = ln();
|
|
2981
|
+
d !== T.value && (d ? Fn() : ws() ? (E && (clearTimeout(E), E = null), C.value = !1, T.value = !1, I.value = "idle", (K = ($ = e.dock) == null ? void 0 : $.onDockChange) == null || K.call($, !1), (he = (ce = e.pageMode) == null ? void 0 : ce.onVisibleChange) == null || he.call(ce, !1)) : zn(), n < 3 && ln() !== T.value && setTimeout(() => Mt(n + 1), 450));
|
|
2982
|
+
}
|
|
2983
|
+
let Ze = null;
|
|
2984
|
+
Pe(() => {
|
|
2985
|
+
Ze = ps(() => {
|
|
2986
|
+
var d, $;
|
|
2987
|
+
jn(Ct()), f.value = an(), Mt();
|
|
2988
|
+
const n = We();
|
|
2989
|
+
n !== M && (M = n, r = "", f.value = {}, ($ = (d = Z.value) == null ? void 0 : d.clearActiveMessages) == null || $.call(d), _t());
|
|
2990
|
+
}), f.value = an(), Mt();
|
|
2991
|
+
}), Be(() => {
|
|
2992
|
+
Ze == null || Ze(), Ze = null, E && (clearTimeout(E), E = null), C.value = !1;
|
|
2947
2993
|
});
|
|
2948
|
-
const
|
|
2949
|
-
let
|
|
2950
|
-
function
|
|
2994
|
+
const Jn = Math.max(1e3, Number(e.activityInterval) || 3e4);
|
|
2995
|
+
let gt = null, Ue = 0, pt = 0, yt = 0;
|
|
2996
|
+
function et(n) {
|
|
2951
2997
|
if (typeof e.onPanelActive == "function")
|
|
2952
2998
|
try {
|
|
2953
2999
|
if (n === "open") {
|
|
2954
|
-
|
|
3000
|
+
Ue = Date.now(), pt = 0, yt = 0, e.onPanelActive({ phase: n, docked: p.value, durationMs: 0, totalMs: 0 });
|
|
2955
3001
|
return;
|
|
2956
3002
|
}
|
|
2957
3003
|
if (document.visibilityState !== "hidden") {
|
|
2958
3004
|
const $ = Date.now();
|
|
2959
|
-
|
|
3005
|
+
pt += Math.max(0, $ - Ue), Ue = $;
|
|
2960
3006
|
}
|
|
2961
|
-
const
|
|
2962
|
-
if (
|
|
2963
|
-
|
|
3007
|
+
const d = Math.round(pt);
|
|
3008
|
+
if (d <= 0 && n !== "close") return;
|
|
3009
|
+
pt = 0, yt += d, e.onPanelActive({ phase: n, docked: p.value, durationMs: d, totalMs: yt }), n === "close" && (yt = 0);
|
|
2964
3010
|
} catch {
|
|
2965
3011
|
}
|
|
2966
3012
|
}
|
|
2967
|
-
function
|
|
2968
|
-
|
|
2969
|
-
!
|
|
2970
|
-
},
|
|
2971
|
-
}
|
|
2972
|
-
function et() {
|
|
2973
|
-
mt !== null && (clearInterval(mt), mt = null);
|
|
3013
|
+
function $t() {
|
|
3014
|
+
tt(), gt = window.setInterval(() => {
|
|
3015
|
+
!T.value || document.visibilityState === "hidden" || et("heartbeat");
|
|
3016
|
+
}, Jn);
|
|
2974
3017
|
}
|
|
2975
|
-
function
|
|
2976
|
-
|
|
3018
|
+
function tt() {
|
|
3019
|
+
gt !== null && (clearInterval(gt), gt = null);
|
|
2977
3020
|
}
|
|
2978
3021
|
function Yt() {
|
|
2979
|
-
|
|
3022
|
+
T.value && (document.visibilityState === "hidden" ? (tt(), et("hidden")) : (Ue = Date.now(), $t()));
|
|
2980
3023
|
}
|
|
2981
3024
|
function Qt() {
|
|
2982
|
-
|
|
2983
|
-
}
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
3025
|
+
T.value && (tt(), et("hidden"));
|
|
3026
|
+
}
|
|
3027
|
+
function jt() {
|
|
3028
|
+
!T.value || document.visibilityState === "hidden" || (Ue = Date.now(), $t());
|
|
3029
|
+
}
|
|
3030
|
+
ge(T, (n) => {
|
|
3031
|
+
n ? (et("open"), document.visibilityState !== "hidden" && $t()) : (tt(), et("close"));
|
|
3032
|
+
}), Pe(() => {
|
|
3033
|
+
document.addEventListener("visibilitychange", Yt), window.addEventListener("pagehide", Qt), window.addEventListener("pageshow", jt);
|
|
3034
|
+
}), Be(() => {
|
|
3035
|
+
tt(), document.removeEventListener("visibilitychange", Yt), window.removeEventListener("pagehide", Qt), window.removeEventListener("pageshow", jt);
|
|
3036
|
+
}), Pe(() => {
|
|
3037
|
+
Pn(), Nn(), It(), bt();
|
|
2992
3038
|
const n = e.theme || "light";
|
|
2993
|
-
|
|
3039
|
+
Pt(n), n === "auto" && (Re = ys(() => Pt("auto"))), Ne = Ls(() => D.value);
|
|
2994
3040
|
});
|
|
2995
|
-
function
|
|
2996
|
-
|
|
3041
|
+
function Jt() {
|
|
3042
|
+
_e && clearTimeout(_e), _e = setTimeout(() => {
|
|
2997
3043
|
const n = window.innerWidth < 768;
|
|
2998
|
-
|
|
3044
|
+
j.value = n, n && (A.value = !0, p.value && Gt()), Vt(), b.value && ct(), p.value && (pe.value = Qe(pe.value));
|
|
2999
3045
|
}, 100);
|
|
3000
3046
|
}
|
|
3001
|
-
return
|
|
3002
|
-
window.addEventListener("resize",
|
|
3003
|
-
}),
|
|
3004
|
-
window.removeEventListener("resize",
|
|
3005
|
-
}),
|
|
3006
|
-
document.addEventListener("mousemove",
|
|
3007
|
-
}),
|
|
3008
|
-
document.removeEventListener("mousemove",
|
|
3009
|
-
}), (n,
|
|
3010
|
-
|
|
3047
|
+
return Pe(() => {
|
|
3048
|
+
window.addEventListener("resize", Jt);
|
|
3049
|
+
}), Be(() => {
|
|
3050
|
+
window.removeEventListener("resize", Jt), _e && clearTimeout(_e), Re == null || Re(), Ne == null || Ne(), Ne = null;
|
|
3051
|
+
}), Pe(() => {
|
|
3052
|
+
document.addEventListener("mousemove", rt), document.addEventListener("touchmove", rt, { passive: !0 }), document.addEventListener("mouseup", ut), document.addEventListener("touchend", ut), document.addEventListener("mousemove", dt), document.addEventListener("touchmove", dt, { passive: !0 }), document.addEventListener("mouseup", vt), document.addEventListener("touchend", vt), document.addEventListener("click", Bt, !0), document.addEventListener("mousemove", ft), document.addEventListener("touchmove", ft, { passive: !0 }), document.addEventListener("mouseup", mt), document.addEventListener("touchend", mt);
|
|
3053
|
+
}), Be(() => {
|
|
3054
|
+
document.removeEventListener("mousemove", rt), document.removeEventListener("touchmove", rt), document.removeEventListener("mouseup", ut), document.removeEventListener("touchend", ut), document.removeEventListener("mousemove", dt), document.removeEventListener("touchmove", dt), document.removeEventListener("mouseup", vt), document.removeEventListener("touchend", vt), document.removeEventListener("click", Bt, !0), document.removeEventListener("mousemove", ft), document.removeEventListener("touchmove", ft), document.removeEventListener("mouseup", mt), document.removeEventListener("touchend", mt), G && clearTimeout(G), W && cancelAnimationFrame(W);
|
|
3055
|
+
}), (n, d) => (i(), h("div", null, [
|
|
3056
|
+
qe(o("div", {
|
|
3011
3057
|
ref_key: "panelRef",
|
|
3012
3058
|
ref: D,
|
|
3013
|
-
class:
|
|
3059
|
+
class: me([
|
|
3014
3060
|
"ai-panel",
|
|
3015
|
-
a.value ? "page-mode" :
|
|
3016
|
-
a.value ? "" :
|
|
3061
|
+
a.value ? "page-mode" : A.value ? "maxWrap" : "minWrap",
|
|
3062
|
+
a.value ? "" : Oe.value,
|
|
3017
3063
|
{
|
|
3018
|
-
"panel-custom": b.value && !
|
|
3064
|
+
"panel-custom": b.value && !A.value && !j.value && !p.value && !a.value && ue.value === "idle",
|
|
3019
3065
|
"page-closing": C.value,
|
|
3020
|
-
dragging:
|
|
3021
|
-
"dock-preview":
|
|
3022
|
-
docked:
|
|
3023
|
-
"dock-resizing":
|
|
3024
|
-
"dock-switching":
|
|
3025
|
-
"dock-switch-instant":
|
|
3026
|
-
"dock-switch-fade-in":
|
|
3027
|
-
"dock-switch-fade-out":
|
|
3028
|
-
"no-drag": !
|
|
3066
|
+
dragging: x.value,
|
|
3067
|
+
"dock-preview": Y.value,
|
|
3068
|
+
docked: p.value,
|
|
3069
|
+
"dock-resizing": oe.value,
|
|
3070
|
+
"dock-switching": ue.value !== "idle",
|
|
3071
|
+
"dock-switch-instant": Q.value,
|
|
3072
|
+
"dock-switch-fade-in": ve.value === "in",
|
|
3073
|
+
"dock-switch-fade-out": ve.value === "out",
|
|
3074
|
+
"no-drag": !Nt.value || a.value
|
|
3029
3075
|
},
|
|
3030
3076
|
I.value !== "idle" ? I.value : "",
|
|
3031
|
-
{ morphing: I.value !== "idle", "morph-instant":
|
|
3077
|
+
{ morphing: I.value !== "idle", "morph-instant": R.value }
|
|
3032
3078
|
]),
|
|
3033
|
-
style:
|
|
3079
|
+
style: kt([Dn.value, xn.value, En.value])
|
|
3034
3080
|
}, [
|
|
3035
|
-
|
|
3081
|
+
p.value || a.value ? (i(), h("div", {
|
|
3036
3082
|
key: 0,
|
|
3037
3083
|
class: "ai-dock-resizer",
|
|
3038
|
-
onMousedown:
|
|
3039
|
-
onTouchstart:
|
|
3040
|
-
}, null, 32)) :
|
|
3084
|
+
onMousedown: Le(qt, ["stop"]),
|
|
3085
|
+
onTouchstart: Le(qt, ["stop"])
|
|
3086
|
+
}, null, 32)) : z("", !0),
|
|
3041
3087
|
o("div", {
|
|
3042
3088
|
class: "header",
|
|
3043
|
-
onMousedown:
|
|
3044
|
-
onTouchstart:
|
|
3089
|
+
onMousedown: Wt,
|
|
3090
|
+
onTouchstart: Wt
|
|
3045
3091
|
}, [
|
|
3046
|
-
|
|
3092
|
+
V.value === "info" ? (i(), h("span", {
|
|
3047
3093
|
key: 0,
|
|
3048
|
-
class:
|
|
3049
|
-
onClick:
|
|
3050
|
-
}, [...
|
|
3094
|
+
class: me(["back", L.value]),
|
|
3095
|
+
onClick: d[0] || (d[0] = ($) => V.value = "answer")
|
|
3096
|
+
}, [...d[6] || (d[6] = [
|
|
3051
3097
|
o("span", { style: { "font-size": "14px" } }, "←", -1)
|
|
3052
|
-
])], 2)) : (i(),
|
|
3098
|
+
])], 2)) : (i(), h("p", fi, [
|
|
3053
3099
|
o("img", {
|
|
3054
|
-
src:
|
|
3100
|
+
src: ie(_n),
|
|
3055
3101
|
draggable: "false"
|
|
3056
3102
|
}, null, 8, mi)
|
|
3057
3103
|
])),
|
|
3058
3104
|
o("div", gi, [
|
|
3059
3105
|
o("span", {
|
|
3060
|
-
title:
|
|
3061
|
-
},
|
|
3106
|
+
title: V.value === "info" ? "个人信息" : re.value || g.value
|
|
3107
|
+
}, te(V.value === "info" ? "个人信息" : re.value || g.value), 9, pi)
|
|
3062
3108
|
]),
|
|
3063
3109
|
o("p", null, [
|
|
3064
|
-
|
|
3110
|
+
qe(ke(Te, {
|
|
3065
3111
|
class: "op-icon",
|
|
3066
3112
|
name: "add",
|
|
3067
|
-
onClick:
|
|
3113
|
+
onClick: Gn
|
|
3068
3114
|
}, null, 512), [
|
|
3069
|
-
[
|
|
3115
|
+
[nt, $n.value]
|
|
3070
3116
|
]),
|
|
3071
|
-
a.value ?
|
|
3117
|
+
a.value ? z("", !0) : (i(), we(Te, {
|
|
3072
3118
|
key: 0,
|
|
3073
|
-
class:
|
|
3119
|
+
class: me(["mute", { active: de.value }]),
|
|
3074
3120
|
name: "history",
|
|
3075
|
-
onClick:
|
|
3121
|
+
onClick: d[1] || (d[1] = ($) => de.value ? Je() : Yn())
|
|
3076
3122
|
}, null, 8, ["class"])),
|
|
3077
|
-
!a.value && !
|
|
3123
|
+
!a.value && !j.value && !p.value ? (i(), we(Te, {
|
|
3078
3124
|
key: 1,
|
|
3079
|
-
onClick:
|
|
3080
|
-
name:
|
|
3081
|
-
}, null, 8, ["name"])) :
|
|
3082
|
-
|
|
3125
|
+
onClick: On,
|
|
3126
|
+
name: A.value ? "fullscreenExit" : "fullscreen"
|
|
3127
|
+
}, null, 8, ["name"])) : z("", !0),
|
|
3128
|
+
p.value && !a.value ? (i(), we(Te, {
|
|
3083
3129
|
key: 2,
|
|
3084
3130
|
name: "dockOut",
|
|
3085
|
-
onClick:
|
|
3086
|
-
})) :
|
|
3087
|
-
|
|
3131
|
+
onClick: Gt
|
|
3132
|
+
})) : z("", !0),
|
|
3133
|
+
Ie.value && !p.value && !a.value ? (i(), we(Te, {
|
|
3088
3134
|
key: 3,
|
|
3089
3135
|
name: "dockIn",
|
|
3090
3136
|
onClick: zt,
|
|
3091
3137
|
class: "__minimize"
|
|
3092
|
-
})) :
|
|
3093
|
-
|
|
3138
|
+
})) : z("", !0),
|
|
3139
|
+
ke(Te, {
|
|
3094
3140
|
onClick: Xn,
|
|
3095
3141
|
name: "close"
|
|
3096
3142
|
})
|
|
3097
3143
|
])
|
|
3098
3144
|
], 32),
|
|
3099
|
-
a.value ? (i(),
|
|
3145
|
+
a.value ? (i(), we(hi, {
|
|
3100
3146
|
key: 1,
|
|
3101
|
-
context:
|
|
3102
|
-
}, null, 8, ["context"])) :
|
|
3103
|
-
|
|
3147
|
+
context: f.value
|
|
3148
|
+
}, null, 8, ["context"])) : z("", !0),
|
|
3149
|
+
qe(ke(Vo, {
|
|
3104
3150
|
ref_key: "answerRef",
|
|
3105
|
-
ref:
|
|
3106
|
-
defaultSayhello:
|
|
3107
|
-
defaultRecommend:
|
|
3108
|
-
onTitleGenerated:
|
|
3109
|
-
onSessionsChange:
|
|
3151
|
+
ref: Z,
|
|
3152
|
+
defaultSayhello: ie(e).defaultSayhello,
|
|
3153
|
+
defaultRecommend: l.value,
|
|
3154
|
+
onTitleGenerated: d[2] || (d[2] = ($) => re.value = $),
|
|
3155
|
+
onSessionsChange: d[3] || (d[3] = ($) => U.value = $)
|
|
3110
3156
|
}, null, 8, ["defaultSayhello", "defaultRecommend"]), [
|
|
3111
|
-
[
|
|
3157
|
+
[nt, V.value === "answer"]
|
|
3112
3158
|
]),
|
|
3113
|
-
|
|
3114
|
-
|
|
3159
|
+
V.value === "info" ? (i(), we(ci, { key: 2 })) : z("", !0),
|
|
3160
|
+
de.value ? (i(), h("div", {
|
|
3115
3161
|
key: 3,
|
|
3116
|
-
class:
|
|
3162
|
+
class: me(["ai-history-drawer", { closing: k.value }])
|
|
3117
3163
|
}, [
|
|
3118
3164
|
o("div", {
|
|
3119
3165
|
class: "ai-history-backdrop",
|
|
3120
|
-
onClick:
|
|
3166
|
+
onClick: Je
|
|
3121
3167
|
}),
|
|
3122
3168
|
o("div", yi, [
|
|
3123
3169
|
o("div", wi, [
|
|
3124
|
-
|
|
3125
|
-
|
|
3170
|
+
d[7] || (d[7] = o("span", null, "对话记录", -1)),
|
|
3171
|
+
ke(Te, {
|
|
3126
3172
|
name: "close",
|
|
3127
3173
|
class: "ai-history-drawer-close",
|
|
3128
|
-
onClick:
|
|
3174
|
+
onClick: Je
|
|
3129
3175
|
})
|
|
3130
3176
|
]),
|
|
3131
|
-
|
|
3132
|
-
localSessions:
|
|
3133
|
-
onHistoryDetail:
|
|
3134
|
-
onNewConversation:
|
|
3177
|
+
ke(jo, {
|
|
3178
|
+
localSessions: U.value,
|
|
3179
|
+
onHistoryDetail: qn,
|
|
3180
|
+
onNewConversation: Kn
|
|
3135
3181
|
}, null, 8, ["localSessions"])
|
|
3136
3182
|
])
|
|
3137
|
-
], 2)) :
|
|
3138
|
-
|
|
3183
|
+
], 2)) : z("", !0),
|
|
3184
|
+
qe(o("div", ki, [
|
|
3139
3185
|
o("div", _i, [
|
|
3140
3186
|
o("div", Ci, [
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
"onUpdate:modelValue":
|
|
3187
|
+
d[8] || (d[8] = o("p", { class: "title" }, "修改标题", -1)),
|
|
3188
|
+
qe(o("textarea", {
|
|
3189
|
+
"onUpdate:modelValue": d[4] || (d[4] = ($) => s.value = $),
|
|
3144
3190
|
placeholder: "请输入新标题"
|
|
3145
3191
|
}, null, 512), [
|
|
3146
|
-
[
|
|
3192
|
+
[gn, s.value]
|
|
3147
3193
|
]),
|
|
3148
3194
|
o("p", bi, [
|
|
3149
3195
|
o("span", {
|
|
3150
|
-
onClick:
|
|
3196
|
+
onClick: d[5] || (d[5] = ($) => le.value = !1)
|
|
3151
3197
|
}, "取消"),
|
|
3152
|
-
o("span", { onClick:
|
|
3198
|
+
o("span", { onClick: Qn }, "确定")
|
|
3153
3199
|
])
|
|
3154
3200
|
])
|
|
3155
3201
|
])
|
|
3156
3202
|
], 512), [
|
|
3157
|
-
[
|
|
3203
|
+
[nt, le.value]
|
|
3158
3204
|
])
|
|
3159
3205
|
], 6), [
|
|
3160
|
-
[
|
|
3206
|
+
[nt, T.value || I.value !== "idle"]
|
|
3161
3207
|
]),
|
|
3162
|
-
|
|
3208
|
+
Y.value && Ie.value ? (i(), h("div", {
|
|
3163
3209
|
key: 0,
|
|
3164
3210
|
class: "ai-dock-preview",
|
|
3165
|
-
style:
|
|
3166
|
-
}, [...
|
|
3211
|
+
style: kt({ width: pe.value + "px" })
|
|
3212
|
+
}, [...d[9] || (d[9] = [
|
|
3167
3213
|
o("span", { class: "ai-dock-preview__text" }, "松开以停靠到右侧", -1)
|
|
3168
|
-
])], 4)) :
|
|
3169
|
-
|
|
3170
|
-
class:
|
|
3171
|
-
style:
|
|
3172
|
-
onMousedown:
|
|
3173
|
-
onTouchstart:
|
|
3174
|
-
onClick:
|
|
3214
|
+
])], 4)) : z("", !0),
|
|
3215
|
+
qe(o("div", {
|
|
3216
|
+
class: me(["character", { dragging: O.value, recycling: q.value, "hover-preview": N.value }]),
|
|
3217
|
+
style: kt(Sn.value),
|
|
3218
|
+
onMousedown: Ot,
|
|
3219
|
+
onTouchstart: Ot,
|
|
3220
|
+
onClick: In
|
|
3175
3221
|
}, [
|
|
3176
|
-
o("img", { src:
|
|
3222
|
+
o("img", { src: Tn.value }, null, 8, Mi)
|
|
3177
3223
|
], 38), [
|
|
3178
|
-
[
|
|
3224
|
+
[nt, !T.value && !a.value]
|
|
3179
3225
|
])
|
|
3180
3226
|
]));
|
|
3181
3227
|
}
|
|
@@ -3204,7 +3250,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3204
3250
|
fill: "currentColor",
|
|
3205
3251
|
width: "16",
|
|
3206
3252
|
height: "16"
|
|
3207
|
-
}, Bi = /* @__PURE__ */
|
|
3253
|
+
}, Bi = /* @__PURE__ */ $e({
|
|
3208
3254
|
__name: "VoiceInput",
|
|
3209
3255
|
props: {
|
|
3210
3256
|
lang: {},
|
|
@@ -3220,58 +3266,58 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3220
3266
|
},
|
|
3221
3267
|
emits: ["result", "final", "error", "statusChange", "complete"],
|
|
3222
3268
|
setup(t, { expose: w, emit: e }) {
|
|
3223
|
-
const
|
|
3269
|
+
const v = t, a = e, f = {
|
|
3224
3270
|
idle: "开始录音",
|
|
3225
3271
|
connecting: "启动中…",
|
|
3226
3272
|
recording: "停止录音",
|
|
3227
3273
|
stopping: "识别中…",
|
|
3228
3274
|
error: "重试"
|
|
3229
|
-
},
|
|
3275
|
+
}, g = _(""), l = _(""), r = _("idle"), M = ot.isSupported();
|
|
3230
3276
|
let C = null;
|
|
3231
|
-
const E = S(() =>
|
|
3232
|
-
lang:
|
|
3233
|
-
continuous:
|
|
3234
|
-
interimResults:
|
|
3277
|
+
const E = S(() => _s(v.theme)), T = () => ({
|
|
3278
|
+
lang: v.lang,
|
|
3279
|
+
continuous: v.continuous,
|
|
3280
|
+
interimResults: v.interimResults
|
|
3235
3281
|
}), I = () => {
|
|
3236
|
-
M && (C = new
|
|
3282
|
+
M && (C = new ot(T(), {
|
|
3237
3283
|
onStatusChange: (s) => {
|
|
3238
|
-
|
|
3284
|
+
r.value = s, a("statusChange", s), s === "idle" && a("complete", g.value);
|
|
3239
3285
|
},
|
|
3240
3286
|
onInterim: (s) => {
|
|
3241
|
-
|
|
3287
|
+
l.value = s;
|
|
3242
3288
|
},
|
|
3243
|
-
onFinal: (s,
|
|
3244
|
-
|
|
3289
|
+
onFinal: (s, ae) => {
|
|
3290
|
+
g.value += s, l.value = "", a("final", s, ae);
|
|
3245
3291
|
},
|
|
3246
3292
|
onResult: (s) => a("result", s),
|
|
3247
3293
|
onError: (s) => a("error", s)
|
|
3248
3294
|
}));
|
|
3249
3295
|
};
|
|
3250
|
-
|
|
3296
|
+
Pe(I), Lt(() => {
|
|
3251
3297
|
C == null || C.destroy(), C = null;
|
|
3252
|
-
}),
|
|
3253
|
-
() => [
|
|
3298
|
+
}), ge(
|
|
3299
|
+
() => [v.lang, v.continuous, v.interimResults],
|
|
3254
3300
|
() => {
|
|
3255
3301
|
C == null || C.destroy(), I();
|
|
3256
3302
|
}
|
|
3257
3303
|
);
|
|
3258
|
-
const
|
|
3304
|
+
const R = async () => {
|
|
3259
3305
|
if (C)
|
|
3260
|
-
if (
|
|
3306
|
+
if (r.value === "idle" || r.value === "error")
|
|
3261
3307
|
try {
|
|
3262
3308
|
await C.start();
|
|
3263
3309
|
} catch {
|
|
3264
3310
|
}
|
|
3265
|
-
else
|
|
3311
|
+
else r.value === "recording" && C.stop();
|
|
3266
3312
|
}, y = () => {
|
|
3267
|
-
|
|
3268
|
-
},
|
|
3269
|
-
() => M ?
|
|
3270
|
-
),
|
|
3313
|
+
g.value = "", l.value = "";
|
|
3314
|
+
}, N = S(() => !g.value && !l.value), j = S(
|
|
3315
|
+
() => M ? v.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
|
|
3316
|
+
), A = S(() => M ? r.value === "connecting" ? v.connectingText || f.connecting : r.value === "recording" ? v.stopText || f.recording : r.value === "stopping" ? v.stoppingText || f.stopping : r.value === "error" ? f.error : v.startText || f.idle : "不支持"), V = S(() => {
|
|
3271
3317
|
const s = ["ai-voice-input-btn"];
|
|
3272
|
-
return
|
|
3273
|
-
}),
|
|
3274
|
-
() => !M ||
|
|
3318
|
+
return r.value === "recording" && s.push("is-recording"), r.value === "connecting" && s.push("is-connecting"), r.value === "stopping" && s.push("is-stopping"), s.join(" ");
|
|
3319
|
+
}), le = S(
|
|
3320
|
+
() => !M || r.value === "connecting" || r.value === "stopping"
|
|
3275
3321
|
);
|
|
3276
3322
|
return w({
|
|
3277
3323
|
start: async () => {
|
|
@@ -3279,42 +3325,42 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3279
3325
|
},
|
|
3280
3326
|
stop: () => C == null ? void 0 : C.stop(),
|
|
3281
3327
|
cancel: () => C == null ? void 0 : C.cancel(),
|
|
3282
|
-
getText: () =>
|
|
3328
|
+
getText: () => g.value + l.value,
|
|
3283
3329
|
clear: () => {
|
|
3284
|
-
|
|
3330
|
+
g.value = "", l.value = "";
|
|
3285
3331
|
},
|
|
3286
3332
|
getStatus: () => (C == null ? void 0 : C.getStatus()) ?? "idle"
|
|
3287
|
-
}), (s,
|
|
3288
|
-
class:
|
|
3333
|
+
}), (s, ae) => (i(), h("div", {
|
|
3334
|
+
class: me(["ai-voice-input", t.className]),
|
|
3289
3335
|
"data-theme": E.value
|
|
3290
3336
|
}, [
|
|
3291
3337
|
o("div", {
|
|
3292
|
-
class:
|
|
3338
|
+
class: me(["ai-voice-input-display", { "is-empty": N.value }])
|
|
3293
3339
|
}, [
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3340
|
+
g.value ? (i(), h("span", Ri, te(g.value), 1)) : z("", !0),
|
|
3341
|
+
l.value ? (i(), h("span", Pi, te(l.value), 1)) : z("", !0),
|
|
3342
|
+
r.value === "recording" && !l.value ? (i(), h("span", Li)) : z("", !0),
|
|
3343
|
+
N.value ? (i(), h("span", Hi, te(j.value), 1)) : z("", !0)
|
|
3298
3344
|
], 2),
|
|
3299
3345
|
o("button", {
|
|
3300
3346
|
type: "button",
|
|
3301
|
-
class:
|
|
3302
|
-
disabled:
|
|
3303
|
-
onClick:
|
|
3347
|
+
class: me(V.value),
|
|
3348
|
+
disabled: le.value,
|
|
3349
|
+
onClick: R
|
|
3304
3350
|
}, [
|
|
3305
|
-
|
|
3351
|
+
r.value === "recording" ? (i(), h("span", Vi)) : r.value === "connecting" || r.value === "stopping" ? (i(), h("span", Oi, [...ae[0] || (ae[0] = [
|
|
3306
3352
|
o("span", null, null, -1),
|
|
3307
3353
|
o("span", null, null, -1),
|
|
3308
3354
|
o("span", null, null, -1),
|
|
3309
3355
|
o("span", null, null, -1),
|
|
3310
3356
|
o("span", null, null, -1)
|
|
3311
|
-
])])) : (i(),
|
|
3357
|
+
])])) : (i(), h("svg", Wi, [...ae[1] || (ae[1] = [
|
|
3312
3358
|
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),
|
|
3313
3359
|
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)
|
|
3314
3360
|
])])),
|
|
3315
|
-
o("span", null,
|
|
3361
|
+
o("span", null, te(A.value), 1)
|
|
3316
3362
|
], 10, Ni),
|
|
3317
|
-
|
|
3363
|
+
N.value ? z("", !0) : (i(), h("button", {
|
|
3318
3364
|
key: 0,
|
|
3319
3365
|
type: "button",
|
|
3320
3366
|
class: "ai-voice-input-btn ai-voice-input-clear-btn",
|
|
@@ -3323,46 +3369,46 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3323
3369
|
}, " 清空 "))
|
|
3324
3370
|
], 10, Ai));
|
|
3325
3371
|
}
|
|
3326
|
-
}), Fi = /* @__PURE__ */
|
|
3327
|
-
let
|
|
3372
|
+
}), Fi = /* @__PURE__ */ bn(Bi, [["__scopeId", "data-v-53d3cc6e"]]);
|
|
3373
|
+
let it = null;
|
|
3328
3374
|
const Ki = (t) => {
|
|
3329
|
-
|
|
3375
|
+
kn(t), wn(t);
|
|
3330
3376
|
}, Yi = (t) => {
|
|
3331
3377
|
const w = t || document.body, e = document.createElement("div");
|
|
3332
3378
|
e.id = "ai-assist-root";
|
|
3333
|
-
const
|
|
3334
|
-
|
|
3379
|
+
const v = lt();
|
|
3380
|
+
Pt(v.theme), Cs(), w.appendChild(e), it = ss(Mn), it.mount(e);
|
|
3335
3381
|
}, Qi = () => {
|
|
3336
|
-
|
|
3382
|
+
it && (it.unmount(), it = null);
|
|
3337
3383
|
const t = document.getElementById("ai-assist-root");
|
|
3338
|
-
t && t.remove(),
|
|
3384
|
+
t && t.remove(), bs();
|
|
3339
3385
|
}, ji = {
|
|
3340
3386
|
install(t, w) {
|
|
3341
|
-
|
|
3387
|
+
kn(w), wn(w), t.component("AiAssist", Mn), t.component("VoiceInput", Fi);
|
|
3342
3388
|
}
|
|
3343
3389
|
};
|
|
3344
3390
|
export {
|
|
3345
|
-
|
|
3391
|
+
Mn as AiAssist,
|
|
3346
3392
|
Fi as VoiceInput,
|
|
3347
|
-
|
|
3393
|
+
os as clearPageThreadId,
|
|
3348
3394
|
Ui as closeAiAssist,
|
|
3349
3395
|
el as collapsePageAssist,
|
|
3350
3396
|
ji as default,
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3397
|
+
Ct as getAiAssistMode,
|
|
3398
|
+
an as getPageContextSnapshot,
|
|
3399
|
+
We as getPageModule,
|
|
3400
|
+
Rt as getPageThreadId,
|
|
3355
3401
|
Ki as initAiAssist,
|
|
3356
|
-
|
|
3357
|
-
|
|
3402
|
+
yn as isAiAssistPageMode,
|
|
3403
|
+
ln as isAiAssistVisible,
|
|
3358
3404
|
Yi as mountAiAssist,
|
|
3359
3405
|
tl as openAiAssist,
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3406
|
+
_t as refreshAiPanelContext,
|
|
3407
|
+
ks as setAiAssistMode,
|
|
3408
|
+
on as setAiAssistVisible,
|
|
3363
3409
|
nl as setPageModule,
|
|
3364
3410
|
xt as setPageThreadId,
|
|
3365
|
-
|
|
3411
|
+
ps as subscribeAiAssistState,
|
|
3366
3412
|
sl as toggleAiAssist,
|
|
3367
3413
|
Qi as unmountAiAssist
|
|
3368
3414
|
};
|