@somecat/ai-assist-sdk 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/types/index.d.ts +6 -0
- package/dist/vue/index.mjs +1667 -1606
- 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 xe, computed as $, openBlock as i, createElementBlock as h, createElementVNode as o, ref as _, watch as pe, nextTick as De, onUnmounted as Fe, normalizeClass as ge, toDisplayString as U, createVNode as Ce, Transition as Un, withCtx as es, unref as ie, createCommentVNode as z, Fragment as be, renderList as He, createTextVNode as fn, onMounted as Ne, onBeforeUnmount as Lt, reactive as Oe, createBlock as _e, createStaticVNode as ts, withModifiers as Ve, Teleport as mn, withDirectives as qe, withKeys as $t, 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 We, i as yn, s as xt, u as as, V as ot, c as os, b as en, d as is, o as ls, e as Be, f as Rt, h as rs, j as tn, k as nn, l as Ct, m as Tt, 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 Ss, f as Ms, i as $s, s as xs, a as Ts, S as Ds, b as Es, c as Ie, 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__ */ xe({
|
|
74
74
|
__name: "SdkIcon",
|
|
75
75
|
props: {
|
|
76
76
|
name: {}
|
|
77
77
|
},
|
|
78
78
|
setup(t) {
|
|
79
|
-
const w = t, e =
|
|
80
|
-
const { left: a = 0, top:
|
|
81
|
-
return a ||
|
|
79
|
+
const w = t, e = $(() => un[w.name] || un.close), v = $(() => {
|
|
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
|
+
}, Ee = /* @__PURE__ */ bn(Xs, [["__scopeId", "data-v-632dda9c"]]), zs = { class: "thinking-block__title" }, qs = ["innerHTML"], Gs = /* @__PURE__ */ xe({
|
|
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
|
|
112
|
+
let v = 0;
|
|
113
113
|
function a(x = 600) {
|
|
114
|
-
clearTimeout(
|
|
115
|
-
|
|
114
|
+
clearTimeout(v), v = window.setTimeout(() => {
|
|
115
|
+
v = 0, e.value = !1;
|
|
116
116
|
}, x);
|
|
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
|
+
pe(
|
|
125
125
|
() => w.isStreaming,
|
|
126
126
|
(x) => {
|
|
127
|
-
x ? (
|
|
127
|
+
x ? (f(), e.value = !0) : w.messageDone || a();
|
|
128
128
|
},
|
|
129
129
|
{ immediate: !0 }
|
|
130
|
-
),
|
|
130
|
+
), pe(
|
|
131
131
|
() => w.messageDone,
|
|
132
132
|
(x) => {
|
|
133
|
-
x && (
|
|
133
|
+
x && (f(), e.value = !0);
|
|
134
134
|
},
|
|
135
135
|
{ immediate: !0 }
|
|
136
136
|
);
|
|
137
|
-
const
|
|
138
|
-
let
|
|
139
|
-
function
|
|
140
|
-
const x =
|
|
137
|
+
const l = _(null);
|
|
138
|
+
let r = !1;
|
|
139
|
+
function S() {
|
|
140
|
+
const x = l.value;
|
|
141
141
|
if (!x) return;
|
|
142
|
-
|
|
142
|
+
r = x.scrollHeight - x.scrollTop - x.clientHeight > 12;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
const x =
|
|
146
|
-
!x || !e.value ||
|
|
144
|
+
function b() {
|
|
145
|
+
const x = l.value;
|
|
146
|
+
!x || !e.value || r || (x.scrollTop = x.scrollHeight);
|
|
147
147
|
}
|
|
148
148
|
function E() {
|
|
149
|
-
w.isStreaming &&
|
|
149
|
+
w.isStreaming && b();
|
|
150
150
|
}
|
|
151
|
-
return
|
|
151
|
+
return pe(
|
|
152
152
|
() => w.content,
|
|
153
153
|
() => {
|
|
154
|
-
w.isStreaming &&
|
|
154
|
+
w.isStreaming && De(b);
|
|
155
155
|
}
|
|
156
|
-
),
|
|
157
|
-
|
|
158
|
-
}), (x, I) => (i(),
|
|
159
|
-
class:
|
|
156
|
+
), Fe(() => {
|
|
157
|
+
f();
|
|
158
|
+
}), (x, I) => (i(), h("div", {
|
|
159
|
+
class: ge(["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, U(t.isStreaming ? "深度思考中" : "深度思考"), 1),
|
|
170
|
+
(i(), h("svg", {
|
|
171
|
+
class: ge(["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
|
+
Ce(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
|
-
onScroll:
|
|
194
|
+
onScroll: S
|
|
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__ */ xe({
|
|
245
245
|
__name: "StepBlock",
|
|
246
246
|
props: {
|
|
247
247
|
steps: {}
|
|
248
248
|
},
|
|
249
249
|
setup(t) {
|
|
250
|
-
const w = t, e =
|
|
251
|
-
() => w.steps.reduce((
|
|
250
|
+
const w = t, e = $(() => w.steps.some((f) => f.state !== "done")), v = $(
|
|
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: ge(["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, U(t.steps.length) + " 步", 1)),
|
|
263
|
+
!e.value && v.value > 0 ? (i(), h("span", Qs, U(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(be, null, He(t.steps, (l, r) => (i(), h("li", {
|
|
267
|
+
key: r,
|
|
268
|
+
class: ge(["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, U(
|
|
286
|
-
|
|
285
|
+
o("span", sa, U(l.title || "处理中"), 1),
|
|
286
|
+
l.state === "done" && l.duration != null && l.duration > 0 ? (i(), h("span", aa, U(a(l.duration)), 1)) : z("", !0)
|
|
287
287
|
]),
|
|
288
|
-
|
|
288
|
+
l.content ? (i(), h("div", oa, U(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__ */ xe({
|
|
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: ge(["agent-thought", { "agent-thought--done": t.isDone }])
|
|
319
319
|
}, [
|
|
320
|
-
t.isDone ? (i(),
|
|
321
|
-
|
|
322
|
-
])) : (i(),
|
|
320
|
+
t.isDone ? (i(), h("span", la, [
|
|
321
|
+
Ce(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",
|
|
@@ -342,8 +342,8 @@ const ln = {
|
|
|
342
342
|
], -1)
|
|
343
343
|
])])),
|
|
344
344
|
o("span", ua, U(t.isDone ? "工具调用" : "工具调用中"), 1),
|
|
345
|
-
t.isDone && (t.count ?? 0) > 1 ? (i(),
|
|
346
|
-
t.isDone && (t.duration ?? 0) > 0 ? (i(),
|
|
345
|
+
t.isDone && (t.count ?? 0) > 1 ? (i(), h("span", ca, "已调用 " + U(t.count) + " 次", 1)) : z("", !0),
|
|
346
|
+
t.isDone && (t.duration ?? 0) > 0 ? (i(), h("span", da, U(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__ */ xe({
|
|
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
|
-
},
|
|
372
|
-
const
|
|
371
|
+
}, f = $(() => e.action.label || a[e.action.type] || "执行操作"), g = $(() => {
|
|
372
|
+
const b = e.action.payload || {};
|
|
373
373
|
if (e.action.type === "fillFilters") {
|
|
374
|
-
const E = [
|
|
374
|
+
const E = [b.platformName, b.companyName, b.year && b.period ? `${b.year}年${b.period}月` : ""].filter(Boolean);
|
|
375
375
|
return E.length ? `将切换为:${E.join(" · ")}` : "";
|
|
376
376
|
}
|
|
377
377
|
return e.action.type === "export" ? "按当前查询条件导出" : "";
|
|
378
|
-
}),
|
|
379
|
-
|
|
378
|
+
}), l = $(() => e.state.status === "applied" ? "已应用" : e.state.status === "pending" ? "执行中" : e.state.status === "failed" ? "重试" : "执行"), r = $(() => e.disabled || e.state.status === "pending" || e.state.status === "applied"), S = () => {
|
|
379
|
+
r.value || v("run", e.action);
|
|
380
380
|
};
|
|
381
|
-
return (
|
|
382
|
-
class:
|
|
381
|
+
return (b, E) => (i(), h("div", {
|
|
382
|
+
class: ge(["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, U(
|
|
387
|
-
|
|
386
|
+
o("p", fa, U(f.value), 1),
|
|
387
|
+
g.value ? (i(), h("p", ma, U(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:
|
|
394
|
-
onClick:
|
|
395
|
-
}, U(
|
|
392
|
+
disabled: r.value,
|
|
393
|
+
title: r.value && t.disabledReason || "",
|
|
394
|
+
onClick: S
|
|
395
|
+
}, U(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, U(t.state.message), 1)) : z("", !0),
|
|
398
|
+
t.state.status === "failed" && t.state.message ? (i(), h("p", ya, U(t.state.message), 1)) : z("", !0)
|
|
399
399
|
], 2));
|
|
400
400
|
}
|
|
401
|
-
}), ka = { class: "ai-file-card__icon" }, _a = { class: "ai-file-card__text" }, Ca = ["title"], ba = { class: "ai-file-card__meta" },
|
|
401
|
+
}), ka = { class: "ai-file-card__icon" }, _a = { class: "ai-file-card__text" }, Ca = ["title"], ba = { class: "ai-file-card__meta" }, Sa = {
|
|
402
402
|
key: 0,
|
|
403
403
|
class: "ai-file-card__error"
|
|
404
|
-
},
|
|
404
|
+
}, Ma = ["disabled"], $a = /* @__PURE__ */ xe({
|
|
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,33 +424,33 @@ const ln = {
|
|
|
424
424
|
jpg: "IMG",
|
|
425
425
|
jpeg: "IMG",
|
|
426
426
|
zip: "ZIP"
|
|
427
|
-
},
|
|
428
|
-
const
|
|
429
|
-
return a[
|
|
430
|
-
}),
|
|
431
|
-
const
|
|
432
|
-
return
|
|
433
|
-
}),
|
|
434
|
-
return (
|
|
435
|
-
class:
|
|
427
|
+
}, f = $(() => {
|
|
428
|
+
const S = (e.file.name.split(".").pop() || "").toLowerCase();
|
|
429
|
+
return a[S] || "FILE";
|
|
430
|
+
}), g = $(() => {
|
|
431
|
+
const S = Number(e.file.size || 0);
|
|
432
|
+
return S ? S < 1024 ? `${S} B` : S < 1024 * 1024 ? `${(S / 1024).toFixed(1)} KB` : `${(S / 1024 / 1024).toFixed(1)} MB` : "—";
|
|
433
|
+
}), l = $(() => e.state.status === "pending" ? "下载中" : e.state.status === "applied" ? "已下载" : e.state.status === "failed" ? "重试" : "下载"), r = $(() => e.state.status === "pending" || e.state.status === "applied");
|
|
434
|
+
return (S, b) => (i(), h("div", {
|
|
435
|
+
class: ge(["ai-file-card", `ai-file-card--${t.state.status}`])
|
|
436
436
|
}, [
|
|
437
|
-
o("div", ka, U(
|
|
437
|
+
o("div", ka, U(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
|
}, U(t.file.name), 9, Ca),
|
|
443
443
|
o("p", ba, [
|
|
444
|
-
|
|
445
|
-
t.state.status === "failed" && t.state.message ? (i(),
|
|
444
|
+
fn(U(g.value) + " ", 1),
|
|
445
|
+
t.state.status === "failed" && t.state.message ? (i(), h("span", Sa, U(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:
|
|
453
|
-
}, U(
|
|
451
|
+
disabled: r.value,
|
|
452
|
+
onClick: b[0] || (b[0] = (E) => v("download", t.file))
|
|
453
|
+
}, U(l.value), 9, Ma)
|
|
454
454
|
], 2));
|
|
455
455
|
}
|
|
456
456
|
}), xa = {
|
|
@@ -459,21 +459,21 @@ const ln = {
|
|
|
459
459
|
}, Ta = {
|
|
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__ */ xe({
|
|
463
463
|
__name: "AiToolStatus",
|
|
464
464
|
props: {
|
|
465
465
|
state: {}
|
|
466
466
|
},
|
|
467
467
|
setup(t) {
|
|
468
|
-
const w = t, e =
|
|
469
|
-
const
|
|
470
|
-
return
|
|
468
|
+
const w = t, e = $(() => {
|
|
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: ge(["ai-tool-status", `ai-tool-status--${t.state.status}`])
|
|
474
474
|
}, [
|
|
475
475
|
o("span", xa, [
|
|
476
|
-
t.state.status === "running" ? (i(),
|
|
476
|
+
t.state.status === "running" ? (i(), h("span", Ta)) : t.state.status === "done" ? (i(), h("span", Da, "✓")) : t.state.status === "failed" ? (i(), h("span", Ea, "!")) : (i(), h("span", Aa, "·"))
|
|
477
477
|
]),
|
|
478
478
|
o("span", Ra, U(e.value), 1)
|
|
479
479
|
], 2));
|
|
@@ -481,134 +481,134 @@ const ln = {
|
|
|
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__ */ xe({
|
|
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 = $(() => {
|
|
493
|
+
var r;
|
|
494
|
+
return !!((r = We()) != null && r.onChartDownload);
|
|
495
495
|
});
|
|
496
|
-
async function
|
|
497
|
-
var
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
500
|
-
const
|
|
501
|
-
if (!
|
|
502
|
-
|
|
496
|
+
async function g() {
|
|
497
|
+
var b;
|
|
498
|
+
const r = e.value;
|
|
499
|
+
if (!r || a) return;
|
|
500
|
+
const S = (b = We()) == null ? void 0 : b.onChartRender;
|
|
501
|
+
if (!S) {
|
|
502
|
+
v.value = !0;
|
|
503
503
|
return;
|
|
504
504
|
}
|
|
505
|
-
|
|
505
|
+
v.value = !1;
|
|
506
506
|
try {
|
|
507
|
-
await
|
|
507
|
+
await S(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
|
-
(
|
|
512
|
+
function l() {
|
|
513
|
+
var r, S;
|
|
514
|
+
(S = (r = We()) == null ? void 0 : r.onChartDownload) == null || S.call(r, w.chart);
|
|
515
515
|
}
|
|
516
|
-
return
|
|
516
|
+
return pe(() => w.chart.chartId, () => De(g)), pe(() => w.chart.option, () => De(g), { deep: !0 }), Ne(() => De(g)), Lt(() => {
|
|
517
517
|
a = !0;
|
|
518
|
-
}), (
|
|
519
|
-
|
|
518
|
+
}), (r, S) => (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 = $(() => t().segments), a = $(() => Dt(v.value)), f = $(() => !!t().streamed), g = $(() => {
|
|
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
|
+
pe(r, (V) => {
|
|
543
|
+
var le;
|
|
544
|
+
return (le = e == null ? void 0 : e.onProgress) == null ? void 0 : le.call(e, V);
|
|
545
545
|
});
|
|
546
|
-
const
|
|
547
|
-
let
|
|
548
|
-
function x(
|
|
549
|
-
|
|
546
|
+
const S = _(0);
|
|
547
|
+
let b = 0, E = 0;
|
|
548
|
+
function x(V) {
|
|
549
|
+
r.value !== V && (r.value = V);
|
|
550
550
|
}
|
|
551
551
|
function I() {
|
|
552
|
-
if (
|
|
553
|
-
const
|
|
552
|
+
if (b) return;
|
|
553
|
+
const V = (le) => {
|
|
554
554
|
if (E === 0) {
|
|
555
|
-
E =
|
|
555
|
+
E = le, b = requestAnimationFrame(V);
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
const s = Math.min(
|
|
559
|
-
E =
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
|
|
558
|
+
const s = Math.min(le - E, 100);
|
|
559
|
+
E = le;
|
|
560
|
+
const se = a.value, re = xs(v.value, r.value), de = Ts(r.value, se, S.value, s, re);
|
|
561
|
+
if (S.value = de.frac, de.reveal !== r.value && (r.value = de.reveal, w == null || w()), r.value >= se) {
|
|
562
|
+
b = 0, E = 0;
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
|
|
565
|
+
b = requestAnimationFrame(V);
|
|
566
566
|
};
|
|
567
|
-
E = 0,
|
|
567
|
+
E = 0, b = requestAnimationFrame(V);
|
|
568
568
|
}
|
|
569
569
|
function P() {
|
|
570
|
-
|
|
570
|
+
b && (cancelAnimationFrame(b), b = 0);
|
|
571
571
|
}
|
|
572
|
-
|
|
573
|
-
[
|
|
572
|
+
pe(
|
|
573
|
+
[f, a],
|
|
574
574
|
() => {
|
|
575
|
-
if (!
|
|
575
|
+
if (!f.value || g.value) {
|
|
576
576
|
x(a.value);
|
|
577
577
|
return;
|
|
578
578
|
}
|
|
579
|
-
|
|
579
|
+
r.value < a.value && I();
|
|
580
580
|
},
|
|
581
581
|
{ immediate: !0 }
|
|
582
|
-
),
|
|
583
|
-
|
|
584
|
-
}),
|
|
582
|
+
), pe(g, (V) => {
|
|
583
|
+
V && f.value && x(a.value);
|
|
584
|
+
}), pe(
|
|
585
585
|
() => t().status,
|
|
586
|
-
(
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
),
|
|
590
|
-
const y =
|
|
591
|
-
() =>
|
|
592
|
-
), J =
|
|
593
|
-
function R(
|
|
594
|
-
return $s(
|
|
586
|
+
(V, le) => {
|
|
587
|
+
V === "rethinking" && le !== "rethinking" && (S.value = 0, x(0), a.value > 0 && I());
|
|
588
|
+
}
|
|
589
|
+
), Fe(P);
|
|
590
|
+
const y = $(() => Ss(v.value, r.value)), N = $(
|
|
591
|
+
() => f.value ? Ms(v.value, r.value) : -1
|
|
592
|
+
), J = $(() => !f.value || r.value >= a.value);
|
|
593
|
+
function R(V) {
|
|
594
|
+
return $s(v.value, V, r.value);
|
|
595
595
|
}
|
|
596
|
-
return { reveal:
|
|
596
|
+
return { reveal: r, segmentContents: y, frontier: N, revealDone: J, isSegRevealed: R, stopLoop: P };
|
|
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 pe(
|
|
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
|
+
), Fe(() => {
|
|
610
610
|
a && clearTimeout(a);
|
|
611
|
-
}),
|
|
611
|
+
}), $(() => 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__ */ xe({
|
|
647
647
|
__name: "MessageItem",
|
|
648
648
|
props: {
|
|
649
649
|
msg: {},
|
|
@@ -655,61 +655,61 @@ 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 = $(() => yn()), f = $(() => {
|
|
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), ae = { ...e.msg.actionStates || {} };
|
|
668
|
+
e.msg.actionStates = { ...ae, [Y]: { status: "pending" } };
|
|
669
|
+
const Q = (B = We()) == null ? void 0 : B.onAction;
|
|
670
|
+
if (!Q) {
|
|
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 Q(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
|
|
688
|
-
var
|
|
689
|
-
return ((
|
|
687
|
+
const S = (u) => {
|
|
688
|
+
var p;
|
|
689
|
+
return ((p = e.msg.fileStates) == null ? void 0 : p[u.relPath]) || { status: "idle" };
|
|
690
690
|
};
|
|
691
|
-
async function
|
|
692
|
-
var
|
|
693
|
-
const
|
|
694
|
-
delete
|
|
695
|
-
const
|
|
696
|
-
if (!
|
|
691
|
+
async function b(u) {
|
|
692
|
+
var ae;
|
|
693
|
+
const p = { ...e.msg.fileStates || {} };
|
|
694
|
+
delete p[u.relPath], e.msg.fileStates = { ...p, [u.relPath]: { status: "pending" } };
|
|
695
|
+
const Y = (ae = We()) == null ? void 0 : ae.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 Q = await Y(u);
|
|
705
705
|
e.msg.fileStates = {
|
|
706
706
|
...e.msg.fileStates,
|
|
707
|
-
[
|
|
707
|
+
[u.relPath]: { status: Q != null && Q.ok ? "applied" : "failed", message: Q == null ? void 0 : Q.message }
|
|
708
708
|
};
|
|
709
|
-
} catch (
|
|
709
|
+
} catch (Q) {
|
|
710
710
|
e.msg.fileStates = {
|
|
711
711
|
...e.msg.fileStates,
|
|
712
|
-
[
|
|
712
|
+
[u.relPath]: { status: "failed", message: (Q == null ? void 0 : Q.message) || "下载失败,请重试" }
|
|
713
713
|
};
|
|
714
714
|
}
|
|
715
715
|
}
|
|
@@ -718,101 +718,101 @@ const Wa = {
|
|
|
718
718
|
() => e.scrollToBottom(),
|
|
719
719
|
{
|
|
720
720
|
initial: e.initialReveal,
|
|
721
|
-
onProgress: (
|
|
721
|
+
onProgress: (u) => v("reveal-progress", u)
|
|
722
722
|
}
|
|
723
|
-
), y =
|
|
723
|
+
), y = $(
|
|
724
724
|
() => e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP
|
|
725
|
-
),
|
|
726
|
-
|
|
727
|
-
|
|
725
|
+
), N = $(() => y.value && P.value), J = _(!1);
|
|
726
|
+
pe(N, (u) => {
|
|
727
|
+
u && (J.value = !1);
|
|
728
728
|
});
|
|
729
|
-
const R =
|
|
729
|
+
const R = $(() => Es(e.msg.segments, E.value)), V = $(() => R.value.length > 0), le = $(() => R.value.some((u) => u.kind === "thinking")), s = $(() => R.value.some((u) => u.kind === "tools")), se = $(() => R.value.some((u) => u.kind === "steps")), re = $(
|
|
730
730
|
() => R.value.some(
|
|
731
|
-
(
|
|
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 = $(
|
|
734
734
|
() => e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING || e.msg.status === e.STATUS.ANSWERING
|
|
735
|
-
), k =
|
|
736
|
-
() =>
|
|
737
|
-
), Z = Oa(k,
|
|
738
|
-
|
|
739
|
-
|
|
735
|
+
), k = $(
|
|
736
|
+
() => de.value && !!e.msg.streamed && P.value && !re.value && e.msg.lastChunkAt != null
|
|
737
|
+
), Z = Oa(k, $(() => e.msg.lastChunkAt));
|
|
738
|
+
pe(Z, (u) => {
|
|
739
|
+
u && e.scrollToBottom();
|
|
740
740
|
});
|
|
741
|
-
const
|
|
742
|
-
const
|
|
743
|
-
return
|
|
744
|
-
}),
|
|
741
|
+
const m = $(() => {
|
|
742
|
+
const u = [];
|
|
743
|
+
return le.value && u.push("深度思考"), s.value && u.push("工具调用"), se.value && u.push("执行步骤"), u.join(" · ") || "思考过程";
|
|
744
|
+
}), O = $(() => !N.value || J.value), q = $(
|
|
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 = $(
|
|
750
750
|
() => (e.msg.segments ?? []).some(
|
|
751
|
-
(
|
|
751
|
+
(u, p) => u.type === "answer" && (x.value[p] || "").length > 0
|
|
752
752
|
)
|
|
753
|
-
),
|
|
754
|
-
() => !
|
|
753
|
+
), L = $(
|
|
754
|
+
() => !N.value && !Z.value && e.msg.status !== e.STATUS.ERROR && e.msg.status !== e.STATUS.PAUSED && R.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 T(
|
|
762
|
-
const
|
|
763
|
-
|
|
760
|
+
const c = Oe(/* @__PURE__ */ new Map()), C = _("");
|
|
761
|
+
function T(u) {
|
|
762
|
+
const p = u.target;
|
|
763
|
+
p.tagName === "IMG" && (C.value = p.src);
|
|
764
764
|
}
|
|
765
|
-
function
|
|
766
|
-
|
|
765
|
+
function H() {
|
|
766
|
+
C.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 ae = u.content;
|
|
772
|
+
if (!ae && ((Y = u.segments) != null && Y.length) && (ae = u.segments.filter((Q) => Q.type === "answer").map((Q) => Q.content).join(`
|
|
773
|
+
`)), ae) {
|
|
774
|
+
const { copy: Q } = as();
|
|
775
|
+
Q(xt(ae)), 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, ae, Q, B, W, ue;
|
|
782
|
+
return i(), h("div", {
|
|
783
|
+
class: ge(["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(be, { key: 0 }, [
|
|
786
|
+
a.value && t.msg.toolState ? (i(), _e(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: (
|
|
796
|
+
ref: (j) => t.setMessageRef(j, t.index),
|
|
797
797
|
onClick: T
|
|
798
798
|
}, [
|
|
799
|
-
|
|
799
|
+
N.value && V.value ? (i(), h("div", {
|
|
800
800
|
key: 0,
|
|
801
|
-
class:
|
|
802
|
-
onClick:
|
|
801
|
+
class: ge(["thought-collapse-bar", { "thought-collapse-bar--expanded": J.value }]),
|
|
802
|
+
onClick: p[0] || (p[0] = Ve((j) => J.value = !J.value, ["stop"]))
|
|
803
803
|
}, [
|
|
804
|
-
|
|
804
|
+
le.value ? (i(), _e(ie(Hs), {
|
|
805
805
|
key: 0,
|
|
806
806
|
class: "thought-collapse-bar__icon"
|
|
807
|
-
})) : (i(),
|
|
807
|
+
})) : (i(), _e(ie(Cn), {
|
|
808
808
|
key: 1,
|
|
809
809
|
class: "thought-collapse-bar__icon"
|
|
810
810
|
})),
|
|
811
|
-
o("span", Ba, U(
|
|
812
|
-
|
|
813
|
-
o("span",
|
|
814
|
-
(i(),
|
|
815
|
-
class:
|
|
811
|
+
o("span", Ba, U(m.value), 1),
|
|
812
|
+
q.value > 0 ? (i(), h("span", Fa, U(D(q.value)), 1)) : z("", !0),
|
|
813
|
+
o("span", Ia, U(J.value ? "收起" : "查看"), 1),
|
|
814
|
+
(i(), h("svg", {
|
|
815
|
+
class: ge(["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(be, { key: 1 }, [
|
|
829
|
+
(i(!0), h(be, null, He(R.value, (j, ve) => (i(), h(be, { key: ve }, [
|
|
830
|
+
j.kind === "steps" ? (i(), _e(ia, {
|
|
831
831
|
key: 0,
|
|
832
|
-
steps:
|
|
833
|
-
}, null, 8, ["steps"])) :
|
|
832
|
+
steps: j.items
|
|
833
|
+
}, null, 8, ["steps"])) : j.kind === "thinking" ? (i(), _e(Gs, {
|
|
834
834
|
key: 1,
|
|
835
|
-
content:
|
|
836
|
-
"is-streaming":
|
|
837
|
-
"message-done":
|
|
838
|
-
}, null, 8, ["content", "is-streaming", "message-done"])) : (i(),
|
|
835
|
+
content: j.content,
|
|
836
|
+
"is-streaming": j.streaming,
|
|
837
|
+
"message-done": N.value
|
|
838
|
+
}, null, 8, ["content", "is-streaming", "message-done"])) : (i(), _e(cn, {
|
|
839
839
|
key: 2,
|
|
840
|
-
"is-done": !
|
|
841
|
-
count:
|
|
842
|
-
duration:
|
|
840
|
+
"is-done": !j.calling,
|
|
841
|
+
count: j.count,
|
|
842
|
+
duration: j.duration
|
|
843
843
|
}, null, 8, ["is-done", "count", "duration"]))
|
|
844
844
|
], 64))), 128)),
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
])) :
|
|
848
|
-
], 64)) :
|
|
849
|
-
(i(!0),
|
|
850
|
-
|
|
845
|
+
ie(Z) ? (i(), h("div", Xa, [
|
|
846
|
+
Ce(cn)
|
|
847
|
+
])) : z("", !0)
|
|
848
|
+
], 64)) : z("", !0),
|
|
849
|
+
(i(!0), h(be, null, He(t.msg.segments, (j, ve) => (i(), h(be, { key: ve }, [
|
|
850
|
+
j.type === "answer" ? (i(), h("div", za, [
|
|
851
851
|
o("div", {
|
|
852
|
-
innerHTML:
|
|
853
|
-
|
|
854
|
-
!
|
|
852
|
+
innerHTML: ie(pn)(
|
|
853
|
+
ie(Et)(ie(xt)(ie(At)(ie(x)[ve] ?? ""))),
|
|
854
|
+
!ie(P) && 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: (
|
|
863
|
+
ref: (j) => t.setMessageRef(j, t.index),
|
|
864
864
|
onClick: T
|
|
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(xt)(ie(At)(t.msg.content)))
|
|
869
|
+
}, null, 8, Ga)) : z("", !0),
|
|
870
|
+
f.value ? (i(), h("div", Ka, [
|
|
871
|
+
(i(!0), h(be, null, He(t.msg.charts, (j) => (i(), _e(Na, {
|
|
872
|
+
key: j.chartId,
|
|
873
|
+
chart: j
|
|
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 && ((ae = t.msg.actions) != null && ae.length || (Q = t.msg.suggestions) != null && Q.length) ? (i(), h(be, { key: 4 }, [
|
|
878
|
+
(B = t.msg.actions) != null && B.length ? (i(), h("div", Ya, [
|
|
879
|
+
(i(!0), h(be, null, He(t.msg.actions, (j, ve) => (i(), _e(wa, {
|
|
880
|
+
key: `${ve}-${j.type}`,
|
|
881
|
+
action: j,
|
|
882
|
+
state: l(j, ve),
|
|
883
|
+
onRun: (me) => r(j, 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(be, null, He(t.msg.suggestions, (j, ve) => (i(), h("button", {
|
|
888
|
+
key: ve,
|
|
889
889
|
type: "button",
|
|
890
890
|
class: "ai-suggestion",
|
|
891
|
-
onClick: (
|
|
892
|
-
}, U(
|
|
893
|
-
])) :
|
|
894
|
-
], 64)) :
|
|
895
|
-
a.value && ((
|
|
896
|
-
(i(!0),
|
|
897
|
-
key:
|
|
898
|
-
file:
|
|
899
|
-
state:
|
|
900
|
-
onDownload:
|
|
891
|
+
onClick: (me) => v("ask", j)
|
|
892
|
+
}, U(j), 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(be, null, He(t.msg.files, (j) => (i(), _e($a, {
|
|
897
|
+
key: j.relPath,
|
|
898
|
+
file: j,
|
|
899
|
+
state: S(j),
|
|
900
|
+
onDownload: b
|
|
901
901
|
}, null, 8, ["file", "state"]))), 128))
|
|
902
|
-
])) :
|
|
903
|
-
t.msg.errorMessage ? (i(),
|
|
904
|
-
|
|
902
|
+
])) : z("", !0),
|
|
903
|
+
t.msg.errorMessage ? (i(), h("div", Za, [
|
|
904
|
+
p[6] || (p[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
|
|
905
905
|
o("span", null, U(t.msg.errorMessage), 1)
|
|
906
|
-
])) :
|
|
907
|
-
|
|
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(), _e(ie(Ns), {
|
|
913
913
|
key: 0,
|
|
914
914
|
class: "message-toolbar__check"
|
|
915
|
-
})) : (i(),
|
|
915
|
+
})) : (i(), _e(ie(Vs), {
|
|
916
916
|
key: 1,
|
|
917
|
-
onClick:
|
|
917
|
+
onClick: p[1] || (p[1] = (j) => F(t.msg, t.index))
|
|
918
918
|
}))
|
|
919
919
|
], 8, eo),
|
|
920
920
|
o("div", to, [
|
|
921
|
-
|
|
922
|
-
onClick:
|
|
921
|
+
Ce(ie(Os), {
|
|
922
|
+
onClick: p[2] || (p[2] = (j) => u.$emit("regenerate"))
|
|
923
923
|
})
|
|
924
924
|
])
|
|
925
|
-
])) :
|
|
926
|
-
], 64)) : (i(),
|
|
927
|
-
(i(),
|
|
928
|
-
|
|
925
|
+
])) : z("", !0)
|
|
926
|
+
], 64)) : (i(), h("div", no, U(t.msg.content), 1)),
|
|
927
|
+
(i(), _e(mn, { to: "#ai-assist-root" }, [
|
|
928
|
+
C.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
|
-
src:
|
|
934
|
+
src: C.value,
|
|
935
935
|
class: "ai-image-preview-overlay__img",
|
|
936
|
-
onClick:
|
|
936
|
+
onClick: p[3] || (p[3] = Ve(() => {
|
|
937
937
|
}, ["stop"]))
|
|
938
938
|
}, null, 8, so),
|
|
939
939
|
o("button", {
|
|
940
940
|
class: "ai-image-preview-overlay__close",
|
|
941
|
-
onClick:
|
|
941
|
+
onClick: Ve(H, ["stop"])
|
|
942
942
|
}, [
|
|
943
|
-
|
|
943
|
+
Ce(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__ */ xe({
|
|
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, P = null, y = null,
|
|
987
|
-
const
|
|
988
|
-
() =>
|
|
989
|
-
), s =
|
|
990
|
-
() =>
|
|
991
|
-
),
|
|
992
|
-
() =>
|
|
993
|
-
),
|
|
994
|
-
() =>
|
|
985
|
+
const e = t, v = w, a = _(!1), f = _(""), g = _(""), l = _("idle"), r = _(""), S = _(null), b = _(null), E = _(!1), x = _(!1);
|
|
986
|
+
let I = !1, P = null, y = null, N = !1, J = !1, R = null;
|
|
987
|
+
const V = $(() => l.value === "connecting"), le = $(
|
|
988
|
+
() => l.value === "recording" || l.value === "stopping"
|
|
989
|
+
), s = $(
|
|
990
|
+
() => l.value === "connecting" || l.value === "recording" || l.value === "stopping"
|
|
991
|
+
), se = $(() => a.value && !s.value), re = $(
|
|
992
|
+
() => se.value ? !!r.value.trim() : !!(f.value.trim() || g.value.trim())
|
|
993
|
+
), de = $(
|
|
994
|
+
() => ot.isSupported() && !e.modelValue.trim() && !e.isGenerating
|
|
995
995
|
), k = _(!1);
|
|
996
|
-
function Z(
|
|
997
|
-
|
|
996
|
+
function Z(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 = $(() => x.value ? "正在请求麦克风权限…" : k.value && de.value ? "发消息...(按住可语音输入)" : "发消息..."), q = $(
|
|
1003
1003
|
() => E.value ? "正在聆听…松手结束" : "正在聆听…点击结束"
|
|
1004
1004
|
);
|
|
1005
|
-
function
|
|
1006
|
-
R = new
|
|
1007
|
-
onStatusChange: (
|
|
1008
|
-
|
|
1005
|
+
function X() {
|
|
1006
|
+
R = 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
|
-
|
|
1025
|
-
|
|
1021
|
+
Ne(X), Lt(() => {
|
|
1022
|
+
c(), R == null || R.destroy(), R = null;
|
|
1023
|
+
}), pe([f, g], () => {
|
|
1024
|
+
De(() => {
|
|
1025
|
+
S.value && (S.value.scrollTop = S.value.scrollHeight);
|
|
1026
1026
|
});
|
|
1027
|
-
}),
|
|
1028
|
-
if (
|
|
1027
|
+
}), pe(l, (B) => {
|
|
1028
|
+
if (B === "recording" && J) {
|
|
1029
1029
|
J = !1, R == null || R.stop();
|
|
1030
1030
|
return;
|
|
1031
1031
|
}
|
|
1032
|
-
|
|
1032
|
+
B === "idle" && a.value && (r.value = (f.value + g.value).trim(), De(() => {
|
|
1033
1033
|
var W;
|
|
1034
|
-
return (W =
|
|
1034
|
+
return (W = b.value) == null ? void 0 : W.focus();
|
|
1035
1035
|
}));
|
|
1036
1036
|
});
|
|
1037
|
-
function
|
|
1037
|
+
function L() {
|
|
1038
1038
|
s.value && (R == null || R.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
|
|
1043
|
+
function c() {
|
|
1044
1044
|
P !== null && (clearTimeout(P), P = null), y = null, D();
|
|
1045
1045
|
}
|
|
1046
|
-
function
|
|
1047
|
-
|
|
1046
|
+
function C() {
|
|
1047
|
+
l.value === "recording" ? R == null || R.stop() : (l.value === "connecting" || l.value === "stopping") && (J = !0);
|
|
1048
1048
|
}
|
|
1049
1049
|
function T() {
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1050
|
+
const B = N;
|
|
1051
|
+
N = !1, c(), B && C();
|
|
1052
1052
|
}
|
|
1053
|
-
function B
|
|
1053
|
+
function H(B) {
|
|
1054
1054
|
if (!y) return;
|
|
1055
|
-
if (
|
|
1056
|
-
|
|
1055
|
+
if (N) {
|
|
1056
|
+
B.buttons === 0 && T();
|
|
1057
1057
|
return;
|
|
1058
1058
|
}
|
|
1059
|
-
const W =
|
|
1060
|
-
Math.hypot(W,
|
|
1059
|
+
const W = B.clientX - y.x, ue = B.clientY - y.y;
|
|
1060
|
+
Math.hypot(W, ue) > wo && c();
|
|
1061
1061
|
}
|
|
1062
|
-
function
|
|
1062
|
+
function F() {
|
|
1063
1063
|
T();
|
|
1064
1064
|
}
|
|
1065
|
-
function
|
|
1066
|
-
|
|
1065
|
+
function u() {
|
|
1066
|
+
N && T();
|
|
1067
1067
|
}
|
|
1068
|
-
function
|
|
1069
|
-
|
|
1070
|
-
var
|
|
1071
|
-
P = null,
|
|
1072
|
-
const W =
|
|
1073
|
-
W && typeof W.blur == "function" && W.blur(), (
|
|
1074
|
-
}, yo), window.addEventListener("pointerup",
|
|
1068
|
+
function p(B) {
|
|
1069
|
+
de.value && (B.pointerType === "mouse" && B.button !== 0 || (y = { x: B.clientX, y: B.clientY }, N = !1, J = !1, P !== null && clearTimeout(P), P = setTimeout(() => {
|
|
1070
|
+
var ue, j, ve;
|
|
1071
|
+
P = null, N = !0;
|
|
1072
|
+
const W = B.target;
|
|
1073
|
+
W && typeof W.blur == "function" && W.blur(), (ve = (j = (ue = window.getSelection) == null ? void 0 : ue.call(window)) == null ? void 0 : j.removeAllRanges) == null || ve.call(j), Y(!0);
|
|
1074
|
+
}, yo), window.addEventListener("pointerup", F), window.addEventListener("pointercancel", F), window.addEventListener("pointermove", H), window.addEventListener("blur", u)));
|
|
1075
1075
|
}
|
|
1076
|
-
async function
|
|
1076
|
+
async function Y(B = !1) {
|
|
1077
1077
|
if (!R || I) return;
|
|
1078
1078
|
x.value = !0, I = !0;
|
|
1079
|
-
const { granted: W, prompted:
|
|
1079
|
+
const { granted: W, prompted: ue } = await ot.ensurePermission();
|
|
1080
1080
|
if (x.value = !1, I = !1, !W) {
|
|
1081
|
-
|
|
1081
|
+
Ie("麦克风不可用,请允许浏览器使用麦克风后重试");
|
|
1082
1082
|
return;
|
|
1083
1083
|
}
|
|
1084
|
-
if (
|
|
1085
|
-
|
|
1084
|
+
if (B && !N) {
|
|
1085
|
+
ue && Ie("麦克风已开启,请重新按住输入框开始说话", "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
1090
|
await R.start();
|
|
1091
1091
|
} catch {
|
|
1092
1092
|
a.value = !1;
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
|
-
function
|
|
1096
|
-
R == null || R.cancel(), a.value = !1, E.value = !1, J = !1,
|
|
1095
|
+
function ae() {
|
|
1096
|
+
R == null || R.cancel(), a.value = !1, E.value = !1, J = !1, f.value = "", g.value = "", r.value = "";
|
|
1097
1097
|
}
|
|
1098
|
-
function
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1098
|
+
function Q() {
|
|
1099
|
+
const B = (se.value ? r.value : f.value + g.value).trim();
|
|
1100
|
+
B && (R == null || R.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: ge(["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
|
-
ref:
|
|
1111
|
-
onClick:
|
|
1110
|
+
ref: S,
|
|
1111
|
+
onClick: L
|
|
1112
1112
|
}, [
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
!
|
|
1116
|
-
], 512)) :
|
|
1113
|
+
f.value ? (i(), h("span", io, U(f.value), 1)) : z("", !0),
|
|
1114
|
+
g.value ? (i(), h("span", lo, U(g.value), 1)) : z("", !0),
|
|
1115
|
+
!f.value && !g.value ? (i(), h("span", ro, U(V.value ? "启动中…" : q.value), 1)) : z("", !0)
|
|
1116
|
+
], 512)) : qe((i(), h("input", {
|
|
1117
1117
|
key: 1,
|
|
1118
1118
|
ref_key: "editorEl",
|
|
1119
|
-
ref:
|
|
1120
|
-
"onUpdate:modelValue": W[0] || (W[0] = (
|
|
1119
|
+
ref: b,
|
|
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: $t(
|
|
1125
|
-
onKeyup: W[1] || (W[1] = $t((
|
|
1124
|
+
onKeydown: $t(Ve(ae, ["prevent"]), ["esc"]),
|
|
1125
|
+
onKeyup: W[1] || (W[1] = $t((ue) => re.value && Q(), ["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: ae
|
|
1133
1133
|
}, [
|
|
1134
|
-
|
|
1134
|
+
Ce(Ee, {
|
|
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: ge(["tooltip-enhanced voice-send", { disabled: !re.value }]),
|
|
1141
|
+
"data-tooltip": re.value ? "发送" : "未识别到文字",
|
|
1142
|
+
onClick: W[2] || (W[2] = (ue) => re.value && Q())
|
|
1143
1143
|
}, [
|
|
1144
|
-
|
|
1144
|
+
Ce(Ee, {
|
|
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
|
+
Ce(Ee, {
|
|
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] = $t((
|
|
1160
|
+
placeholder: O.value,
|
|
1161
|
+
onInput: W[4] || (W[4] = (ue) => B.$emit("update:modelValue", ue.target.value)),
|
|
1162
|
+
onKeyup: W[5] || (W[5] = $t((ue) => t.modelValue.trim() && B.$emit("send"), ["enter"])),
|
|
1163
1163
|
disabled: t.isGenerating,
|
|
1164
|
-
onPointerdown:
|
|
1164
|
+
onPointerdown: p,
|
|
1165
1165
|
onPointerenter: Z,
|
|
1166
|
-
onPointerleave:
|
|
1166
|
+
onPointerleave: m
|
|
1167
1167
|
}, null, 40, fo),
|
|
1168
|
-
t.isGenerating ? (i(),
|
|
1169
|
-
|
|
1168
|
+
t.isGenerating ? (i(), h("div", mo, [
|
|
1169
|
+
Ce(Ee, {
|
|
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
|
+
Ce(Ee, {
|
|
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: ge(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
|
|
1187
1187
|
"data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
|
|
1188
1188
|
}, [
|
|
1189
|
-
|
|
1189
|
+
Ce(Ee, {
|
|
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
|
+
Ce(Ee, {
|
|
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, S = g.clientHeight;
|
|
1209
|
+
if (r <= S) {
|
|
1210
|
+
l.style.setProperty("--ai-thumb-height", "0px"), l.style.setProperty("--ai-thumb-top", "0px");
|
|
1211
1211
|
return;
|
|
1212
1212
|
}
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1213
|
+
const b = Math.max(S * S / r, 32), E = S - b, x = g.scrollTop / (r - S);
|
|
1214
|
+
l.style.setProperty("--ai-thumb-height", `${b}px`), l.style.setProperty("--ai-thumb-top", `${x * E}px`);
|
|
1215
1215
|
}
|
|
1216
1216
|
function a() {
|
|
1217
|
-
|
|
1217
|
+
De(() => {
|
|
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
|
-
function
|
|
1263
|
+
function So({
|
|
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()), S = _(/* @__PURE__ */ new Map()), b = _(/* @__PURE__ */ new Map()), E = _(!1), x = _(/* @__PURE__ */ new Map()), I = _(/* @__PURE__ */ new Map()), P = _(!1);
|
|
1273
|
+
function y(V) {
|
|
1274
|
+
const le = l.value.get(V) || [];
|
|
1275
|
+
v((s) => {
|
|
1276
|
+
if (s[V]) {
|
|
1277
|
+
const se = [...s];
|
|
1278
|
+
return se[V] = { ...se[V], segments: le.map((re) => ({ ...re })) }, se;
|
|
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 se = s[V];
|
|
1287
|
+
if (!se || se.status === f.COMPLETED || se.status === f.STOP || se.status === f.ERROR)
|
|
1288
1288
|
return s;
|
|
1289
|
-
const
|
|
1290
|
-
return
|
|
1289
|
+
const re = [...s];
|
|
1290
|
+
return re[V] = { ...se, lastChunkAt: le }, re;
|
|
1291
1291
|
});
|
|
1292
1292
|
}
|
|
1293
|
-
function J(
|
|
1294
|
-
const
|
|
1295
|
-
let
|
|
1296
|
-
|
|
1293
|
+
function J(V) {
|
|
1294
|
+
const le = l.value.get(V) || [], s = S.value.get(V), se = 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 ? se == null ? void 0 : se.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[
|
|
1301
|
+
}), de && (l.value.set(V, le), v((k) => {
|
|
1302
|
+
if (k[V]) {
|
|
1303
1303
|
const Z = [...k];
|
|
1304
|
-
return Z[
|
|
1305
|
-
...Z[
|
|
1306
|
-
segments:
|
|
1307
|
-
thinkingDuration: (Z[
|
|
1304
|
+
return Z[V] = {
|
|
1305
|
+
...Z[V],
|
|
1306
|
+
segments: le.map((m) => ({ ...m })),
|
|
1307
|
+
thinkingDuration: (Z[V].thinkingDuration || 0) + re
|
|
1308
1308
|
}, Z;
|
|
1309
1309
|
}
|
|
1310
1310
|
return k;
|
|
1311
1311
|
}));
|
|
1312
1312
|
}
|
|
1313
|
-
async function R(
|
|
1314
|
-
P.value = !1, E.value = !1,
|
|
1313
|
+
async function R(V, le, s, se, re = !1) {
|
|
1314
|
+
P.value = !1, E.value = !1, l.value.set(s, []), x.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: se,
|
|
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 Z,
|
|
1330
|
+
var Z, 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
|
-
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1351
|
+
S.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
|
-
T && T.type === "agent_thought" && T.duration == null ? T.content +=
|
|
1359
|
-
if (
|
|
1360
|
-
const
|
|
1361
|
-
return
|
|
1362
|
-
...
|
|
1363
|
-
segments:
|
|
1364
|
-
thinkingContent: (
|
|
1365
|
-
status:
|
|
1366
|
-
},
|
|
1357
|
+
const c = D.thought || D.thinking || "", C = l.value.get(s) || [], T = C[C.length - 1];
|
|
1358
|
+
T && T.type === "agent_thought" && T.duration == null ? T.content += c : (r.value.set(s, "agent_thought"), C.push({ type: "agent_thought", content: c }), b.value.set(s, Date.now())), l.value.set(s, C), v((H) => {
|
|
1359
|
+
if (H[s]) {
|
|
1360
|
+
const F = [...H];
|
|
1361
|
+
return F[s] = {
|
|
1362
|
+
...F[s],
|
|
1363
|
+
segments: C.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
|
-
T && T.type === "thinking" ? T.content +=
|
|
1375
|
-
if (
|
|
1376
|
-
const
|
|
1377
|
-
return
|
|
1378
|
-
...
|
|
1379
|
-
segments:
|
|
1380
|
-
thinkingContent: (
|
|
1381
|
-
status:
|
|
1382
|
-
},
|
|
1373
|
+
const c = D.thinking || D.answer || D.text || "", C = l.value.get(s) || [], T = C[C.length - 1];
|
|
1374
|
+
T && T.type === "thinking" ? T.content += c : (C.push({ type: "thinking", content: c }), S.value.set(s, Date.now())), l.value.set(s, C), v((H) => {
|
|
1375
|
+
if (H[s]) {
|
|
1376
|
+
const F = [...H];
|
|
1377
|
+
return F[s] = {
|
|
1378
|
+
...F[s],
|
|
1379
|
+
segments: C.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: T.map((
|
|
1396
|
-
thinkingDuration: (
|
|
1397
|
-
},
|
|
1389
|
+
const c = b.value.get(s), C = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, T = l.value.get(s) || [], H = T[T.length - 1];
|
|
1390
|
+
H && H.type === "agent_thought" && (H.duration = C), l.value.set(s, T), v((F) => {
|
|
1391
|
+
if (F[s]) {
|
|
1392
|
+
const u = [...F];
|
|
1393
|
+
return u[s] = {
|
|
1394
|
+
...u[s],
|
|
1395
|
+
segments: T.map((p) => ({ ...p })),
|
|
1396
|
+
thinkingDuration: (u[s].thinkingDuration || 0) + C
|
|
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: T.map((
|
|
1411
|
-
thinkingDuration: (
|
|
1412
|
-
},
|
|
1404
|
+
const c = S.value.get(s), C = c ? Math.round((Date.now() - c) / 1e3 * 10) / 10 : 0, T = l.value.get(s) || [], H = T[T.length - 1];
|
|
1405
|
+
H && H.type === "thinking" && (H.duration = C), l.value.set(s, T), v((F) => {
|
|
1406
|
+
if (F[s]) {
|
|
1407
|
+
const u = [...F];
|
|
1408
|
+
return u[s] = {
|
|
1409
|
+
...u[s],
|
|
1410
|
+
segments: T.map((p) => ({ ...p })),
|
|
1411
|
+
thinkingDuration: (u[s].thinkingDuration || 0) + C
|
|
1412
|
+
}, u;
|
|
1413
1413
|
}
|
|
1414
|
-
return
|
|
1414
|
+
return F;
|
|
1415
1415
|
});
|
|
1416
1416
|
break;
|
|
1417
1417
|
}
|
|
@@ -1420,478 +1420,539 @@ function Mo({
|
|
|
1420
1420
|
// 其余(執行準備/資料獲取/...)归入流程步骤。
|
|
1421
1421
|
case "tool_message_output_start": {
|
|
1422
1422
|
E.value = !0;
|
|
1423
|
-
const
|
|
1423
|
+
const c = ((Z = D.message_config) == null ? void 0 : Z.reasoning) === !0 || D.reasoning === !0, C = Date.now(), T = l.value.get(s) || [];
|
|
1424
1424
|
T.push({
|
|
1425
|
-
type:
|
|
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 = T.length - 1;
|
|
1432
|
+
if (l.value.set(s, T), r.value.set(s, c ? "thinking" : "step"), D.id != null) {
|
|
1433
|
+
const F = x.value.get(s) || /* @__PURE__ */ new Map();
|
|
1434
|
+
F.set(String(D.id), H), x.value.set(s, F);
|
|
1435
|
+
const u = I.value.get(s) || /* @__PURE__ */ new Map();
|
|
1436
|
+
u.set(String(D.id), C), I.value.set(s, u);
|
|
1437
1437
|
}
|
|
1438
|
-
|
|
1438
|
+
c && S.value.set(s, C), y(s);
|
|
1439
1439
|
break;
|
|
1440
1440
|
}
|
|
1441
1441
|
case "tool_message": {
|
|
1442
|
-
const
|
|
1443
|
-
if (!
|
|
1444
|
-
const
|
|
1442
|
+
const c = D.answer || D.text || D.content || "";
|
|
1443
|
+
if (!c) break;
|
|
1444
|
+
const C = l.value.get(s) || [];
|
|
1445
1445
|
if (E.value) {
|
|
1446
|
-
const T = D.id != null ? String(D.id) : null,
|
|
1447
|
-
let
|
|
1448
|
-
if (
|
|
1449
|
-
const
|
|
1450
|
-
if (
|
|
1451
|
-
type:
|
|
1446
|
+
const T = D.id != null ? String(D.id) : null, H = x.value.get(s);
|
|
1447
|
+
let F = T != null ? H == null ? void 0 : H.get(T) : void 0;
|
|
1448
|
+
if (F == null || !C[F]) {
|
|
1449
|
+
const u = ((m = D.message_config) == null ? void 0 : m.reasoning) === !0 || D.reasoning === !0;
|
|
1450
|
+
if (C.push({
|
|
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 = C.length - 1, T != null) {
|
|
1457
|
+
const p = H || /* @__PURE__ */ new Map();
|
|
1458
|
+
p.set(T, F), x.value.set(s, p), u && S.value.set(s, Date.now());
|
|
1459
1459
|
}
|
|
1460
1460
|
} else {
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1461
|
+
const u = C[F];
|
|
1462
|
+
C[F] = { ...u, content: u.content + c };
|
|
1463
1463
|
}
|
|
1464
|
-
|
|
1465
|
-
if (
|
|
1466
|
-
const
|
|
1467
|
-
return
|
|
1468
|
-
...
|
|
1469
|
-
segments:
|
|
1470
|
-
status:
|
|
1471
|
-
},
|
|
1464
|
+
l.value.set(s, C), v((u) => {
|
|
1465
|
+
if (u[s]) {
|
|
1466
|
+
const p = [...u];
|
|
1467
|
+
return p[s] = {
|
|
1468
|
+
...p[s],
|
|
1469
|
+
segments: C.map((Y) => ({ ...Y })),
|
|
1470
|
+
status: f.THINKING
|
|
1471
|
+
}, p;
|
|
1472
1472
|
}
|
|
1473
|
-
return
|
|
1473
|
+
return u;
|
|
1474
1474
|
});
|
|
1475
1475
|
break;
|
|
1476
1476
|
}
|
|
1477
|
-
|
|
1477
|
+
C.push({ type: "answer", content: c }), l.value.set(s, C), y(s);
|
|
1478
1478
|
break;
|
|
1479
1479
|
}
|
|
1480
1480
|
// ── 对话流型智能体:步骤/推理消息结束,记录该步骤耗时 ──
|
|
1481
1481
|
case "tool_message_output_end": {
|
|
1482
|
-
const
|
|
1483
|
-
let T =
|
|
1484
|
-
(T == null || !
|
|
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) || [], C = D.id != null ? String(D.id) : null;
|
|
1483
|
+
let T = C != null ? (O = x.value.get(s)) == null ? void 0 : O.get(C) : c.length - 1;
|
|
1484
|
+
(T == null || !c[T]) && (T = c.length - 1);
|
|
1485
|
+
const H = (C != null ? (q = I.value.get(s)) == null ? void 0 : q.get(C) : void 0) ?? S.value.get(s), F = H ? Math.round((Date.now() - H) / 1e3 * 10) / 10 : 0;
|
|
1486
|
+
let u = 0;
|
|
1487
|
+
const p = c[T];
|
|
1488
|
+
p && p.duration == null && (c[T] = { ...p, duration: F }, p.type === "thinking" && (u = F)), l.value.set(s, c), v((Y) => {
|
|
1489
|
+
if (Y[s]) {
|
|
1490
|
+
const ae = [...Y];
|
|
1491
|
+
return ae[s] = {
|
|
1492
|
+
...ae[s],
|
|
1493
|
+
segments: c.map((Q) => ({ ...Q })),
|
|
1494
|
+
...u ? { thinkingDuration: (ae[s].thinkingDuration || 0) + u } : {}
|
|
1495
|
+
}, ae;
|
|
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
|
-
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
if (
|
|
1514
|
-
const
|
|
1515
|
-
return
|
|
1516
|
-
...
|
|
1517
|
-
segments: T.map((
|
|
1518
|
-
content:
|
|
1519
|
-
status: P.value ?
|
|
1520
|
-
},
|
|
1509
|
+
const c = D.answer || "", C = r.value.get(s), T = l.value.get(s) || [], H = T[T.length - 1];
|
|
1510
|
+
C === "answer" && H && H.type === "answer" ? H.content += c : (J(s), r.value.set(s, "answer"), T.push({ type: "answer", content: c })), l.value.set(s, T);
|
|
1511
|
+
const F = T.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: T.map((Y) => ({ ...Y })),
|
|
1518
|
+
content: F,
|
|
1519
|
+
status: P.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: P.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
|
-
T != null ?
|
|
1547
|
-
if (
|
|
1548
|
-
const
|
|
1549
|
-
return
|
|
1550
|
-
...
|
|
1551
|
-
segments:
|
|
1552
|
-
content:
|
|
1553
|
-
},
|
|
1545
|
+
const c = D.answer || "", C = l.value.get(s) || [], T = (X = C.map((H, F) => ({ s: H, i: F })).reverse().find((H) => H.s.type === "answer")) == null ? void 0 : X.i;
|
|
1546
|
+
T != null ? C[T] = { ...C[T], content: c } : C.push({ type: "answer", content: c }), l.value.set(s, C), v((H) => {
|
|
1547
|
+
if (H[s]) {
|
|
1548
|
+
const F = [...H];
|
|
1549
|
+
return F[s] = {
|
|
1550
|
+
...F[s],
|
|
1551
|
+
segments: C.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
|
-
|
|
1567
|
-
if (
|
|
1568
|
-
const T = [...
|
|
1569
|
-
return T[s] = { ...T[s], cost:
|
|
1566
|
+
v((C) => {
|
|
1567
|
+
if (C[s]) {
|
|
1568
|
+
const T = [...C];
|
|
1569
|
+
return T[s] = { ...T[s], cost: c }, T;
|
|
1570
1570
|
}
|
|
1571
|
-
return
|
|
1571
|
+
return C;
|
|
1572
1572
|
});
|
|
1573
1573
|
break;
|
|
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
1582
|
a(), J(s), a();
|
|
1583
|
-
const Z = (
|
|
1584
|
-
|
|
1585
|
-
...
|
|
1583
|
+
const Z = (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
1586
|
content: P.value && !Z ? "已停止回答" : Z,
|
|
1587
|
-
status: P.value ?
|
|
1588
|
-
}), t.value =
|
|
1587
|
+
status: P.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
1592
|
const Z = [...t.value];
|
|
1593
1593
|
Z[s] && (Z[s] = { ...Z[s], content: `
|
|
1594
|
-
⚠️ 请求异常,已终止`, status:
|
|
1594
|
+
⚠️ 请求异常,已终止`, status: f.ERROR }), t.value = Z, 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), !P.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
1605
|
return { doStreamRequest: R, issTop: P };
|
|
1606
1606
|
}
|
|
1607
|
-
function
|
|
1607
|
+
function Mo(t) {
|
|
1608
1608
|
return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
|
|
1609
1609
|
}
|
|
1610
|
-
function
|
|
1610
|
+
function $o({
|
|
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:
|
|
1620
|
-
cfg:
|
|
1621
|
-
onTitleGenerated:
|
|
1616
|
+
doStreamRequest: f,
|
|
1617
|
+
issTop: g,
|
|
1618
|
+
scrollToBottom: l,
|
|
1619
|
+
STATUS: r,
|
|
1620
|
+
cfg: S,
|
|
1621
|
+
onTitleGenerated: b
|
|
1622
1622
|
}) {
|
|
1623
|
-
const E =
|
|
1623
|
+
const E = S.apis, x = Oe({
|
|
1624
1624
|
first: new AbortController(),
|
|
1625
1625
|
again: new AbortController()
|
|
1626
1626
|
}), I = _(!1), P = _("");
|
|
1627
|
-
let y = 0,
|
|
1627
|
+
let y = 0, N = null;
|
|
1628
1628
|
function J() {
|
|
1629
|
-
var
|
|
1630
|
-
return
|
|
1629
|
+
var m;
|
|
1630
|
+
return Ct() === "page" && !!((m = We()) != null && m.api);
|
|
1631
1631
|
}
|
|
1632
|
-
async function R(
|
|
1633
|
-
var
|
|
1634
|
-
const
|
|
1635
|
-
if (!
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1632
|
+
async function R(m, O) {
|
|
1633
|
+
var te, fe;
|
|
1634
|
+
const q = (te = We()) == null ? void 0 : te.api;
|
|
1635
|
+
if (!q) return;
|
|
1636
|
+
const X = Be(), 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 ee;
|
|
1642
|
+
const A = t.value;
|
|
1643
|
+
if (((ee = A[O]) == null ? void 0 : ee.type) === "ai") return O;
|
|
1644
|
+
for (let ne = A.length - 1; ne >= 0; ne -= 1)
|
|
1645
|
+
if (A[ne].type === "ai") return ne;
|
|
1646
1646
|
return -1;
|
|
1647
|
-
},
|
|
1648
|
-
if (
|
|
1649
|
-
const
|
|
1650
|
-
if (
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
}, T = (
|
|
1654
|
-
|
|
1655
|
-
|
|
1647
|
+
}, C = (A, ee = !1) => {
|
|
1648
|
+
if (L !== y) return;
|
|
1649
|
+
const ne = c();
|
|
1650
|
+
if (ne < 0) return;
|
|
1651
|
+
const oe = [...t.value];
|
|
1652
|
+
oe[ne] = A(oe[ne]), t.value = oe, ee && l();
|
|
1653
|
+
}, T = (A, ee) => C((ne) => ({ ...ne, content: A, status: ee }), !0);
|
|
1654
|
+
let H = "", F = 0, u = null;
|
|
1655
|
+
const p = () => {
|
|
1656
|
+
u && (clearInterval(u), u = null);
|
|
1657
|
+
}, Y = (A, ee, ne = !1) => {
|
|
1658
|
+
let oe = !1;
|
|
1659
|
+
C((ye) => {
|
|
1660
|
+
var Te, Se;
|
|
1661
|
+
oe = !0;
|
|
1662
|
+
const $e = `${ne && ((Te = ye.toolState) == null ? void 0 : Te.status) === "done" && ye.toolState.message ? `${ye.toolState.message},` : ""}${A}`;
|
|
1663
|
+
return H = $e, F = Date.now(), {
|
|
1664
|
+
...ye,
|
|
1665
|
+
toolState: { name: ee || ((Se = ye.toolState) == null ? void 0 : Se.name) || "status", status: "running", message: $e }
|
|
1666
|
+
};
|
|
1667
|
+
}), oe && (p(), u = setInterval(() => {
|
|
1668
|
+
if (L !== y || !H) return;
|
|
1669
|
+
const ye = Math.round((Date.now() - F) / 1e3);
|
|
1670
|
+
ye < 2 || C((Re) => {
|
|
1671
|
+
var $e;
|
|
1672
|
+
return {
|
|
1673
|
+
...Re,
|
|
1674
|
+
toolState: {
|
|
1675
|
+
name: (($e = Re.toolState) == null ? void 0 : $e.name) || "status",
|
|
1676
|
+
status: "running",
|
|
1677
|
+
message: `${H}(已用 ${ye}s)`
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
});
|
|
1681
|
+
}, 1e3));
|
|
1682
|
+
};
|
|
1683
|
+
let ae = "", Q = "", B = null;
|
|
1684
|
+
const W = () => {
|
|
1685
|
+
B && (clearInterval(B), B = null);
|
|
1686
|
+
}, ue = () => {
|
|
1687
|
+
const A = rn(ae);
|
|
1688
|
+
if (A.length <= Q.length) return;
|
|
1689
|
+
const ee = Math.max(2, Math.ceil((A.length - Q.length) / 12));
|
|
1690
|
+
Q = A.slice(0, Q.length + ee), T(Q, r.ANSWERING);
|
|
1691
|
+
}, j = () => {
|
|
1692
|
+
B || (B = setInterval(ue, 24));
|
|
1693
|
+
}, ve = () => {
|
|
1694
|
+
W();
|
|
1695
|
+
const A = rn(ae);
|
|
1696
|
+
A !== Q && (Q = A, T(Q, r.ANSWERING));
|
|
1697
|
+
}, me = () => {
|
|
1698
|
+
p(), C((A) => {
|
|
1699
|
+
var ee;
|
|
1700
|
+
return ((ee = A.toolState) == null ? void 0 : ee.status) !== "running" ? A : {
|
|
1656
1701
|
...A,
|
|
1657
|
-
toolState: {
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1702
|
+
toolState: {
|
|
1703
|
+
...A.toolState,
|
|
1704
|
+
status: "done",
|
|
1705
|
+
message: (A.toolState.message || "").replace(/(已用 \d+s)$/, "")
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
});
|
|
1709
|
+
}, G = (A) => {
|
|
1710
|
+
if (A.type === "status")
|
|
1711
|
+
Y(A.message || "正在处理…", void 0, A.phase === "answering");
|
|
1712
|
+
else if (A.type === "tool")
|
|
1713
|
+
Y(A.message || "正在查询数据…", A.name);
|
|
1714
|
+
else if (A.type === "tool_result")
|
|
1715
|
+
p(), H = "", C((ee) => {
|
|
1716
|
+
var ne;
|
|
1662
1717
|
return {
|
|
1663
|
-
...
|
|
1718
|
+
...ee,
|
|
1664
1719
|
toolState: {
|
|
1665
|
-
name: ((
|
|
1666
|
-
status:
|
|
1667
|
-
message:
|
|
1720
|
+
name: ((ne = ee.toolState) == null ? void 0 : ne.name) || "turnover_trend",
|
|
1721
|
+
status: A.ok ? "done" : "failed",
|
|
1722
|
+
message: A.summary
|
|
1668
1723
|
}
|
|
1669
1724
|
};
|
|
1670
1725
|
});
|
|
1671
|
-
else if (
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
...
|
|
1675
|
-
charts: [...(
|
|
1726
|
+
else if (A.type === "chart") {
|
|
1727
|
+
const ee = { chartId: A.chartId, option: A.option };
|
|
1728
|
+
C((ne) => ({
|
|
1729
|
+
...ne,
|
|
1730
|
+
charts: [...(ne.charts || []).filter((oe) => oe.chartId !== ee.chartId), ee]
|
|
1676
1731
|
}));
|
|
1677
1732
|
}
|
|
1678
1733
|
};
|
|
1679
1734
|
try {
|
|
1680
|
-
let
|
|
1681
|
-
if (
|
|
1682
|
-
const
|
|
1683
|
-
if (
|
|
1684
|
-
let
|
|
1685
|
-
const
|
|
1686
|
-
module:
|
|
1687
|
-
threadId:
|
|
1688
|
-
question:
|
|
1689
|
-
pageContext:
|
|
1735
|
+
let A = Rt(X);
|
|
1736
|
+
if (A || (A = await q.createThread({ module: X }), Tt(A, X)), L !== y) return;
|
|
1737
|
+
const ee = await _t();
|
|
1738
|
+
if (L !== y) return;
|
|
1739
|
+
let ne = "";
|
|
1740
|
+
const oe = q.chatStream ? await q.chatStream({
|
|
1741
|
+
module: X,
|
|
1742
|
+
threadId: A,
|
|
1743
|
+
question: m,
|
|
1744
|
+
pageContext: ee,
|
|
1690
1745
|
signal: D.signal,
|
|
1691
|
-
onMeta: (
|
|
1692
|
-
|
|
1746
|
+
onMeta: (Se) => {
|
|
1747
|
+
Se != null && Se.threadId && Tt(Se.threadId, X);
|
|
1693
1748
|
},
|
|
1694
|
-
onDelta: (
|
|
1695
|
-
|
|
1749
|
+
onDelta: (Se) => {
|
|
1750
|
+
ne += Se, ae = ne, Q || me(), j();
|
|
1696
1751
|
},
|
|
1697
|
-
onEvent:
|
|
1698
|
-
}) : await
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1701
|
-
const
|
|
1702
|
-
if (
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1752
|
+
onEvent: G
|
|
1753
|
+
}) : await q.chat({ module: X, threadId: A, question: m, pageContext: ee });
|
|
1754
|
+
if (L !== y) return;
|
|
1755
|
+
oe != null && oe.threadId && Tt(oe.threadId, X), p(), ve();
|
|
1756
|
+
const ye = Bs((oe == null ? void 0 : oe.content) || ne), Re = c();
|
|
1757
|
+
if (Re < 0) return;
|
|
1758
|
+
const $e = [...t.value], Te = $e[Re];
|
|
1759
|
+
$e[Re] = {
|
|
1705
1760
|
type: "ai",
|
|
1706
|
-
content:
|
|
1707
|
-
status:
|
|
1708
|
-
actions:
|
|
1709
|
-
suggestions:
|
|
1710
|
-
files: (
|
|
1761
|
+
content: ye.answer,
|
|
1762
|
+
status: r.COMPLETED,
|
|
1763
|
+
actions: ye.actions,
|
|
1764
|
+
suggestions: ye.suggestions,
|
|
1765
|
+
files: (oe == null ? void 0 : oe.files) ?? [],
|
|
1711
1766
|
// 图表始终并入当前回答消息,不新开气泡
|
|
1712
|
-
charts: (
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1767
|
+
charts: (fe = oe == null ? void 0 : oe.charts) != null && fe.length ? oe.charts : (Te == null ? void 0 : Te.charts) || [],
|
|
1768
|
+
// 结束时收掉「正在…(已用 Ns)」状态,避免 spinner 一直转
|
|
1769
|
+
toolState: Te != null && Te.toolState ? {
|
|
1770
|
+
...Te.toolState,
|
|
1771
|
+
status: Te.toolState.status === "running" ? "done" : Te.toolState.status,
|
|
1772
|
+
message: (Te.toolState.message || "").replace(/(已用 \d+s)$/, "")
|
|
1773
|
+
} : void 0
|
|
1774
|
+
}, t.value = $e;
|
|
1775
|
+
} catch (A) {
|
|
1776
|
+
if (L !== y) return;
|
|
1777
|
+
p(), W();
|
|
1778
|
+
const ee = c();
|
|
1779
|
+
if (ee < 0) return;
|
|
1780
|
+
if ((A == null ? void 0 : A.name) === "AbortError" || (A == null ? void 0 : A.code) === "ABORT_ERR") {
|
|
1781
|
+
const oe = [...t.value];
|
|
1782
|
+
oe[ee] = { ...oe[ee], status: r.STOP }, t.value = oe;
|
|
1722
1783
|
return;
|
|
1723
1784
|
}
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1785
|
+
const ne = [...t.value];
|
|
1786
|
+
ne[ee] = {
|
|
1726
1787
|
type: "ai",
|
|
1727
|
-
content: (
|
|
1728
|
-
status:
|
|
1729
|
-
}, t.value =
|
|
1788
|
+
content: (A == null ? void 0 : A.message) || "AI 服务连接失败,请稍后重试",
|
|
1789
|
+
status: r.ERROR
|
|
1790
|
+
}, t.value = ne;
|
|
1730
1791
|
} finally {
|
|
1731
|
-
|
|
1792
|
+
p(), W(), L === y && (e.value = !1, N = null);
|
|
1732
1793
|
}
|
|
1733
1794
|
}
|
|
1734
|
-
async function
|
|
1735
|
-
var
|
|
1736
|
-
if (J() || !
|
|
1737
|
-
let
|
|
1738
|
-
if (!
|
|
1795
|
+
async function V(m, O) {
|
|
1796
|
+
var X;
|
|
1797
|
+
if (J() || !S.titleGenerateApp || !E.updateConversationApi || I.value) return;
|
|
1798
|
+
let q = a.value;
|
|
1799
|
+
if (!q)
|
|
1739
1800
|
try {
|
|
1740
|
-
const
|
|
1741
|
-
(
|
|
1742
|
-
} catch (
|
|
1743
|
-
console.error("[ai-assist-sdk] 创建会话失败:",
|
|
1801
|
+
const L = await en(E);
|
|
1802
|
+
(X = L == null ? void 0 : L.conversation) != null && X.appConversationID && (q = L.conversation.appConversationID, a.value = q);
|
|
1803
|
+
} catch (L) {
|
|
1804
|
+
console.error("[ai-assist-sdk] 创建会话失败:", L);
|
|
1744
1805
|
return;
|
|
1745
1806
|
}
|
|
1746
|
-
if (
|
|
1807
|
+
if (q)
|
|
1747
1808
|
try {
|
|
1748
|
-
const
|
|
1749
|
-
if (!
|
|
1750
|
-
const D =
|
|
1751
|
-
AI回答:${D}`, T = await
|
|
1752
|
-
app:
|
|
1753
|
-
data: { Query:
|
|
1754
|
-
}),
|
|
1755
|
-
|
|
1756
|
-
} catch (
|
|
1757
|
-
console.error("[ai-assist-sdk] 生成对话标题失败:",
|
|
1809
|
+
const L = await us(E, S.titleGenerateApp);
|
|
1810
|
+
if (!L) return;
|
|
1811
|
+
const D = O.length > 500 ? O.slice(0, 500) : O, c = `用户提问:${m}
|
|
1812
|
+
AI回答:${D}`, T = await tn().post(E.chatQueryApi, {
|
|
1813
|
+
app: S.titleGenerateApp,
|
|
1814
|
+
data: { Query: c, AppConversationID: L }
|
|
1815
|
+
}), H = cs(nn(T.data));
|
|
1816
|
+
H && (await ds(E, q, H), I.value = !0, b == null || b(H));
|
|
1817
|
+
} catch (L) {
|
|
1818
|
+
console.error("[ai-assist-sdk] 生成对话标题失败:", L);
|
|
1758
1819
|
}
|
|
1759
1820
|
}
|
|
1760
|
-
async function
|
|
1821
|
+
async function le() {
|
|
1761
1822
|
var D;
|
|
1762
|
-
const
|
|
1763
|
-
if (!
|
|
1764
|
-
const
|
|
1765
|
-
if (!
|
|
1766
|
-
|
|
1823
|
+
const m = w.value.trim();
|
|
1824
|
+
if (!m || e.value) return;
|
|
1825
|
+
const O = J();
|
|
1826
|
+
if (!O && !a.value && (await de(), !a.value)) {
|
|
1827
|
+
Ie("创建会话失败,请重试");
|
|
1767
1828
|
return;
|
|
1768
1829
|
}
|
|
1769
|
-
const
|
|
1830
|
+
const q = t.value.length === 0;
|
|
1770
1831
|
try {
|
|
1771
|
-
(D =
|
|
1832
|
+
(D = S.onMessageSend) == null || D.call(S, { text: m, isFirstMessage: q, conversationId: a.value });
|
|
1772
1833
|
} catch {
|
|
1773
1834
|
}
|
|
1774
|
-
const
|
|
1835
|
+
const X = [
|
|
1775
1836
|
...t.value,
|
|
1776
|
-
{ type: "user", content:
|
|
1837
|
+
{ type: "user", content: m },
|
|
1777
1838
|
// streamed:标记该条由实时流产生,前端按序逐字揭示(后端批量转发,终态可能早于渲染)
|
|
1778
|
-
{ type: "ai", content: "", status:
|
|
1839
|
+
{ type: "ai", content: "", status: r.THINKING, streamed: !0 }
|
|
1779
1840
|
];
|
|
1780
|
-
t.value =
|
|
1781
|
-
const
|
|
1782
|
-
if (
|
|
1783
|
-
P.value =
|
|
1841
|
+
t.value = X, w.value = "", l();
|
|
1842
|
+
const L = X.length - 1;
|
|
1843
|
+
if (O) {
|
|
1844
|
+
P.value = m, await R(m, L);
|
|
1784
1845
|
return;
|
|
1785
1846
|
}
|
|
1786
1847
|
if (E.chatQueryStreamApi) {
|
|
1787
|
-
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await
|
|
1788
|
-
Query:
|
|
1848
|
+
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", E.chatQueryStreamApi), await f(E.chatQueryStreamApi, {
|
|
1849
|
+
Query: m,
|
|
1789
1850
|
AppConversationID: a.value,
|
|
1790
1851
|
ResponseMode: "streaming"
|
|
1791
|
-
},
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1852
|
+
}, L, x.first.signal), q && !I.value) {
|
|
1853
|
+
const c = t.value[L];
|
|
1854
|
+
c && c.status !== r.ERROR && V(m, c.content);
|
|
1794
1855
|
}
|
|
1795
1856
|
return;
|
|
1796
1857
|
}
|
|
1797
1858
|
console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
|
|
1798
1859
|
try {
|
|
1799
|
-
const
|
|
1800
|
-
app:
|
|
1801
|
-
data: { Query:
|
|
1802
|
-
}), T =
|
|
1860
|
+
const C = await tn().post(E.chatQueryApi, {
|
|
1861
|
+
app: S.app ?? 1,
|
|
1862
|
+
data: { Query: m, AppConversationID: a.value }
|
|
1863
|
+
}), T = nn(C.data);
|
|
1803
1864
|
t.value = [
|
|
1804
1865
|
...t.value.slice(0, -1),
|
|
1805
|
-
{ type: "ai", content: T || "未获取到回答内容,请稍后重试", status:
|
|
1806
|
-
],
|
|
1807
|
-
} catch (
|
|
1808
|
-
t.value = [...t.value.slice(0, -1), { type: "ai", content: (
|
|
1866
|
+
{ type: "ai", content: T || "未获取到回答内容,请稍后重试", status: r.COMPLETED }
|
|
1867
|
+
], q && !I.value && T && V(m, T);
|
|
1868
|
+
} catch (c) {
|
|
1869
|
+
t.value = [...t.value.slice(0, -1), { type: "ai", content: (c == null ? void 0 : c.message) || "服务连接失败,请稍后重试", status: r.ERROR }];
|
|
1809
1870
|
}
|
|
1810
1871
|
}
|
|
1811
1872
|
async function s() {
|
|
1812
1873
|
if (J()) {
|
|
1813
1874
|
if (!P.value || e.value) return;
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1875
|
+
const X = [...t.value];
|
|
1876
|
+
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 R(P.value, t.value.length - 1);
|
|
1816
1877
|
return;
|
|
1817
1878
|
}
|
|
1818
|
-
if (!
|
|
1879
|
+
if (!v.value || e.value) return;
|
|
1819
1880
|
x.again.abort(), x.again = new AbortController();
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
const
|
|
1823
|
-
await
|
|
1824
|
-
MessageID:
|
|
1881
|
+
const m = [...t.value];
|
|
1882
|
+
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();
|
|
1883
|
+
const O = t.value.length - 1, q = Mo(E);
|
|
1884
|
+
await f(q, {
|
|
1885
|
+
MessageID: v.value,
|
|
1825
1886
|
AppConversationID: a.value,
|
|
1826
1887
|
ResponseMode: "streaming"
|
|
1827
|
-
},
|
|
1888
|
+
}, O, x.again.signal, !0);
|
|
1828
1889
|
}
|
|
1829
|
-
async function
|
|
1830
|
-
var
|
|
1890
|
+
async function se() {
|
|
1891
|
+
var q;
|
|
1831
1892
|
if (!e.value) return;
|
|
1832
|
-
const
|
|
1893
|
+
const m = t.value.length - 1;
|
|
1833
1894
|
if (J()) {
|
|
1834
|
-
y++,
|
|
1835
|
-
const
|
|
1836
|
-
if (
|
|
1895
|
+
y++, N == null || N.abort(), N = null;
|
|
1896
|
+
const X = (q = We()) == null ? void 0 : q.api, L = Be(), D = Rt(L);
|
|
1897
|
+
if (X != null && X.stop && D)
|
|
1837
1898
|
try {
|
|
1838
|
-
await
|
|
1839
|
-
} catch (
|
|
1840
|
-
console.error("[ai-assist-sdk] page stop failed:",
|
|
1899
|
+
await X.stop({ module: L, threadId: D });
|
|
1900
|
+
} catch (C) {
|
|
1901
|
+
console.error("[ai-assist-sdk] page stop failed:", C);
|
|
1841
1902
|
}
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
-
...
|
|
1845
|
-
content:
|
|
1846
|
-
status:
|
|
1847
|
-
}), t.value =
|
|
1903
|
+
const c = [...t.value];
|
|
1904
|
+
c[m] && (c[m] = {
|
|
1905
|
+
...c[m],
|
|
1906
|
+
content: c[m].content || "已停止回答",
|
|
1907
|
+
status: r.STOP
|
|
1908
|
+
}), t.value = c, e.value = !1, g.value = !0;
|
|
1848
1909
|
return;
|
|
1849
1910
|
}
|
|
1850
|
-
if (
|
|
1911
|
+
if (v.value && E.stopMessageApi)
|
|
1851
1912
|
try {
|
|
1852
|
-
await
|
|
1853
|
-
} catch (
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1913
|
+
await rs(E, v.value);
|
|
1914
|
+
} catch (X) {
|
|
1915
|
+
const L = [...t.value];
|
|
1916
|
+
L[m] && (L[m] = { ...L[m], content: (X == null ? void 0 : X.message) || "系统繁忙,请稍后再试", status: r.ERROR }), t.value = L;
|
|
1856
1917
|
return;
|
|
1857
1918
|
}
|
|
1858
|
-
const
|
|
1859
|
-
|
|
1919
|
+
const O = [...t.value];
|
|
1920
|
+
O[m] && (O[m] = { ...O[m], content: O[m].content || "已停止回答", status: r.STOP }), t.value = O, e.value = !1, x.first.abort(), x.first = new AbortController(), x.again.abort(), x.again = new AbortController(), g.value = !0;
|
|
1860
1921
|
}
|
|
1861
|
-
async function
|
|
1862
|
-
var
|
|
1863
|
-
a.value =
|
|
1922
|
+
async function re(m) {
|
|
1923
|
+
var O;
|
|
1924
|
+
a.value = m, I.value = !0;
|
|
1864
1925
|
try {
|
|
1865
|
-
const
|
|
1866
|
-
for (const D of
|
|
1867
|
-
D.query &&
|
|
1868
|
-
t.value =
|
|
1869
|
-
} catch (
|
|
1870
|
-
|
|
1926
|
+
const q = await is(E, m), X = [], L = ls(q == null ? void 0 : q.messages);
|
|
1927
|
+
for (const D of L)
|
|
1928
|
+
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 });
|
|
1929
|
+
t.value = X, l();
|
|
1930
|
+
} catch (q) {
|
|
1931
|
+
Ie((q == null ? void 0 : q.message) || "加载历史会话失败");
|
|
1871
1932
|
}
|
|
1872
1933
|
}
|
|
1873
|
-
async function
|
|
1874
|
-
var
|
|
1934
|
+
async function de() {
|
|
1935
|
+
var m;
|
|
1875
1936
|
I.value = !1;
|
|
1876
1937
|
try {
|
|
1877
|
-
const
|
|
1878
|
-
(
|
|
1879
|
-
} catch (
|
|
1880
|
-
|
|
1938
|
+
const O = await en(E);
|
|
1939
|
+
(m = O == null ? void 0 : O.conversation) != null && m.appConversationID && (a.value = O.conversation.appConversationID);
|
|
1940
|
+
} catch (O) {
|
|
1941
|
+
Ie((O == null ? void 0 : O.message) || "创建会话失败");
|
|
1881
1942
|
}
|
|
1882
1943
|
}
|
|
1883
1944
|
function k() {
|
|
1884
|
-
a.value = "", I.value = !1, P.value = "", y++,
|
|
1945
|
+
a.value = "", I.value = !1, P.value = "", y++, N == null || N.abort(), N = null, os();
|
|
1885
1946
|
}
|
|
1886
1947
|
function Z() {
|
|
1887
|
-
y++,
|
|
1948
|
+
y++, N == null || N.abort(), N = null, e.value = !1, P.value = "", t.value = [], w.value = "", g.value = !0;
|
|
1888
1949
|
}
|
|
1889
1950
|
return {
|
|
1890
|
-
sendMessage:
|
|
1951
|
+
sendMessage: le,
|
|
1891
1952
|
regenerateResponse: s,
|
|
1892
|
-
toggleStop:
|
|
1893
|
-
goHistoryMessage:
|
|
1894
|
-
initConversation:
|
|
1953
|
+
toggleStop: se,
|
|
1954
|
+
goHistoryMessage: re,
|
|
1955
|
+
initConversation: de,
|
|
1895
1956
|
resetConversation: k,
|
|
1896
1957
|
clearMessagesKeepingThread: Z,
|
|
1897
1958
|
controllers: x
|
|
@@ -1901,27 +1962,27 @@ function xo({
|
|
|
1901
1962
|
cfg: t,
|
|
1902
1963
|
STATUS: w,
|
|
1903
1964
|
userInput: e,
|
|
1904
|
-
isActive:
|
|
1965
|
+
isActive: v,
|
|
1905
1966
|
scrollToBottom: a,
|
|
1906
|
-
onSessionTitle:
|
|
1967
|
+
onSessionTitle: f
|
|
1907
1968
|
}) {
|
|
1908
|
-
const
|
|
1909
|
-
let
|
|
1910
|
-
const
|
|
1911
|
-
() =>
|
|
1912
|
-
),
|
|
1969
|
+
const g = ns([]), l = _("");
|
|
1970
|
+
let r = 0;
|
|
1971
|
+
const S = $(
|
|
1972
|
+
() => g.value.find((k) => k.uid === l.value) ?? null
|
|
1973
|
+
), b = $(() => {
|
|
1913
1974
|
var k;
|
|
1914
|
-
return ((k =
|
|
1915
|
-
}), E =
|
|
1975
|
+
return ((k = S.value) == null ? void 0 : k.messages.value) ?? [];
|
|
1976
|
+
}), E = $(() => {
|
|
1916
1977
|
var k;
|
|
1917
|
-
return ((k =
|
|
1918
|
-
}), x =
|
|
1978
|
+
return ((k = S.value) == null ? void 0 : k.isGenerating.value) ?? !1;
|
|
1979
|
+
}), x = $(
|
|
1919
1980
|
() => {
|
|
1920
1981
|
var k;
|
|
1921
|
-
return (((k =
|
|
1982
|
+
return (((k = S.value) == null ? void 0 : k.messages.value.length) ?? 0) === 0;
|
|
1922
1983
|
}
|
|
1923
|
-
), I =
|
|
1924
|
-
() =>
|
|
1984
|
+
), I = $(
|
|
1985
|
+
() => g.value.filter((k) => !!k.conversationId.value).map((k) => ({
|
|
1925
1986
|
conversationId: k.conversationId.value,
|
|
1926
1987
|
title: k.title.value,
|
|
1927
1988
|
generating: k.isGenerating.value,
|
|
@@ -1929,81 +1990,81 @@ function xo({
|
|
|
1929
1990
|
}))
|
|
1930
1991
|
);
|
|
1931
1992
|
function P(k = "") {
|
|
1932
|
-
const Z = k || `draft-${++
|
|
1933
|
-
messages:
|
|
1934
|
-
isGenerating:
|
|
1935
|
-
lastUserMessage:
|
|
1936
|
-
batchMessagesUpdate:
|
|
1993
|
+
const Z = k || `draft-${++r}`, m = _([]), O = _(!1), q = _(""), X = _(k), L = _(""), D = _(Date.now()), c = /* @__PURE__ */ new Map(), { batchMessagesUpdate: C, flushMessagesBatch: T } = bo(m), { doStreamRequest: H, issTop: F } = So({
|
|
1994
|
+
messages: m,
|
|
1995
|
+
isGenerating: O,
|
|
1996
|
+
lastUserMessage: q,
|
|
1997
|
+
batchMessagesUpdate: C,
|
|
1937
1998
|
flushMessagesBatch: T,
|
|
1938
1999
|
STATUS: w,
|
|
1939
2000
|
cfg: t
|
|
1940
|
-
}),
|
|
1941
|
-
messages:
|
|
2001
|
+
}), Y = $o({
|
|
2002
|
+
messages: m,
|
|
1942
2003
|
userInput: e,
|
|
1943
|
-
isGenerating:
|
|
1944
|
-
lastUserMessage:
|
|
1945
|
-
conversationId:
|
|
1946
|
-
doStreamRequest: async (
|
|
2004
|
+
isGenerating: O,
|
|
2005
|
+
lastUserMessage: q,
|
|
2006
|
+
conversationId: X,
|
|
2007
|
+
doStreamRequest: async (ae, Q, B, W, ue) => {
|
|
1947
2008
|
D.value = Date.now();
|
|
1948
2009
|
try {
|
|
1949
|
-
return await
|
|
2010
|
+
return await H(ae, Q, B, W, ue);
|
|
1950
2011
|
} finally {
|
|
1951
2012
|
D.value = Date.now();
|
|
1952
2013
|
}
|
|
1953
2014
|
},
|
|
1954
|
-
issTop:
|
|
2015
|
+
issTop: F,
|
|
1955
2016
|
scrollToBottom: () => {
|
|
1956
|
-
|
|
2017
|
+
v(Z) && a();
|
|
1957
2018
|
},
|
|
1958
2019
|
STATUS: w,
|
|
1959
2020
|
cfg: t,
|
|
1960
|
-
onTitleGenerated: (
|
|
1961
|
-
|
|
2021
|
+
onTitleGenerated: (ae) => {
|
|
2022
|
+
L.value = ae, D.value = Date.now(), f == null || f(Z, ae);
|
|
1962
2023
|
}
|
|
1963
2024
|
});
|
|
1964
2025
|
return {
|
|
1965
2026
|
uid: Z,
|
|
1966
|
-
conversationId:
|
|
1967
|
-
messages:
|
|
1968
|
-
isGenerating:
|
|
1969
|
-
lastUserMessage:
|
|
1970
|
-
title:
|
|
2027
|
+
conversationId: X,
|
|
2028
|
+
messages: m,
|
|
2029
|
+
isGenerating: O,
|
|
2030
|
+
lastUserMessage: q,
|
|
2031
|
+
title: L,
|
|
1971
2032
|
updatedAt: D,
|
|
1972
|
-
reveal:
|
|
1973
|
-
sendMessage:
|
|
1974
|
-
regenerateResponse:
|
|
1975
|
-
toggleStop:
|
|
1976
|
-
loadHistory:
|
|
1977
|
-
resetConversation:
|
|
1978
|
-
clearMessages:
|
|
2033
|
+
reveal: c,
|
|
2034
|
+
sendMessage: Y.sendMessage,
|
|
2035
|
+
regenerateResponse: Y.regenerateResponse,
|
|
2036
|
+
toggleStop: Y.toggleStop,
|
|
2037
|
+
loadHistory: Y.goHistoryMessage,
|
|
2038
|
+
resetConversation: Y.resetConversation,
|
|
2039
|
+
clearMessages: Y.clearMessagesKeepingThread
|
|
1979
2040
|
};
|
|
1980
2041
|
}
|
|
1981
2042
|
function y(k) {
|
|
1982
|
-
|
|
2043
|
+
l.value = k, a();
|
|
1983
2044
|
}
|
|
1984
|
-
function
|
|
1985
|
-
let k =
|
|
2045
|
+
function N() {
|
|
2046
|
+
let k = g.value.find(
|
|
1986
2047
|
(Z) => !Z.conversationId.value && !Z.isGenerating.value && Z.messages.value.length === 0
|
|
1987
2048
|
);
|
|
1988
|
-
k || (k = P(""),
|
|
2049
|
+
k || (k = P(""), g.value = [...g.value, k]), k.resetConversation(), y(k.uid);
|
|
1989
2050
|
}
|
|
1990
2051
|
function J(k) {
|
|
1991
|
-
const Z =
|
|
2052
|
+
const Z = g.value.find((O) => O.conversationId.value === k);
|
|
1992
2053
|
if (Z) {
|
|
1993
2054
|
y(Z.uid);
|
|
1994
2055
|
return;
|
|
1995
2056
|
}
|
|
1996
|
-
const
|
|
1997
|
-
|
|
2057
|
+
const m = P(k);
|
|
2058
|
+
g.value = [...g.value, m], y(m.uid), m.loadHistory(k);
|
|
1998
2059
|
}
|
|
1999
2060
|
function R() {
|
|
2000
|
-
return
|
|
2061
|
+
return S.value;
|
|
2001
2062
|
}
|
|
2002
|
-
async function
|
|
2063
|
+
async function V() {
|
|
2003
2064
|
var k;
|
|
2004
2065
|
await ((k = R()) == null ? void 0 : k.sendMessage());
|
|
2005
2066
|
}
|
|
2006
|
-
async function
|
|
2067
|
+
async function le() {
|
|
2007
2068
|
var k;
|
|
2008
2069
|
await ((k = R()) == null ? void 0 : k.toggleStop());
|
|
2009
2070
|
}
|
|
@@ -2011,59 +2072,59 @@ function xo({
|
|
|
2011
2072
|
var k;
|
|
2012
2073
|
await ((k = R()) == null ? void 0 : k.regenerateResponse());
|
|
2013
2074
|
}
|
|
2014
|
-
function
|
|
2075
|
+
function se() {
|
|
2015
2076
|
var k;
|
|
2016
2077
|
(k = R()) == null || k.clearMessages();
|
|
2017
2078
|
}
|
|
2018
|
-
async function
|
|
2019
|
-
var
|
|
2020
|
-
if (
|
|
2021
|
-
const Z = k ??
|
|
2079
|
+
async function re(k) {
|
|
2080
|
+
var X;
|
|
2081
|
+
if (Ct() !== "page") return;
|
|
2082
|
+
const Z = k ?? S.value;
|
|
2022
2083
|
if (!Z || Z.messages.value.length) return;
|
|
2023
|
-
const
|
|
2024
|
-
if (!(
|
|
2025
|
-
const
|
|
2026
|
-
if (
|
|
2084
|
+
const m = (X = We()) == null ? void 0 : X.api;
|
|
2085
|
+
if (!(m != null && m.state)) return;
|
|
2086
|
+
const O = Be(), q = Rt(O);
|
|
2087
|
+
if (q)
|
|
2027
2088
|
try {
|
|
2028
|
-
const
|
|
2029
|
-
var
|
|
2030
|
-
return !(
|
|
2031
|
-
}).map((
|
|
2032
|
-
type:
|
|
2033
|
-
content:
|
|
2034
|
-
status:
|
|
2035
|
-
files:
|
|
2036
|
-
charts:
|
|
2089
|
+
const L = await m.state({ module: O, threadId: q }), D = ((L == null ? void 0 : L.messages) || []).filter((c) => {
|
|
2090
|
+
var C;
|
|
2091
|
+
return !(c.role === "assistant" && !c.content && !((C = c.charts) != null && C.length));
|
|
2092
|
+
}).map((c) => ({
|
|
2093
|
+
type: c.role === "user" ? "user" : "ai",
|
|
2094
|
+
content: c.content,
|
|
2095
|
+
status: c.role === "assistant" ? w.COMPLETED : void 0,
|
|
2096
|
+
files: c.role === "assistant" ? c.files ?? [] : void 0,
|
|
2097
|
+
charts: c.role === "assistant" ? c.charts ?? [] : void 0
|
|
2037
2098
|
}));
|
|
2038
2099
|
if (!D.length) return;
|
|
2039
|
-
Z.conversationId.value =
|
|
2040
|
-
} catch (
|
|
2041
|
-
console.warn("[ai-assist-sdk] 恢复页面会话失败:",
|
|
2100
|
+
Z.conversationId.value = L.threadId || q, Z.messages.value = D, v(Z.uid) && a();
|
|
2101
|
+
} catch (L) {
|
|
2102
|
+
console.warn("[ai-assist-sdk] 恢复页面会话失败:", L);
|
|
2042
2103
|
}
|
|
2043
2104
|
}
|
|
2044
|
-
const
|
|
2045
|
-
return
|
|
2046
|
-
sessions:
|
|
2047
|
-
activeUid:
|
|
2048
|
-
activeSession:
|
|
2049
|
-
messages:
|
|
2105
|
+
const de = P("");
|
|
2106
|
+
return g.value = [de], l.value = de.uid, re(de), {
|
|
2107
|
+
sessions: g,
|
|
2108
|
+
activeUid: l,
|
|
2109
|
+
activeSession: S,
|
|
2110
|
+
messages: b,
|
|
2050
2111
|
isGenerating: E,
|
|
2051
2112
|
isEmptyConversation: x,
|
|
2052
2113
|
sessionMetas: I,
|
|
2053
|
-
sendMessage:
|
|
2054
|
-
toggleStop:
|
|
2114
|
+
sendMessage: V,
|
|
2115
|
+
toggleStop: le,
|
|
2055
2116
|
regenerateResponse: s,
|
|
2056
2117
|
goHistoryMessage: J,
|
|
2057
|
-
createNewConversation:
|
|
2058
|
-
clearActiveMessages:
|
|
2118
|
+
createNewConversation: N,
|
|
2119
|
+
clearActiveMessages: se,
|
|
2059
2120
|
/** page 模式:打开侧栏时按 threadId 恢复历史(幂等,已有消息直接返回) */
|
|
2060
|
-
restorePageHistory:
|
|
2121
|
+
restorePageHistory: re
|
|
2061
2122
|
};
|
|
2062
2123
|
}
|
|
2063
2124
|
const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "message ai-message greet-message" }, Ao = { class: "ai-greet" }, Ro = ["src"], Po = {
|
|
2064
2125
|
key: 0,
|
|
2065
2126
|
class: "message ai-message recommend-message"
|
|
2066
|
-
}, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */
|
|
2127
|
+
}, Lo = { class: "ai-recommend" }, Ho = { class: "recommend-header" }, No = ["onClick"], Vo = /* @__PURE__ */ xe({
|
|
2067
2128
|
__name: "Answer",
|
|
2068
2129
|
props: {
|
|
2069
2130
|
defaultSayhello: {},
|
|
@@ -2071,7 +2132,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2071
2132
|
},
|
|
2072
2133
|
emits: ["title-generated", "sessions-change"],
|
|
2073
2134
|
setup(t, { expose: w, emit: e }) {
|
|
2074
|
-
const
|
|
2135
|
+
const v = {
|
|
2075
2136
|
THINKING: "thinking",
|
|
2076
2137
|
RETHINKING: "rethinking",
|
|
2077
2138
|
ANSWERING: "answering",
|
|
@@ -2079,135 +2140,135 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2079
2140
|
COMPLETED: "completed",
|
|
2080
2141
|
STOP: "stop",
|
|
2081
2142
|
ERROR: "error"
|
|
2082
|
-
}, a = t,
|
|
2083
|
-
() =>
|
|
2143
|
+
}, a = t, f = e, g = lt(), l = _(""), r = _(null), S = Oe({ text1: "", text2: "" }), b = _([]), E = _(0), x = $(
|
|
2144
|
+
() => b.value[E.value % (b.value.length || 1)]
|
|
2084
2145
|
);
|
|
2085
2146
|
function I() {
|
|
2086
2147
|
E.value++;
|
|
2087
2148
|
}
|
|
2088
|
-
const P =
|
|
2089
|
-
|
|
2149
|
+
const P = $(() => yn());
|
|
2150
|
+
pe(
|
|
2090
2151
|
() => a.defaultRecommend,
|
|
2091
|
-
(
|
|
2092
|
-
|
|
2152
|
+
(G) => {
|
|
2153
|
+
b.value = sn(G || []), E.value = 0;
|
|
2093
2154
|
},
|
|
2094
2155
|
{ deep: !0 }
|
|
2095
2156
|
);
|
|
2096
|
-
function y(
|
|
2097
|
-
|
|
2157
|
+
function y(G) {
|
|
2158
|
+
l.value = G;
|
|
2098
2159
|
}
|
|
2099
|
-
function
|
|
2100
|
-
|
|
2160
|
+
function N(G) {
|
|
2161
|
+
G && (l.value = G, O());
|
|
2101
2162
|
}
|
|
2102
|
-
const { isAtBottom: J, hasScroll: R, scrollToBottom:
|
|
2103
|
-
let
|
|
2163
|
+
const { isAtBottom: J, hasScroll: R, scrollToBottom: V, checkScrollStatus: le } = _o(r), { enhanceCodeBlocks: s } = Co();
|
|
2164
|
+
let se = (G) => !1;
|
|
2104
2165
|
const {
|
|
2105
|
-
activeSession:
|
|
2106
|
-
messages:
|
|
2166
|
+
activeSession: re,
|
|
2167
|
+
messages: de,
|
|
2107
2168
|
isGenerating: k,
|
|
2108
2169
|
isEmptyConversation: Z,
|
|
2109
|
-
sessionMetas:
|
|
2110
|
-
sendMessage:
|
|
2111
|
-
regenerateResponse:
|
|
2112
|
-
toggleStop:
|
|
2113
|
-
goHistoryMessage:
|
|
2170
|
+
sessionMetas: m,
|
|
2171
|
+
sendMessage: O,
|
|
2172
|
+
regenerateResponse: q,
|
|
2173
|
+
toggleStop: X,
|
|
2174
|
+
goHistoryMessage: L,
|
|
2114
2175
|
createNewConversation: D,
|
|
2115
|
-
clearActiveMessages:
|
|
2116
|
-
restorePageHistory:
|
|
2176
|
+
clearActiveMessages: c,
|
|
2177
|
+
restorePageHistory: C
|
|
2117
2178
|
} = xo({
|
|
2118
|
-
cfg:
|
|
2119
|
-
STATUS:
|
|
2120
|
-
userInput:
|
|
2121
|
-
isActive: (
|
|
2122
|
-
scrollToBottom:
|
|
2123
|
-
onSessionTitle: (
|
|
2124
|
-
|
|
2179
|
+
cfg: g,
|
|
2180
|
+
STATUS: v,
|
|
2181
|
+
userInput: l,
|
|
2182
|
+
isActive: (G) => se(G),
|
|
2183
|
+
scrollToBottom: V,
|
|
2184
|
+
onSessionTitle: (G, te) => {
|
|
2185
|
+
se(G) && f("title-generated", te);
|
|
2125
2186
|
}
|
|
2126
2187
|
});
|
|
2127
|
-
|
|
2188
|
+
se = (G) => {
|
|
2128
2189
|
var te;
|
|
2129
|
-
return ((te =
|
|
2130
|
-
},
|
|
2131
|
-
|
|
2132
|
-
}),
|
|
2133
|
-
function T(
|
|
2190
|
+
return ((te = re.value) == null ? void 0 : te.uid) === G;
|
|
2191
|
+
}, pe(re, (G) => {
|
|
2192
|
+
f("title-generated", (G == null ? void 0 : G.title.value) ?? "");
|
|
2193
|
+
}), pe(m, (G) => f("sessions-change", G), { immediate: !0 });
|
|
2194
|
+
function T(G, te) {
|
|
2134
2195
|
var fe;
|
|
2135
|
-
(fe =
|
|
2196
|
+
(fe = re.value) == null || fe.reveal.set(G, te);
|
|
2136
2197
|
}
|
|
2137
2198
|
w({
|
|
2138
|
-
goHistoryMessage:
|
|
2199
|
+
goHistoryMessage: L,
|
|
2139
2200
|
createNewConversation: D,
|
|
2140
|
-
clearActiveMessages:
|
|
2201
|
+
clearActiveMessages: c,
|
|
2141
2202
|
isEmptyConversation: Z,
|
|
2142
|
-
restorePageHistory:
|
|
2203
|
+
restorePageHistory: C
|
|
2143
2204
|
});
|
|
2144
|
-
const
|
|
2145
|
-
function
|
|
2146
|
-
|
|
2147
|
-
}
|
|
2148
|
-
de
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
s(
|
|
2152
|
-
}),
|
|
2205
|
+
const H = _(/* @__PURE__ */ new Map());
|
|
2206
|
+
function F(G, te) {
|
|
2207
|
+
G ? H.value.set(te, G) : H.value.delete(te);
|
|
2208
|
+
}
|
|
2209
|
+
pe(de, () => {
|
|
2210
|
+
De(() => {
|
|
2211
|
+
H.value.forEach((G) => {
|
|
2212
|
+
s(G);
|
|
2213
|
+
}), le();
|
|
2153
2214
|
});
|
|
2154
2215
|
}, { deep: !0 });
|
|
2155
|
-
let
|
|
2156
|
-
|
|
2157
|
-
a.defaultSayhello && (
|
|
2158
|
-
}),
|
|
2159
|
-
|
|
2216
|
+
let u = null;
|
|
2217
|
+
Ne(() => {
|
|
2218
|
+
a.defaultSayhello && (S.text1 = a.defaultSayhello.text1, S.text2 = a.defaultSayhello.text2), a.defaultRecommend && (b.value = sn(a.defaultRecommend));
|
|
2219
|
+
}), Ne(() => {
|
|
2220
|
+
r.value && (u = () => le(), r.value.addEventListener("scroll", u), le());
|
|
2160
2221
|
});
|
|
2161
|
-
const
|
|
2162
|
-
let
|
|
2163
|
-
function
|
|
2222
|
+
const p = _(null);
|
|
2223
|
+
let Y = !1, ae = 0, Q = 0;
|
|
2224
|
+
function B(G) {
|
|
2164
2225
|
var fe;
|
|
2165
|
-
const te = (fe =
|
|
2166
|
-
return parseFloat((te == null ? void 0 : te.style.getPropertyValue(
|
|
2226
|
+
const te = (fe = r.value) == null ? void 0 : fe.closest(".chat-wrap");
|
|
2227
|
+
return parseFloat((te == null ? void 0 : te.style.getPropertyValue(G)) ?? "") || 0;
|
|
2167
2228
|
}
|
|
2168
|
-
function W(
|
|
2169
|
-
return "touches" in
|
|
2229
|
+
function W(G) {
|
|
2230
|
+
return "touches" in G ? G.touches[0].clientY : G.clientY;
|
|
2170
2231
|
}
|
|
2171
|
-
function
|
|
2172
|
-
const te =
|
|
2173
|
-
te && (
|
|
2232
|
+
function ue(G) {
|
|
2233
|
+
const te = r.value;
|
|
2234
|
+
te && (G.preventDefault(), Y = !0, ae = W(G), te.scrollTop, Q = B("--ai-thumb-top"), window.addEventListener("mousemove", j), window.addEventListener("mouseup", ve), window.addEventListener("touchmove", j, { passive: !1 }), window.addEventListener("touchend", ve));
|
|
2174
2235
|
}
|
|
2175
|
-
function
|
|
2176
|
-
const te =
|
|
2177
|
-
if (!
|
|
2178
|
-
|
|
2179
|
-
const fe = W(
|
|
2180
|
-
te.scrollTop =
|
|
2236
|
+
function j(G) {
|
|
2237
|
+
const te = r.value;
|
|
2238
|
+
if (!Y || !te) return;
|
|
2239
|
+
G.preventDefault();
|
|
2240
|
+
const fe = W(G) - ae, A = te.clientHeight, ee = te.scrollHeight, ne = B("--ai-thumb-height"), oe = A - ne, ye = Math.min(Math.max(Q + fe, 0), oe);
|
|
2241
|
+
te.scrollTop = ye / oe * (ee - A);
|
|
2181
2242
|
}
|
|
2182
|
-
function
|
|
2183
|
-
|
|
2243
|
+
function ve() {
|
|
2244
|
+
Y = !1, window.removeEventListener("mousemove", j), window.removeEventListener("mouseup", ve), window.removeEventListener("touchmove", j), window.removeEventListener("touchend", ve);
|
|
2184
2245
|
}
|
|
2185
|
-
function
|
|
2186
|
-
const te =
|
|
2246
|
+
function me(G) {
|
|
2247
|
+
const te = r.value, fe = p.value;
|
|
2187
2248
|
if (!te || !fe) return;
|
|
2188
|
-
|
|
2189
|
-
const
|
|
2190
|
-
te.scrollTop =
|
|
2249
|
+
G.preventDefault();
|
|
2250
|
+
const A = fe.getBoundingClientRect(), ne = (W(G) - A.top) / A.height;
|
|
2251
|
+
te.scrollTop = ne * (te.scrollHeight - te.clientHeight);
|
|
2191
2252
|
}
|
|
2192
|
-
return
|
|
2193
|
-
|
|
2194
|
-
}), (
|
|
2253
|
+
return Fe(() => {
|
|
2254
|
+
r.value && u && r.value.removeEventListener("scroll", u), ve();
|
|
2255
|
+
}), (G, te) => {
|
|
2195
2256
|
var fe;
|
|
2196
|
-
return i(),
|
|
2257
|
+
return i(), h("div", To, [
|
|
2197
2258
|
o("div", Do, [
|
|
2198
2259
|
o("div", {
|
|
2199
2260
|
class: "chat-box scrollWrap",
|
|
2200
2261
|
ref_key: "chatBoxRef",
|
|
2201
|
-
ref:
|
|
2262
|
+
ref: r
|
|
2202
2263
|
}, [
|
|
2203
2264
|
o("div", Eo, [
|
|
2204
2265
|
o("div", Ao, [
|
|
2205
|
-
o("img", { src:
|
|
2206
|
-
o("h1", null, U(
|
|
2207
|
-
o("p", null, U(
|
|
2266
|
+
o("img", { src: ie(_n) }, null, 8, Ro),
|
|
2267
|
+
o("h1", null, U(S.text1), 1),
|
|
2268
|
+
o("p", null, U(S.text2), 1)
|
|
2208
2269
|
])
|
|
2209
2270
|
]),
|
|
2210
|
-
(fe = x.value) != null && fe.length && (!P.value ||
|
|
2271
|
+
(fe = x.value) != null && fe.length && (!P.value || ie(de).length === 0) ? (i(), h("div", Po, [
|
|
2211
2272
|
o("div", Lo, [
|
|
2212
2273
|
o("div", Ho, [
|
|
2213
2274
|
te[2] || (te[2] = o("span", null, "你可以尝试这样问我:", -1)),
|
|
@@ -2215,7 +2276,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2215
2276
|
class: "refresh-btn",
|
|
2216
2277
|
onClick: I
|
|
2217
2278
|
}, [
|
|
2218
|
-
|
|
2279
|
+
Ce(Ee, {
|
|
2219
2280
|
name: "refresh",
|
|
2220
2281
|
class: "refresh-icon"
|
|
2221
2282
|
}),
|
|
@@ -2223,53 +2284,53 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2223
2284
|
])
|
|
2224
2285
|
]),
|
|
2225
2286
|
o("ul", null, [
|
|
2226
|
-
(i(!0),
|
|
2227
|
-
key:
|
|
2228
|
-
onClick: (
|
|
2229
|
-
}, U(
|
|
2287
|
+
(i(!0), h(be, null, He(x.value, (A, ee) => (i(), h("li", {
|
|
2288
|
+
key: ee,
|
|
2289
|
+
onClick: (ne) => y(A)
|
|
2290
|
+
}, U(A), 9, No))), 128))
|
|
2230
2291
|
])
|
|
2231
2292
|
])
|
|
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: (
|
|
2293
|
+
])) : z("", !0),
|
|
2294
|
+
(i(!0), h(be, null, He(ie(de), (A, ee) => {
|
|
2295
|
+
var ne, oe;
|
|
2296
|
+
return i(), _e(ao, {
|
|
2297
|
+
key: `${((ne = ie(re)) == null ? void 0 : ne.uid) ?? ""}-${ee}`,
|
|
2298
|
+
msg: A,
|
|
2299
|
+
index: ee,
|
|
2300
|
+
STATUS: v,
|
|
2301
|
+
setMessageRef: F,
|
|
2302
|
+
scrollToBottom: ie(V),
|
|
2303
|
+
initialReveal: (oe = ie(re)) == null ? void 0 : oe.reveal.get(ee),
|
|
2304
|
+
onRegenerate: ie(q),
|
|
2305
|
+
onAsk: N,
|
|
2306
|
+
onRevealProgress: (ye) => T(ee, ye)
|
|
2246
2307
|
}, null, 8, ["msg", "index", "scrollToBottom", "initialReveal", "onRegenerate", "onRevealProgress"]);
|
|
2247
2308
|
}), 128))
|
|
2248
2309
|
], 512),
|
|
2249
2310
|
o("div", {
|
|
2250
2311
|
ref_key: "scrollbarRef",
|
|
2251
|
-
ref:
|
|
2312
|
+
ref: p,
|
|
2252
2313
|
class: "chat-box__scrollbar",
|
|
2253
|
-
onMousedown:
|
|
2254
|
-
onTouchstart:
|
|
2314
|
+
onMousedown: Ve(me, ["prevent"]),
|
|
2315
|
+
onTouchstart: Ve(me, ["prevent"])
|
|
2255
2316
|
}, [
|
|
2256
2317
|
o("div", {
|
|
2257
2318
|
class: "chat-box__scrollbar-thumb",
|
|
2258
|
-
onMousedown:
|
|
2259
|
-
onTouchstart:
|
|
2319
|
+
onMousedown: Ve(ue, ["stop", "prevent"]),
|
|
2320
|
+
onTouchstart: Ve(ue, ["stop", "prevent"])
|
|
2260
2321
|
}, null, 32)
|
|
2261
2322
|
], 544)
|
|
2262
2323
|
]),
|
|
2263
|
-
|
|
2264
|
-
modelValue:
|
|
2265
|
-
"onUpdate:modelValue": te[0] || (te[0] = (
|
|
2266
|
-
isGenerating:
|
|
2267
|
-
hasScroll:
|
|
2268
|
-
isAtBottom:
|
|
2269
|
-
onSend:
|
|
2270
|
-
onRegenerate:
|
|
2271
|
-
onStop:
|
|
2272
|
-
onScrollToBottom:
|
|
2324
|
+
Ce(ko, {
|
|
2325
|
+
modelValue: l.value,
|
|
2326
|
+
"onUpdate:modelValue": te[0] || (te[0] = (A) => l.value = A),
|
|
2327
|
+
isGenerating: ie(k),
|
|
2328
|
+
hasScroll: ie(R),
|
|
2329
|
+
isAtBottom: ie(J),
|
|
2330
|
+
onSend: ie(O),
|
|
2331
|
+
onRegenerate: ie(q),
|
|
2332
|
+
onStop: ie(X),
|
|
2333
|
+
onScrollToBottom: ie(V)
|
|
2273
2334
|
}, null, 8, ["modelValue", "isGenerating", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
|
|
2274
2335
|
te[3] || (te[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
|
|
2275
2336
|
]);
|
|
@@ -2278,29 +2339,29 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2278
2339
|
}), Oo = { class: "ai-history" }, Wo = { class: "content" }, Bo = {
|
|
2279
2340
|
key: 0,
|
|
2280
2341
|
class: "ai-history-loading"
|
|
2281
|
-
}, Fo = { class: "ai-history-group-title" },
|
|
2342
|
+
}, Fo = { class: "ai-history-group-title" }, Io = ["onClick"], Xo = { class: "ai-history-item-title" }, zo = {
|
|
2282
2343
|
key: 0,
|
|
2283
2344
|
class: "ai-history-item-badge"
|
|
2284
2345
|
}, qo = ["onClick"], Go = {
|
|
2285
2346
|
key: 2,
|
|
2286
2347
|
class: "ai-history-empty"
|
|
2287
|
-
}, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */
|
|
2348
|
+
}, Ko = ["src"], Yo = { class: "ai-modal" }, Qo = { class: "ai-modal-footer" }, jo = /* @__PURE__ */ xe({
|
|
2288
2349
|
__name: "History",
|
|
2289
2350
|
props: {
|
|
2290
2351
|
localSessions: {}
|
|
2291
2352
|
},
|
|
2292
2353
|
emits: ["history-detail", "new-conversation"],
|
|
2293
2354
|
setup(t, { emit: w }) {
|
|
2294
|
-
const e = t, a =
|
|
2295
|
-
const P =
|
|
2355
|
+
const e = t, a = lt().apis, f = _([]), g = _(!0), l = _(!1), r = _(""), S = $(() => {
|
|
2356
|
+
const P = f.value.map((y) => ({ ...y }));
|
|
2296
2357
|
for (const y of e.localSessions ?? []) {
|
|
2297
2358
|
if (!y.conversationId) continue;
|
|
2298
|
-
const
|
|
2299
|
-
if (
|
|
2300
|
-
P[
|
|
2301
|
-
...P[
|
|
2359
|
+
const N = P.findIndex((R) => R.appConversationID === y.conversationId);
|
|
2360
|
+
if (N >= 0) {
|
|
2361
|
+
P[N] = {
|
|
2362
|
+
...P[N],
|
|
2302
2363
|
// 本地标题(标题生成完成)优先于服务端默认名
|
|
2303
|
-
conversationName: y.title || P[
|
|
2364
|
+
conversationName: y.title || P[N].conversationName,
|
|
2304
2365
|
generating: y.generating
|
|
2305
2366
|
};
|
|
2306
2367
|
continue;
|
|
@@ -2322,70 +2383,70 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2322
2383
|
}
|
|
2323
2384
|
return P.map((y) => ({
|
|
2324
2385
|
...y,
|
|
2325
|
-
conversationName:
|
|
2386
|
+
conversationName: vs(y.conversationName) ? "新的对话" : y.conversationName
|
|
2326
2387
|
}));
|
|
2327
|
-
}),
|
|
2388
|
+
}), b = $(() => hs(S.value));
|
|
2328
2389
|
async function E() {
|
|
2329
2390
|
try {
|
|
2330
|
-
const P = await
|
|
2331
|
-
P != null && P.conversationList && (
|
|
2391
|
+
const P = await fs(a);
|
|
2392
|
+
P != null && P.conversationList && (f.value = P.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
|
|
2332
2393
|
} catch (P) {
|
|
2333
|
-
|
|
2394
|
+
Ie((P == null ? void 0 : P.message) || "获取历史记录失败");
|
|
2334
2395
|
} finally {
|
|
2335
|
-
|
|
2396
|
+
g.value = !1;
|
|
2336
2397
|
}
|
|
2337
2398
|
}
|
|
2338
2399
|
function x(P) {
|
|
2339
|
-
|
|
2400
|
+
r.value = P, l.value = !0;
|
|
2340
2401
|
}
|
|
2341
2402
|
async function I() {
|
|
2342
|
-
|
|
2403
|
+
l.value = !1;
|
|
2343
2404
|
try {
|
|
2344
|
-
await
|
|
2405
|
+
await ms(a, r.value), await E();
|
|
2345
2406
|
} catch (P) {
|
|
2346
|
-
|
|
2407
|
+
Ie((P == null ? void 0 : P.message) || "删除失败"), await E();
|
|
2347
2408
|
}
|
|
2348
2409
|
}
|
|
2349
|
-
return
|
|
2410
|
+
return Ne(() => {
|
|
2350
2411
|
E();
|
|
2351
|
-
}), (P, y) => (i(),
|
|
2412
|
+
}), (P, y) => (i(), h("div", Oo, [
|
|
2352
2413
|
o("div", Wo, [
|
|
2353
|
-
|
|
2414
|
+
g.value ? (i(), h("div", Bo, [...y[3] || (y[3] = [
|
|
2354
2415
|
o("div", { class: "ai-history-spinner" }, null, -1)
|
|
2355
|
-
])])) :
|
|
2356
|
-
key:
|
|
2416
|
+
])])) : b.value.length > 0 ? (i(!0), h(be, { key: 1 }, He(b.value, (N) => (i(), h("div", {
|
|
2417
|
+
key: N.label,
|
|
2357
2418
|
class: "ai-history-group"
|
|
2358
2419
|
}, [
|
|
2359
|
-
o("div", Fo, U(
|
|
2360
|
-
(i(!0),
|
|
2420
|
+
o("div", Fo, U(N.label), 1),
|
|
2421
|
+
(i(!0), h(be, null, He(N.items, (J, R) => (i(), h("div", {
|
|
2361
2422
|
key: J.appConversationID,
|
|
2362
2423
|
class: "ai-history-item",
|
|
2363
|
-
style:
|
|
2364
|
-
onClick: (
|
|
2424
|
+
style: kt({ "--i": R }),
|
|
2425
|
+
onClick: (V) => P.$emit("history-detail", J.appConversationID)
|
|
2365
2426
|
}, [
|
|
2366
|
-
o("div",
|
|
2367
|
-
|
|
2368
|
-
J.generating ? (i(),
|
|
2427
|
+
o("div", Xo, [
|
|
2428
|
+
fn(U(J.conversationName) + " ", 1),
|
|
2429
|
+
J.generating ? (i(), h("span", zo, "生成中")) : z("", !0)
|
|
2369
2430
|
]),
|
|
2370
2431
|
o("div", {
|
|
2371
2432
|
class: "ai-history-item-delete",
|
|
2372
|
-
onClick:
|
|
2433
|
+
onClick: Ve((V) => x(J.appConversationID), ["stop"])
|
|
2373
2434
|
}, "删除", 8, qo)
|
|
2374
|
-
], 12,
|
|
2375
|
-
]))), 128)) : (i(),
|
|
2435
|
+
], 12, Io))), 128))
|
|
2436
|
+
]))), 128)) : (i(), h("div", Go, "暂无历史记录"))
|
|
2376
2437
|
]),
|
|
2377
2438
|
o("div", {
|
|
2378
2439
|
class: "ai-add",
|
|
2379
|
-
onClick: y[0] || (y[0] = (
|
|
2440
|
+
onClick: y[0] || (y[0] = (N) => P.$emit("new-conversation"))
|
|
2380
2441
|
}, [
|
|
2381
|
-
o("img", { src:
|
|
2442
|
+
o("img", { src: ie(Rs) }, null, 8, Ko),
|
|
2382
2443
|
y[4] || (y[4] = o("span", null, "新建AI对话", -1))
|
|
2383
2444
|
]),
|
|
2384
|
-
(i(),
|
|
2385
|
-
|
|
2445
|
+
(i(), _e(mn, { to: "#ai-assist-root" }, [
|
|
2446
|
+
l.value ? (i(), h("div", {
|
|
2386
2447
|
key: 0,
|
|
2387
2448
|
class: "ai-modal-overlay",
|
|
2388
|
-
onClick: y[2] || (y[2] =
|
|
2449
|
+
onClick: y[2] || (y[2] = Ve((N) => l.value = !1, ["self"]))
|
|
2389
2450
|
}, [
|
|
2390
2451
|
o("div", Yo, [
|
|
2391
2452
|
y[5] || (y[5] = o("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
|
|
@@ -2393,7 +2454,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2393
2454
|
o("div", Qo, [
|
|
2394
2455
|
o("button", {
|
|
2395
2456
|
class: "ai-modal-btn cancel",
|
|
2396
|
-
onClick: y[1] || (y[1] = (
|
|
2457
|
+
onClick: y[1] || (y[1] = (N) => l.value = !1)
|
|
2397
2458
|
}, "取消"),
|
|
2398
2459
|
o("button", {
|
|
2399
2460
|
class: "ai-modal-btn confirm",
|
|
@@ -2401,23 +2462,23 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2401
2462
|
}, "确定")
|
|
2402
2463
|
])
|
|
2403
2464
|
])
|
|
2404
|
-
])) :
|
|
2465
|
+
])) : z("", !0)
|
|
2405
2466
|
]))
|
|
2406
2467
|
]));
|
|
2407
2468
|
}
|
|
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__ */
|
|
2469
|
+
}), 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__ */ xe({
|
|
2409
2470
|
__name: "Info",
|
|
2410
2471
|
setup(t) {
|
|
2411
|
-
const w =
|
|
2412
|
-
return
|
|
2472
|
+
const w = lt(), e = _(null);
|
|
2473
|
+
return Ne(async () => {
|
|
2413
2474
|
try {
|
|
2414
|
-
e.value = await
|
|
2415
|
-
} catch (
|
|
2416
|
-
|
|
2475
|
+
e.value = await gs(w.apis);
|
|
2476
|
+
} catch (v) {
|
|
2477
|
+
Ie((v == null ? void 0 : v.message) || "获取个人信息失败");
|
|
2417
2478
|
}
|
|
2418
|
-
}), (
|
|
2419
|
-
var
|
|
2420
|
-
return i(),
|
|
2479
|
+
}), (v, a) => {
|
|
2480
|
+
var f, g, l, r, S;
|
|
2481
|
+
return i(), h("div", Jo, [
|
|
2421
2482
|
o("div", Zo, [
|
|
2422
2483
|
a[2] || (a[2] = o("div", { class: "heading" }, [
|
|
2423
2484
|
o("div", { class: "heading-column" }),
|
|
@@ -2425,11 +2486,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2425
2486
|
], -1)),
|
|
2426
2487
|
o("div", Uo, [
|
|
2427
2488
|
a[0] || (a[0] = o("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
|
|
2428
|
-
o("div", ei, U(((
|
|
2489
|
+
o("div", ei, U(((f = e.value) == null ? void 0 : f.name) || ""), 1)
|
|
2429
2490
|
]),
|
|
2430
2491
|
o("div", ti, [
|
|
2431
2492
|
a[1] || (a[1] = o("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
|
|
2432
|
-
o("div", ni, U(((
|
|
2493
|
+
o("div", ni, U(((g = e.value) == null ? void 0 : g.userName) || ""), 1)
|
|
2433
2494
|
])
|
|
2434
2495
|
]),
|
|
2435
2496
|
o("div", si, [
|
|
@@ -2438,10 +2499,10 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2438
2499
|
o("div", { class: "heading-title" }, "数据权限")
|
|
2439
2500
|
], -1)),
|
|
2440
2501
|
o("div", ai, [
|
|
2441
|
-
(i(!0),
|
|
2502
|
+
(i(!0), h(be, null, He((l = e.value) == null ? void 0 : l.ptnameList, (b, E) => (i(), h("div", {
|
|
2442
2503
|
key: E,
|
|
2443
2504
|
class: "permission-content-text"
|
|
2444
|
-
}, U(
|
|
2505
|
+
}, U(b), 1))), 128))
|
|
2445
2506
|
])
|
|
2446
2507
|
]),
|
|
2447
2508
|
o("div", oi, [
|
|
@@ -2451,11 +2512,11 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2451
2512
|
], -1)),
|
|
2452
2513
|
o("div", ii, [
|
|
2453
2514
|
a[4] || (a[4] = o("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
|
|
2454
|
-
o("div", li, U(((
|
|
2515
|
+
o("div", li, U(((r = e.value) == null ? void 0 : r.dept) || ""), 1)
|
|
2455
2516
|
]),
|
|
2456
2517
|
o("div", ri, [
|
|
2457
2518
|
a[5] || (a[5] = o("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
|
|
2458
|
-
o("div", ui, U(((
|
|
2519
|
+
o("div", ui, U(((S = e.value) == null ? void 0 : S.email) || ""), 1)
|
|
2459
2520
|
])
|
|
2460
2521
|
])
|
|
2461
2522
|
]);
|
|
@@ -2464,219 +2525,219 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2464
2525
|
}), di = {
|
|
2465
2526
|
key: 0,
|
|
2466
2527
|
class: "ai-context-chips"
|
|
2467
|
-
}, vi = ["title"], hi = /* @__PURE__ */
|
|
2528
|
+
}, vi = ["title"], hi = /* @__PURE__ */ xe({
|
|
2468
2529
|
__name: "AiContextChips",
|
|
2469
2530
|
props: {
|
|
2470
2531
|
context: {}
|
|
2471
2532
|
},
|
|
2472
2533
|
setup(t) {
|
|
2473
|
-
const w = t, e =
|
|
2474
|
-
const
|
|
2475
|
-
return a.platform &&
|
|
2534
|
+
const w = t, e = $(() => {
|
|
2535
|
+
const v = w.context || {}, a = v.filters || {}, f = v.status || {}, g = v.summary || {}, l = [];
|
|
2536
|
+
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
2537
|
});
|
|
2477
|
-
return (
|
|
2478
|
-
(i(!0),
|
|
2479
|
-
key:
|
|
2538
|
+
return (v, a) => e.value.length ? (i(), h("div", di, [
|
|
2539
|
+
(i(!0), h(be, null, He(e.value, (f, g) => (i(), h("span", {
|
|
2540
|
+
key: g,
|
|
2480
2541
|
class: "ai-context-chip",
|
|
2481
|
-
title:
|
|
2482
|
-
}, U(
|
|
2483
|
-
])) :
|
|
2542
|
+
title: f
|
|
2543
|
+
}, U(f), 9, vi))), 128))
|
|
2544
|
+
])) : z("", !0);
|
|
2484
2545
|
}
|
|
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" },
|
|
2546
|
+
}), 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" }, Si = ["src"], Mi = 78, st = 78, Le = 8, at = 26, ze = 490, dn = "aiPanelPosition", vn = "aiPanelDocked", $i = "aiDockWidth", xi = 60, Ti = 150, hn = 400, Di = 320, Ei = "aiDockWidth:page", Sn = /* @__PURE__ */ xe({
|
|
2486
2547
|
__name: "AiAssist",
|
|
2487
2548
|
setup(t) {
|
|
2488
|
-
var
|
|
2489
|
-
const w =
|
|
2490
|
-
var
|
|
2549
|
+
var Zt, Ut;
|
|
2550
|
+
const w = Mi / 2, e = lt(), v = _(Ct()), a = $(() => v.value === "page"), f = _({}), g = $(() => {
|
|
2551
|
+
var M, K, ce;
|
|
2491
2552
|
const n = e.name || "AI 助手";
|
|
2492
|
-
return a.value ? ((
|
|
2493
|
-
}),
|
|
2494
|
-
var
|
|
2553
|
+
return a.value ? ((K = (M = e.pageMode) == null ? void 0 : M.titles) == null ? void 0 : K[Be()]) || ((ce = e.pageMode) == null ? void 0 : ce.title) || n || "AI 助手" : n;
|
|
2554
|
+
}), l = $(() => {
|
|
2555
|
+
var d, M;
|
|
2495
2556
|
if (!a.value) return e.defaultRecommend;
|
|
2496
|
-
const n = (
|
|
2557
|
+
const n = (M = (d = e.pageMode) == null ? void 0 : d.recommend) == null ? void 0 : M[Be()];
|
|
2497
2558
|
return n != null && n.length ? n : e.defaultRecommend;
|
|
2498
2559
|
});
|
|
2499
|
-
let
|
|
2500
|
-
const
|
|
2560
|
+
let r = "", S = Be();
|
|
2561
|
+
const b = _(!1);
|
|
2501
2562
|
let E = null;
|
|
2502
|
-
const x = _(!1), I = _("idle"), P = _(!1), y =
|
|
2563
|
+
const x = _(!1), I = _("idle"), P = _(!1), y = Oe({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), N = _(!1), J = _(window.innerWidth < 768), R = _(window.innerWidth < 768), V = _("answer"), le = _(!1), s = _(""), se = _(""), re = _(""), de = _(!1), k = _(!1), Z = _([]), m = Oe({
|
|
2503
2564
|
x: window.innerWidth - w,
|
|
2504
|
-
y: window.innerHeight / 2 -
|
|
2505
|
-
}),
|
|
2565
|
+
y: window.innerHeight / 2 - st / 2
|
|
2566
|
+
}), O = _(!1), q = _(!1), X = _("right"), L = _("left"), D = _(null), c = Oe({ x: 0, y: 0 }), C = _(!1), T = _(!1), H = Oe({ x: 0, y: 0 }), F = _(!1), u = Oe({ x: 0, y: 0 }), p = _(!1), Y = _(!1), ae = _(!1), Q = Oe({ x: 0, width: 0 }), B = _(!1);
|
|
2506
2567
|
let W = 0;
|
|
2507
|
-
const
|
|
2508
|
-
let
|
|
2509
|
-
const
|
|
2510
|
-
let
|
|
2511
|
-
const
|
|
2568
|
+
const ue = _("idle"), j = _(!1), ve = _("none"), me = Oe({ x: 0, y: 0, w: ze, h: 0, radius: "14px" });
|
|
2569
|
+
let G = null, te = !1, fe = !1;
|
|
2570
|
+
const A = Oe({ x: 0, y: 0 }), ee = _(!1), ne = _(null);
|
|
2571
|
+
let oe = null, ye = null, Re = null;
|
|
2572
|
+
const $e = $(() => {
|
|
2512
2573
|
const n = window.innerWidth / 2;
|
|
2513
|
-
return
|
|
2514
|
-
}),
|
|
2574
|
+
return m.x + w < n ? 5 : -5;
|
|
2575
|
+
}), Te = $(() => R.value || p.value || a.value || ue.value !== "idle" ? "" : `panel-${X.value}`), Se = $(() => {
|
|
2515
2576
|
var n;
|
|
2516
2577
|
return !!((n = e.dock) != null && n.containerId) && !J.value;
|
|
2517
|
-
}),
|
|
2518
|
-
a.value ? ((
|
|
2519
|
-
),
|
|
2578
|
+
}), we = _(
|
|
2579
|
+
a.value ? ((Zt = e.pageMode) == null ? void 0 : Zt.width) || 440 : ((Ut = e.dock) == null ? void 0 : Ut.width) || ze
|
|
2580
|
+
), Ht = () => a.value ? Ei : $i, Nt = $(() => e.panelDraggable !== !1), Mn = $(() => {
|
|
2520
2581
|
var n;
|
|
2521
|
-
return !((n =
|
|
2522
|
-
}), $n =
|
|
2523
|
-
left: `${
|
|
2524
|
-
top: `${
|
|
2525
|
-
transition:
|
|
2526
|
-
"--direction": String(
|
|
2527
|
-
})),
|
|
2582
|
+
return !((n = ne.value) != null && n.isEmptyConversation);
|
|
2583
|
+
}), $n = $(() => ({
|
|
2584
|
+
left: `${m.x}px`,
|
|
2585
|
+
top: `${m.y}px`,
|
|
2586
|
+
transition: O.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
|
|
2587
|
+
"--direction": String($e.value)
|
|
2588
|
+
})), xn = $(() => e.characterImage || Ps), Tn = $(() => I.value === "idle" ? {} : {
|
|
2528
2589
|
left: `${y.x}px`,
|
|
2529
2590
|
top: `${y.y}px`,
|
|
2530
2591
|
width: `${y.w}px`,
|
|
2531
2592
|
height: `${y.h}px`,
|
|
2532
2593
|
borderRadius: y.radius
|
|
2533
|
-
}),
|
|
2594
|
+
}), Dn = $(() => {
|
|
2534
2595
|
const n = {};
|
|
2535
|
-
return
|
|
2536
|
-
}),
|
|
2537
|
-
left: `${
|
|
2538
|
-
top: `${
|
|
2539
|
-
width: `${
|
|
2540
|
-
height: `${
|
|
2541
|
-
borderRadius:
|
|
2596
|
+
return C.value && !R.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"] = `${we.value}px`), n;
|
|
2597
|
+
}), En = $(() => ue.value === "idle" ? {} : {
|
|
2598
|
+
left: `${me.x}px`,
|
|
2599
|
+
top: `${me.y}px`,
|
|
2600
|
+
width: `${me.w}px`,
|
|
2601
|
+
height: `${me.h}px`,
|
|
2602
|
+
borderRadius: me.radius
|
|
2542
2603
|
});
|
|
2543
|
-
function
|
|
2604
|
+
function Ye() {
|
|
2544
2605
|
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 };
|
|
2606
|
+
m.x + w < n ? (X.value = "left", L.value = "right") : (X.value = "right", L.value = "left");
|
|
2550
2607
|
}
|
|
2551
|
-
function
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2608
|
+
function An() {
|
|
2609
|
+
const n = window.innerWidth, d = Math.max(0, Math.min(m.y, window.innerHeight - st));
|
|
2610
|
+
return { x: m.x + w >= n / 2 ? n - w : -w, y: d };
|
|
2611
|
+
}
|
|
2612
|
+
function Vt() {
|
|
2613
|
+
q.value = !0;
|
|
2614
|
+
const n = An();
|
|
2615
|
+
m.x = n.x, m.y = n.y, setTimeout(() => {
|
|
2616
|
+
q.value = !1, Ye(), Rn();
|
|
2556
2617
|
}, 400);
|
|
2557
2618
|
}
|
|
2558
|
-
function
|
|
2619
|
+
function Rn() {
|
|
2559
2620
|
try {
|
|
2560
|
-
localStorage.setItem("characterPosition", JSON.stringify({ x:
|
|
2621
|
+
localStorage.setItem("characterPosition", JSON.stringify({ x: m.x, y: m.y })), localStorage.setItem("panelPosition", X.value), localStorage.setItem("backPosition", L.value);
|
|
2561
2622
|
} catch {
|
|
2562
2623
|
}
|
|
2563
2624
|
}
|
|
2564
|
-
function
|
|
2625
|
+
function Pn() {
|
|
2565
2626
|
const n = localStorage.getItem("characterPosition");
|
|
2566
2627
|
if (n) {
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2628
|
+
const K = JSON.parse(n);
|
|
2629
|
+
m.x = K.x, m.y = Math.min(Math.max(K.y, 0), window.innerHeight - st);
|
|
2569
2630
|
} else
|
|
2570
|
-
|
|
2571
|
-
const
|
|
2572
|
-
|
|
2631
|
+
m.x = window.innerWidth - w, m.y = window.innerHeight / 2 - st / 2;
|
|
2632
|
+
const d = localStorage.getItem("panelPosition"), M = localStorage.getItem("backPosition");
|
|
2633
|
+
d && (X.value = d), M && (L.value = M);
|
|
2573
2634
|
}
|
|
2574
|
-
function
|
|
2575
|
-
if (!
|
|
2576
|
-
const
|
|
2577
|
-
|
|
2635
|
+
function rt(n) {
|
|
2636
|
+
if (!O.value) return;
|
|
2637
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY, K = d - A.x, ce = Math.max(0, Math.min(M - A.y, window.innerHeight - st)), he = Math.abs(K - m.x), ke = Math.abs(ce - m.y);
|
|
2638
|
+
he + ke > 5 && (ee.value = !0), m.x = K, m.y = ce;
|
|
2578
2639
|
}
|
|
2579
|
-
function
|
|
2580
|
-
|
|
2640
|
+
function ut() {
|
|
2641
|
+
O.value && (O.value = !1, ee.value && (Vt(), ee.value = !1));
|
|
2581
2642
|
}
|
|
2582
|
-
function
|
|
2583
|
-
|
|
2584
|
-
const
|
|
2585
|
-
|
|
2643
|
+
function Ot(n) {
|
|
2644
|
+
q.value = !1, O.value = !0, ee.value = !1;
|
|
2645
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
2646
|
+
A.x = d - m.x, A.y = M - m.y;
|
|
2586
2647
|
}
|
|
2587
|
-
function
|
|
2588
|
-
const n = D.value,
|
|
2648
|
+
function Ln() {
|
|
2649
|
+
const n = D.value, d = (n == null ? void 0 : n.offsetWidth) || ze, M = (n == null ? void 0 : n.offsetHeight) || window.innerHeight - 78;
|
|
2589
2650
|
return {
|
|
2590
|
-
maxX: Math.max(
|
|
2591
|
-
maxY: Math.max(
|
|
2651
|
+
maxX: Math.max(Le, window.innerWidth - d - Le),
|
|
2652
|
+
maxY: Math.max(at, window.innerHeight - M - Le)
|
|
2592
2653
|
};
|
|
2593
2654
|
}
|
|
2594
|
-
function
|
|
2595
|
-
const
|
|
2596
|
-
|
|
2655
|
+
function ct(n, d) {
|
|
2656
|
+
const M = D.value, K = n ?? (M == null ? void 0 : M.offsetWidth) ?? ze, ce = d ?? (M == null ? void 0 : M.offsetHeight) ?? window.innerHeight - 78, he = Math.max(Le, window.innerWidth - K - Le), ke = Math.max(at, window.innerHeight - ce - Le);
|
|
2657
|
+
c.x = Math.min(Math.max(c.x, Le), he), c.y = Math.min(Math.max(c.y, at), ke);
|
|
2597
2658
|
}
|
|
2598
|
-
function
|
|
2599
|
-
if (!
|
|
2600
|
-
if (fe = !1, T.value = !0,
|
|
2601
|
-
const
|
|
2602
|
-
if (
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2659
|
+
function Wt(n) {
|
|
2660
|
+
if (!Nt.value || R.value || J.value || p.value || I.value !== "idle") return;
|
|
2661
|
+
if (fe = !1, T.value = !0, F.value = !1, !C.value) {
|
|
2662
|
+
const K = D.value;
|
|
2663
|
+
if (K) {
|
|
2664
|
+
const ce = K.getBoundingClientRect();
|
|
2665
|
+
c.x = ce.left, c.y = ce.top, C.value = !0;
|
|
2605
2666
|
}
|
|
2606
2667
|
}
|
|
2607
|
-
const
|
|
2608
|
-
|
|
2668
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
2669
|
+
u.x = d, u.y = M, H.x = d - c.x, H.y = M - c.y;
|
|
2609
2670
|
}
|
|
2610
|
-
function
|
|
2611
|
-
var
|
|
2671
|
+
function dt(n) {
|
|
2672
|
+
var Me, Xe;
|
|
2612
2673
|
if (!T.value) return;
|
|
2613
|
-
const
|
|
2614
|
-
if (!
|
|
2615
|
-
const
|
|
2616
|
-
if (
|
|
2617
|
-
|
|
2674
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
2675
|
+
if (!F.value) {
|
|
2676
|
+
const Ke = Math.abs(d - u.x), wt = Math.abs(M - u.y);
|
|
2677
|
+
if (Ke + wt <= 5) return;
|
|
2678
|
+
F.value = !0;
|
|
2618
2679
|
}
|
|
2619
|
-
const { maxX:
|
|
2620
|
-
|
|
2680
|
+
const { maxX: K, maxY: ce } = Ln(), he = Se.value ? K + Ti : K, ke = Math.min(Math.max(d - H.x, Le), he), Ae = Math.min(Math.max(M - H.y, at), ce), Pe = Se.value && ke > K + xi;
|
|
2681
|
+
Pe !== fe && (fe = Pe, (Xe = (Me = e.dock) == null ? void 0 : Me.onDockChange) == null || Xe.call(Me, Pe)), Y.value = Pe, c.x = ke, c.y = Ae;
|
|
2621
2682
|
}
|
|
2622
|
-
function
|
|
2623
|
-
var
|
|
2683
|
+
function vt() {
|
|
2684
|
+
var d, M;
|
|
2624
2685
|
if (!T.value) return;
|
|
2625
2686
|
T.value = !1;
|
|
2626
2687
|
let n = !1;
|
|
2627
|
-
|
|
2688
|
+
F.value && (F.value = !1, te = !0, setTimeout(() => {
|
|
2628
2689
|
te = !1;
|
|
2629
|
-
}, 0),
|
|
2690
|
+
}, 0), Y.value && Se.value ? (zt(), n = !0) : (ct(), Hn())), fe && !n && (fe = !1, (M = (d = e.dock) == null ? void 0 : d.onDockChange) == null || M.call(d, !1)), Y.value = !1;
|
|
2630
2691
|
}
|
|
2631
|
-
function
|
|
2692
|
+
function Bt(n) {
|
|
2632
2693
|
te && (n.preventDefault(), n.stopPropagation(), te = !1);
|
|
2633
2694
|
}
|
|
2634
|
-
function
|
|
2695
|
+
function Hn() {
|
|
2635
2696
|
try {
|
|
2636
|
-
localStorage.setItem(
|
|
2697
|
+
localStorage.setItem(dn, JSON.stringify({ x: c.x, y: c.y }));
|
|
2637
2698
|
} catch {
|
|
2638
2699
|
}
|
|
2639
2700
|
}
|
|
2640
|
-
function
|
|
2701
|
+
function Nn() {
|
|
2641
2702
|
try {
|
|
2642
|
-
const n = localStorage.getItem(
|
|
2703
|
+
const n = localStorage.getItem(dn);
|
|
2643
2704
|
if (n) {
|
|
2644
|
-
const
|
|
2645
|
-
typeof
|
|
2705
|
+
const d = JSON.parse(n);
|
|
2706
|
+
typeof d.x == "number" && typeof d.y == "number" && (c.x = d.x, c.y = d.y, C.value = !0);
|
|
2646
2707
|
}
|
|
2647
2708
|
} catch {
|
|
2648
2709
|
}
|
|
2649
2710
|
}
|
|
2650
|
-
function
|
|
2711
|
+
function Ft() {
|
|
2651
2712
|
try {
|
|
2652
|
-
localStorage.setItem(
|
|
2713
|
+
localStorage.setItem(vn, p.value ? "1" : "0");
|
|
2653
2714
|
} catch {
|
|
2654
2715
|
}
|
|
2655
2716
|
}
|
|
2656
|
-
function
|
|
2717
|
+
function It() {
|
|
2657
2718
|
var n;
|
|
2658
2719
|
if (!a.value)
|
|
2659
2720
|
try {
|
|
2660
|
-
if (localStorage.getItem(
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2721
|
+
if (localStorage.getItem(vn) === "1" && Se.value) {
|
|
2722
|
+
const M = (n = e.dock) == null ? void 0 : n.containerId;
|
|
2723
|
+
M && document.getElementById(M) && (p.value = !0);
|
|
2663
2724
|
}
|
|
2664
2725
|
} catch {
|
|
2665
2726
|
}
|
|
2666
2727
|
}
|
|
2667
|
-
function
|
|
2728
|
+
function ht() {
|
|
2668
2729
|
return {
|
|
2669
|
-
x: window.innerWidth -
|
|
2730
|
+
x: window.innerWidth - we.value,
|
|
2670
2731
|
y: 0,
|
|
2671
|
-
w:
|
|
2732
|
+
w: we.value,
|
|
2672
2733
|
h: window.innerHeight,
|
|
2673
2734
|
radius: "0px"
|
|
2674
2735
|
};
|
|
2675
2736
|
}
|
|
2676
|
-
function
|
|
2737
|
+
function Vn() {
|
|
2677
2738
|
return {
|
|
2678
|
-
x: Math.max(0, Math.min(window.innerWidth - 53,
|
|
2679
|
-
y:
|
|
2739
|
+
x: Math.max(0, Math.min(window.innerWidth - 53, m.x + $e.value * 3)),
|
|
2740
|
+
y: m.y,
|
|
2680
2741
|
w: 53,
|
|
2681
2742
|
h: 53,
|
|
2682
2743
|
radius: "50%"
|
|
@@ -2692,112 +2753,112 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2692
2753
|
radius: "14px"
|
|
2693
2754
|
};
|
|
2694
2755
|
}
|
|
2695
|
-
function
|
|
2696
|
-
R.value ? (
|
|
2756
|
+
function On() {
|
|
2757
|
+
R.value ? (Ge(Xt(), Kt()), R.value = !1) : (Ge(je(), Xt()), R.value = !0);
|
|
2697
2758
|
}
|
|
2698
|
-
function
|
|
2699
|
-
|
|
2759
|
+
function Ge(n, d, M, K = "none") {
|
|
2760
|
+
G && clearTimeout(G), ue.value = "switching", j.value = !0, ve.value = K, me.x = n.x, me.y = n.y, me.w = n.w, me.h = n.h, me.radius = n.radius, De(() => {
|
|
2700
2761
|
requestAnimationFrame(() => {
|
|
2701
|
-
|
|
2762
|
+
j.value = !1, me.x = d.x, me.y = d.y, me.w = d.w, me.h = d.h, me.radius = d.radius;
|
|
2702
2763
|
});
|
|
2703
|
-
}),
|
|
2704
|
-
|
|
2764
|
+
}), G = setTimeout(() => {
|
|
2765
|
+
ue.value = "idle", ve.value = "none", G = null, M == null || M();
|
|
2705
2766
|
}, 400);
|
|
2706
2767
|
}
|
|
2707
2768
|
function zt() {
|
|
2708
|
-
var
|
|
2709
|
-
if (!
|
|
2769
|
+
var ce, he, ke, Ae, Pe;
|
|
2770
|
+
if (!Se.value || p.value) return;
|
|
2710
2771
|
R.value && (R.value = !1);
|
|
2711
|
-
const n = (
|
|
2772
|
+
const n = (ce = e.dock) == null ? void 0 : ce.containerId;
|
|
2712
2773
|
if (n && !document.getElementById(n)) {
|
|
2713
2774
|
console.warn(`[ai-assist-sdk] dock container "#${n}" not found, dock feature disabled`);
|
|
2714
2775
|
return;
|
|
2715
2776
|
}
|
|
2716
|
-
const
|
|
2717
|
-
let
|
|
2718
|
-
if (
|
|
2719
|
-
const
|
|
2720
|
-
|
|
2777
|
+
const d = D.value;
|
|
2778
|
+
let M = je();
|
|
2779
|
+
if (d) {
|
|
2780
|
+
const Me = d.getBoundingClientRect();
|
|
2781
|
+
M = { x: Me.left, y: Me.top, w: Me.width, h: Me.height, radius: getComputedStyle(d).borderRadius };
|
|
2721
2782
|
}
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2783
|
+
const K = ht();
|
|
2784
|
+
Ge(M, K), p.value = !0, I.value = "idle", Y.value = !1, Ft(), (ke = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ke.call(he, !0), (Pe = (Ae = e.dock) == null ? void 0 : Ae.onDockWidthChange) == null || Pe.call(Ae, we.value);
|
|
2724
2785
|
}
|
|
2725
|
-
function
|
|
2726
|
-
return Math.max(
|
|
2786
|
+
function Wn() {
|
|
2787
|
+
return Math.max(hn, window.innerWidth - Di);
|
|
2727
2788
|
}
|
|
2728
|
-
function
|
|
2789
|
+
function Qe(n) {
|
|
2729
2790
|
if (a.value) {
|
|
2730
|
-
const
|
|
2731
|
-
return Math.min(Math.max(n, 360),
|
|
2791
|
+
const d = Math.max(360, Math.min(720, Math.min(window.innerWidth * 0.6, window.innerWidth - 80)));
|
|
2792
|
+
return Math.min(Math.max(n, 360), d);
|
|
2732
2793
|
}
|
|
2733
|
-
return Math.min(Math.max(n,
|
|
2794
|
+
return Math.min(Math.max(n, hn), Wn());
|
|
2734
2795
|
}
|
|
2735
|
-
function
|
|
2796
|
+
function Bn() {
|
|
2736
2797
|
try {
|
|
2737
|
-
localStorage.setItem(
|
|
2798
|
+
localStorage.setItem(Ht(), String(we.value));
|
|
2738
2799
|
} catch {
|
|
2739
2800
|
}
|
|
2740
2801
|
}
|
|
2741
|
-
function
|
|
2802
|
+
function bt() {
|
|
2742
2803
|
try {
|
|
2743
|
-
const n = localStorage.getItem(
|
|
2804
|
+
const n = localStorage.getItem(Ht());
|
|
2744
2805
|
if (n) {
|
|
2745
|
-
const
|
|
2746
|
-
Number.isFinite(
|
|
2806
|
+
const d = parseFloat(n);
|
|
2807
|
+
Number.isFinite(d) && (we.value = Qe(d));
|
|
2747
2808
|
}
|
|
2748
2809
|
} catch {
|
|
2749
2810
|
}
|
|
2750
2811
|
}
|
|
2751
|
-
function
|
|
2752
|
-
if (!
|
|
2753
|
-
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
}
|
|
2757
|
-
function
|
|
2758
|
-
if (!
|
|
2759
|
-
const
|
|
2760
|
-
Math.abs(
|
|
2761
|
-
var
|
|
2762
|
-
W = 0, (
|
|
2812
|
+
function qt(n) {
|
|
2813
|
+
if (!p.value && !a.value) return;
|
|
2814
|
+
ae.value = !0, B.value = !1;
|
|
2815
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX;
|
|
2816
|
+
Q.x = d, Q.width = we.value, document.body.style.userSelect = "none";
|
|
2817
|
+
}
|
|
2818
|
+
function ft(n) {
|
|
2819
|
+
if (!ae.value) return;
|
|
2820
|
+
const d = "touches" in n ? n.touches[0].clientX : n.clientX, M = Qe(Q.width + (Q.x - d));
|
|
2821
|
+
Math.abs(M - Q.width) > 3 && (B.value = !0), we.value = M, W || (W = requestAnimationFrame(() => {
|
|
2822
|
+
var K, ce;
|
|
2823
|
+
W = 0, (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, we.value);
|
|
2763
2824
|
}));
|
|
2764
2825
|
}
|
|
2765
|
-
function
|
|
2766
|
-
var n,
|
|
2767
|
-
|
|
2826
|
+
function mt() {
|
|
2827
|
+
var n, d;
|
|
2828
|
+
ae.value && (ae.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, we.value)));
|
|
2768
2829
|
}
|
|
2769
|
-
function
|
|
2770
|
-
var n,
|
|
2771
|
-
|
|
2830
|
+
function Gt() {
|
|
2831
|
+
var n, d;
|
|
2832
|
+
p.value && (C.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
2833
|
}
|
|
2773
|
-
function
|
|
2774
|
-
var
|
|
2834
|
+
function Fn() {
|
|
2835
|
+
var d, M, K, ce, he, ke, Ae, Pe;
|
|
2775
2836
|
if (x.value) return;
|
|
2776
|
-
if (E && (clearTimeout(E), E = null),
|
|
2777
|
-
x.value = !0, I.value = "idle",
|
|
2778
|
-
const
|
|
2779
|
-
if (
|
|
2780
|
-
|
|
2837
|
+
if (E && (clearTimeout(E), E = null), b.value = !1, a.value) {
|
|
2838
|
+
x.value = !0, I.value = "idle", we.value = Qe(we.value), (M = (d = e.dock) == null ? void 0 : d.onDockChange) == null || M.call(d, !0), (ce = (K = e.dock) == null ? void 0 : K.onDockWidthChange) == null || ce.call(K, we.value), _t();
|
|
2839
|
+
const Me = Be();
|
|
2840
|
+
if (r !== Me) {
|
|
2841
|
+
r = Me;
|
|
2781
2842
|
try {
|
|
2782
|
-
(
|
|
2783
|
-
} catch (
|
|
2784
|
-
console.warn("[ai-assist-sdk] 页面会话恢复失败:",
|
|
2843
|
+
(ke = (he = ne.value) == null ? void 0 : he.restorePageHistory) == null || ke.call(he);
|
|
2844
|
+
} catch (Xe) {
|
|
2845
|
+
console.warn("[ai-assist-sdk] 页面会话恢复失败:", Xe);
|
|
2785
2846
|
}
|
|
2786
2847
|
}
|
|
2787
2848
|
return;
|
|
2788
2849
|
}
|
|
2789
|
-
if (
|
|
2790
|
-
|
|
2791
|
-
{ x: window.innerWidth, y: 0, w:
|
|
2792
|
-
|
|
2850
|
+
if (p.value) {
|
|
2851
|
+
Ge(
|
|
2852
|
+
{ x: window.innerWidth, y: 0, w: we.value, h: window.innerHeight, radius: "0px" },
|
|
2853
|
+
ht(),
|
|
2793
2854
|
void 0,
|
|
2794
2855
|
"in"
|
|
2795
|
-
), x.value = !0, I.value = "idle", (
|
|
2856
|
+
), x.value = !0, I.value = "idle", (Pe = (Ae = e.dock) == null ? void 0 : Ae.onDockChange) == null || Pe.call(Ae, !0);
|
|
2796
2857
|
return;
|
|
2797
2858
|
}
|
|
2798
|
-
|
|
2799
|
-
const n =
|
|
2800
|
-
y.x = Math.max(0, Math.min(window.innerWidth - 53,
|
|
2859
|
+
Ye();
|
|
2860
|
+
const n = je();
|
|
2861
|
+
y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + $e.value * 3)), y.y = m.y - $e.value * 2, y.w = 53, y.h = 53, y.radius = "50%", P.value = !0, I.value = "expanding", x.value = !0, De(() => {
|
|
2801
2862
|
requestAnimationFrame(() => {
|
|
2802
2863
|
P.value = !1, y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius;
|
|
2803
2864
|
});
|
|
@@ -2805,17 +2866,17 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2805
2866
|
I.value = "idle";
|
|
2806
2867
|
}, 400);
|
|
2807
2868
|
}
|
|
2808
|
-
function
|
|
2809
|
-
if (
|
|
2810
|
-
|
|
2869
|
+
function In() {
|
|
2870
|
+
if (ee.value || q.value) {
|
|
2871
|
+
ee.value = !1;
|
|
2811
2872
|
return;
|
|
2812
2873
|
}
|
|
2813
|
-
|
|
2874
|
+
on(!0);
|
|
2814
2875
|
}
|
|
2815
2876
|
function Xn() {
|
|
2816
|
-
|
|
2877
|
+
on(!1);
|
|
2817
2878
|
}
|
|
2818
|
-
function
|
|
2879
|
+
function je() {
|
|
2819
2880
|
if (window.innerWidth < 768)
|
|
2820
2881
|
return R.value ? {
|
|
2821
2882
|
x: 0,
|
|
@@ -2830,352 +2891,352 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
2830
2891
|
h: window.innerHeight - 16,
|
|
2831
2892
|
radius: "14px"
|
|
2832
2893
|
};
|
|
2833
|
-
const
|
|
2834
|
-
let
|
|
2894
|
+
const d = window.innerHeight - 78;
|
|
2895
|
+
let M = 54;
|
|
2835
2896
|
if (R.value) {
|
|
2836
|
-
const
|
|
2897
|
+
const K = window.innerWidth * 0.8;
|
|
2837
2898
|
return {
|
|
2838
|
-
x: (window.innerWidth -
|
|
2839
|
-
y:
|
|
2840
|
-
w:
|
|
2841
|
-
h:
|
|
2899
|
+
x: (window.innerWidth - K) / 2,
|
|
2900
|
+
y: M,
|
|
2901
|
+
w: K,
|
|
2902
|
+
h: d,
|
|
2842
2903
|
radius: "14px"
|
|
2843
2904
|
};
|
|
2844
2905
|
}
|
|
2845
|
-
return
|
|
2906
|
+
return Kt();
|
|
2846
2907
|
}
|
|
2847
|
-
function
|
|
2848
|
-
const n =
|
|
2849
|
-
let
|
|
2850
|
-
return
|
|
2908
|
+
function Kt() {
|
|
2909
|
+
const n = ze, d = window.innerHeight - 78;
|
|
2910
|
+
let M = 54, K;
|
|
2911
|
+
return C.value ? (K = Math.min(Math.max(c.x, Le), Math.max(Le, window.innerWidth - n - Le)), M = Math.min(Math.max(c.y, at), Math.max(Le, d - Le))) : K = X.value === "left" ? 24 : window.innerWidth - n - 24, { x: K, y: M, w: n, h: d, radius: "14px" };
|
|
2851
2912
|
}
|
|
2852
2913
|
function zn() {
|
|
2853
|
-
var
|
|
2914
|
+
var d, M, K, ce, he, ke;
|
|
2854
2915
|
if (a.value) {
|
|
2855
|
-
if (
|
|
2856
|
-
|
|
2857
|
-
E = null,
|
|
2916
|
+
if (b.value) return;
|
|
2917
|
+
b.value = !0, (M = (d = e.dock) == null ? void 0 : d.onDockChange) == null || M.call(d, !1), (ce = (K = e.pageMode) == null ? void 0 : K.onVisibleChange) == null || ce.call(K, !1), E && clearTimeout(E), E = setTimeout(() => {
|
|
2918
|
+
E = null, b.value = !1, x.value = !1, I.value = "idle", ks("default");
|
|
2858
2919
|
}, 300);
|
|
2859
2920
|
return;
|
|
2860
2921
|
}
|
|
2861
|
-
if (
|
|
2862
|
-
if (
|
|
2863
|
-
|
|
2864
|
-
x.value = !1, I.value = "idle",
|
|
2865
|
-
|
|
2922
|
+
if (ue.value !== "idle") return;
|
|
2923
|
+
if (p.value) {
|
|
2924
|
+
Ge(ht(), Vn(), () => {
|
|
2925
|
+
x.value = !1, I.value = "idle", N.value = !0, setTimeout(() => {
|
|
2926
|
+
N.value = !1;
|
|
2866
2927
|
}, 1400);
|
|
2867
|
-
}, "out"), (
|
|
2928
|
+
}, "out"), (ke = (he = e.dock) == null ? void 0 : he.onDockChange) == null || ke.call(he, !1);
|
|
2868
2929
|
return;
|
|
2869
2930
|
}
|
|
2870
2931
|
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, P.value = !0, I.value = "collapsing",
|
|
2932
|
+
const n = je();
|
|
2933
|
+
y.x = n.x, y.y = n.y, y.w = n.w, y.h = n.h, y.radius = n.radius, P.value = !0, I.value = "collapsing", De(() => {
|
|
2873
2934
|
requestAnimationFrame(() => {
|
|
2874
|
-
P.value = !1, y.x = Math.max(0, Math.min(window.innerWidth - 53,
|
|
2935
|
+
P.value = !1, y.x = Math.max(0, Math.min(window.innerWidth - 53, m.x + $e.value * 3)), y.y = m.y + Math.abs($e.value) * 2, y.w = 53, y.h = 53, y.radius = "50%";
|
|
2875
2936
|
});
|
|
2876
2937
|
}), setTimeout(() => {
|
|
2877
|
-
x.value = !1, I.value = "idle",
|
|
2938
|
+
x.value = !1, I.value = "idle", N.value = !0;
|
|
2878
2939
|
}, 400), setTimeout(() => {
|
|
2879
|
-
|
|
2940
|
+
N.value = !1;
|
|
2880
2941
|
}, 1400);
|
|
2881
2942
|
}
|
|
2882
|
-
function
|
|
2883
|
-
|
|
2884
|
-
var
|
|
2885
|
-
(
|
|
2943
|
+
function qn(n) {
|
|
2944
|
+
Je(), V.value = "answer", De(() => {
|
|
2945
|
+
var d;
|
|
2946
|
+
(d = ne.value) == null || d.goHistoryMessage(n);
|
|
2886
2947
|
});
|
|
2887
2948
|
}
|
|
2888
|
-
function
|
|
2889
|
-
|
|
2949
|
+
function Gn() {
|
|
2950
|
+
re.value = "", V.value = "answer", De(() => {
|
|
2890
2951
|
var n;
|
|
2891
|
-
(n =
|
|
2952
|
+
(n = ne.value) == null || n.createNewConversation();
|
|
2892
2953
|
});
|
|
2893
2954
|
}
|
|
2894
|
-
function
|
|
2895
|
-
|
|
2955
|
+
function Kn() {
|
|
2956
|
+
Je(), re.value = "", De(() => {
|
|
2896
2957
|
var n;
|
|
2897
|
-
(n =
|
|
2958
|
+
(n = ne.value) == null || n.createNewConversation();
|
|
2898
2959
|
});
|
|
2899
2960
|
}
|
|
2900
|
-
function
|
|
2901
|
-
k.value = !1,
|
|
2961
|
+
function Yn() {
|
|
2962
|
+
k.value = !1, de.value = !0;
|
|
2902
2963
|
}
|
|
2903
|
-
function
|
|
2964
|
+
function Je() {
|
|
2904
2965
|
k.value = !0, setTimeout(() => {
|
|
2905
|
-
|
|
2966
|
+
de.value = !1, k.value = !1;
|
|
2906
2967
|
}, 300);
|
|
2907
2968
|
}
|
|
2908
|
-
function
|
|
2909
|
-
|
|
2969
|
+
function Qn() {
|
|
2970
|
+
se.value = s.value, le.value = !1;
|
|
2910
2971
|
}
|
|
2911
|
-
|
|
2912
|
-
n ?
|
|
2913
|
-
}),
|
|
2914
|
-
n &&
|
|
2972
|
+
pe(R, (n) => {
|
|
2973
|
+
n ? X.value = "center" : Ye();
|
|
2974
|
+
}), pe(x, (n) => {
|
|
2975
|
+
n && C.value && De(() => ct());
|
|
2915
2976
|
});
|
|
2916
|
-
function
|
|
2917
|
-
var
|
|
2918
|
-
if (n !==
|
|
2919
|
-
|
|
2977
|
+
function jn(n) {
|
|
2978
|
+
var d, M, K, ce, he, ke, Ae, Pe, Me, Xe, Ke, wt;
|
|
2979
|
+
if (n !== v.value) {
|
|
2980
|
+
v.value = n, C.value = !1, Y.value = !1, T.value = !1, ae.value = !1, I.value = "idle", fe = !1, re.value = "", r = "";
|
|
2920
2981
|
try {
|
|
2921
|
-
(
|
|
2922
|
-
} catch (
|
|
2923
|
-
console.warn("[ai-assist-sdk] 切换形态清空会话失败:",
|
|
2982
|
+
(M = (d = ne.value) == null ? void 0 : d.clearActiveMessages) == null || M.call(d);
|
|
2983
|
+
} catch (Zn) {
|
|
2984
|
+
console.warn("[ai-assist-sdk] 切换形态清空会话失败:", Zn);
|
|
2924
2985
|
}
|
|
2925
2986
|
if (n === "page") {
|
|
2926
|
-
R.value = !1,
|
|
2987
|
+
R.value = !1, p.value = !1, we.value = Qe(((K = e.pageMode) == null ? void 0 : K.width) || 440), bt(), x.value && ((he = (ce = e.dock) == null ? void 0 : ce.onDockChange) == null || he.call(ce, !0), (Ae = (ke = e.dock) == null ? void 0 : ke.onDockWidthChange) == null || Ae.call(ke, we.value), _t());
|
|
2927
2988
|
return;
|
|
2928
2989
|
}
|
|
2929
|
-
R.value = window.innerWidth < 768,
|
|
2990
|
+
R.value = window.innerWidth < 768, we.value = ((Pe = e.dock) == null ? void 0 : Pe.width) || ze, It(), bt(), Ye(), x.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, we.value));
|
|
2930
2991
|
}
|
|
2931
2992
|
}
|
|
2932
|
-
function
|
|
2933
|
-
var
|
|
2934
|
-
const
|
|
2935
|
-
|
|
2936
|
-
}
|
|
2937
|
-
let
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
var
|
|
2941
|
-
|
|
2942
|
-
const n =
|
|
2943
|
-
n !==
|
|
2944
|
-
}),
|
|
2945
|
-
}),
|
|
2946
|
-
|
|
2993
|
+
function St(n = 0) {
|
|
2994
|
+
var M, K, ce, he;
|
|
2995
|
+
const d = ln();
|
|
2996
|
+
d !== x.value && (d ? Fn() : ws() ? (E && (clearTimeout(E), E = null), b.value = !1, x.value = !1, I.value = "idle", (K = (M = e.dock) == null ? void 0 : M.onDockChange) == null || K.call(M, !1), (he = (ce = e.pageMode) == null ? void 0 : ce.onVisibleChange) == null || he.call(ce, !1)) : zn(), n < 3 && ln() !== x.value && setTimeout(() => St(n + 1), 450));
|
|
2997
|
+
}
|
|
2998
|
+
let Ze = null;
|
|
2999
|
+
Ne(() => {
|
|
3000
|
+
Ze = ps(() => {
|
|
3001
|
+
var d, M;
|
|
3002
|
+
jn(Ct()), f.value = an(), St();
|
|
3003
|
+
const n = Be();
|
|
3004
|
+
n !== S && (S = n, r = "", f.value = {}, (M = (d = ne.value) == null ? void 0 : d.clearActiveMessages) == null || M.call(d), _t());
|
|
3005
|
+
}), f.value = an(), St();
|
|
3006
|
+
}), Fe(() => {
|
|
3007
|
+
Ze == null || Ze(), Ze = null, E && (clearTimeout(E), E = null), b.value = !1;
|
|
2947
3008
|
});
|
|
2948
|
-
const
|
|
2949
|
-
let
|
|
2950
|
-
function
|
|
3009
|
+
const Jn = Math.max(1e3, Number(e.activityInterval) || 3e4);
|
|
3010
|
+
let gt = null, Ue = 0, pt = 0, yt = 0;
|
|
3011
|
+
function et(n) {
|
|
2951
3012
|
if (typeof e.onPanelActive == "function")
|
|
2952
3013
|
try {
|
|
2953
3014
|
if (n === "open") {
|
|
2954
|
-
|
|
3015
|
+
Ue = Date.now(), pt = 0, yt = 0, e.onPanelActive({ phase: n, docked: p.value, durationMs: 0, totalMs: 0 });
|
|
2955
3016
|
return;
|
|
2956
3017
|
}
|
|
2957
3018
|
if (document.visibilityState !== "hidden") {
|
|
2958
|
-
const
|
|
2959
|
-
|
|
3019
|
+
const M = Date.now();
|
|
3020
|
+
pt += Math.max(0, M - Ue), Ue = M;
|
|
2960
3021
|
}
|
|
2961
|
-
const
|
|
2962
|
-
if (
|
|
2963
|
-
|
|
3022
|
+
const d = Math.round(pt);
|
|
3023
|
+
if (d <= 0 && n !== "close") return;
|
|
3024
|
+
pt = 0, yt += d, e.onPanelActive({ phase: n, docked: p.value, durationMs: d, totalMs: yt }), n === "close" && (yt = 0);
|
|
2964
3025
|
} catch {
|
|
2965
3026
|
}
|
|
2966
3027
|
}
|
|
2967
3028
|
function Mt() {
|
|
2968
|
-
|
|
2969
|
-
!x.value || document.visibilityState === "hidden" ||
|
|
2970
|
-
},
|
|
2971
|
-
}
|
|
2972
|
-
function et() {
|
|
2973
|
-
mt !== null && (clearInterval(mt), mt = null);
|
|
3029
|
+
tt(), gt = window.setInterval(() => {
|
|
3030
|
+
!x.value || document.visibilityState === "hidden" || et("heartbeat");
|
|
3031
|
+
}, Jn);
|
|
2974
3032
|
}
|
|
2975
|
-
function
|
|
2976
|
-
|
|
3033
|
+
function tt() {
|
|
3034
|
+
gt !== null && (clearInterval(gt), gt = null);
|
|
2977
3035
|
}
|
|
2978
3036
|
function Yt() {
|
|
2979
|
-
x.value && (
|
|
3037
|
+
x.value && (document.visibilityState === "hidden" ? (tt(), et("hidden")) : (Ue = Date.now(), Mt()));
|
|
2980
3038
|
}
|
|
2981
3039
|
function Qt() {
|
|
2982
|
-
|
|
2983
|
-
}
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
3040
|
+
x.value && (tt(), et("hidden"));
|
|
3041
|
+
}
|
|
3042
|
+
function jt() {
|
|
3043
|
+
!x.value || document.visibilityState === "hidden" || (Ue = Date.now(), Mt());
|
|
3044
|
+
}
|
|
3045
|
+
pe(x, (n) => {
|
|
3046
|
+
n ? (et("open"), document.visibilityState !== "hidden" && Mt()) : (tt(), et("close"));
|
|
3047
|
+
}), Ne(() => {
|
|
3048
|
+
document.addEventListener("visibilitychange", Yt), window.addEventListener("pagehide", Qt), window.addEventListener("pageshow", jt);
|
|
3049
|
+
}), Fe(() => {
|
|
3050
|
+
tt(), document.removeEventListener("visibilitychange", Yt), window.removeEventListener("pagehide", Qt), window.removeEventListener("pageshow", jt);
|
|
3051
|
+
}), Ne(() => {
|
|
3052
|
+
Pn(), Nn(), It(), bt();
|
|
2992
3053
|
const n = e.theme || "light";
|
|
2993
|
-
|
|
3054
|
+
Pt(n), n === "auto" && (ye = ys(() => Pt("auto"))), Re = Ls(() => D.value);
|
|
2994
3055
|
});
|
|
2995
|
-
function
|
|
2996
|
-
|
|
3056
|
+
function Jt() {
|
|
3057
|
+
oe && clearTimeout(oe), oe = setTimeout(() => {
|
|
2997
3058
|
const n = window.innerWidth < 768;
|
|
2998
|
-
J.value = n, n && (R.value = !0,
|
|
3059
|
+
J.value = n, n && (R.value = !0, p.value && Gt()), Vt(), C.value && ct(), p.value && (we.value = Qe(we.value));
|
|
2999
3060
|
}, 100);
|
|
3000
3061
|
}
|
|
3001
|
-
return
|
|
3002
|
-
window.addEventListener("resize",
|
|
3003
|
-
}),
|
|
3004
|
-
window.removeEventListener("resize",
|
|
3005
|
-
}),
|
|
3006
|
-
document.addEventListener("mousemove",
|
|
3007
|
-
}),
|
|
3008
|
-
document.removeEventListener("mousemove",
|
|
3009
|
-
}), (n,
|
|
3010
|
-
|
|
3062
|
+
return Ne(() => {
|
|
3063
|
+
window.addEventListener("resize", Jt);
|
|
3064
|
+
}), Fe(() => {
|
|
3065
|
+
window.removeEventListener("resize", Jt), oe && clearTimeout(oe), ye == null || ye(), Re == null || Re(), Re = null;
|
|
3066
|
+
}), Ne(() => {
|
|
3067
|
+
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);
|
|
3068
|
+
}), Fe(() => {
|
|
3069
|
+
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);
|
|
3070
|
+
}), (n, d) => (i(), h("div", null, [
|
|
3071
|
+
qe(o("div", {
|
|
3011
3072
|
ref_key: "panelRef",
|
|
3012
3073
|
ref: D,
|
|
3013
|
-
class:
|
|
3074
|
+
class: ge([
|
|
3014
3075
|
"ai-panel",
|
|
3015
3076
|
a.value ? "page-mode" : R.value ? "maxWrap" : "minWrap",
|
|
3016
|
-
a.value ? "" :
|
|
3077
|
+
a.value ? "" : Te.value,
|
|
3017
3078
|
{
|
|
3018
|
-
"panel-custom":
|
|
3019
|
-
"page-closing":
|
|
3079
|
+
"panel-custom": C.value && !R.value && !J.value && !p.value && !a.value && ue.value === "idle",
|
|
3080
|
+
"page-closing": b.value,
|
|
3020
3081
|
dragging: T.value,
|
|
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": !
|
|
3082
|
+
"dock-preview": Y.value,
|
|
3083
|
+
docked: p.value,
|
|
3084
|
+
"dock-resizing": ae.value,
|
|
3085
|
+
"dock-switching": ue.value !== "idle",
|
|
3086
|
+
"dock-switch-instant": j.value,
|
|
3087
|
+
"dock-switch-fade-in": ve.value === "in",
|
|
3088
|
+
"dock-switch-fade-out": ve.value === "out",
|
|
3089
|
+
"no-drag": !Nt.value || a.value
|
|
3029
3090
|
},
|
|
3030
3091
|
I.value !== "idle" ? I.value : "",
|
|
3031
3092
|
{ morphing: I.value !== "idle", "morph-instant": P.value }
|
|
3032
3093
|
]),
|
|
3033
|
-
style:
|
|
3094
|
+
style: kt([Dn.value, Tn.value, En.value])
|
|
3034
3095
|
}, [
|
|
3035
|
-
|
|
3096
|
+
p.value || a.value ? (i(), h("div", {
|
|
3036
3097
|
key: 0,
|
|
3037
3098
|
class: "ai-dock-resizer",
|
|
3038
|
-
onMousedown:
|
|
3039
|
-
onTouchstart:
|
|
3040
|
-
}, null, 32)) :
|
|
3099
|
+
onMousedown: Ve(qt, ["stop"]),
|
|
3100
|
+
onTouchstart: Ve(qt, ["stop"])
|
|
3101
|
+
}, null, 32)) : z("", !0),
|
|
3041
3102
|
o("div", {
|
|
3042
3103
|
class: "header",
|
|
3043
|
-
onMousedown:
|
|
3044
|
-
onTouchstart:
|
|
3104
|
+
onMousedown: Wt,
|
|
3105
|
+
onTouchstart: Wt
|
|
3045
3106
|
}, [
|
|
3046
|
-
|
|
3107
|
+
V.value === "info" ? (i(), h("span", {
|
|
3047
3108
|
key: 0,
|
|
3048
|
-
class:
|
|
3049
|
-
onClick:
|
|
3050
|
-
}, [...
|
|
3109
|
+
class: ge(["back", L.value]),
|
|
3110
|
+
onClick: d[0] || (d[0] = (M) => V.value = "answer")
|
|
3111
|
+
}, [...d[6] || (d[6] = [
|
|
3051
3112
|
o("span", { style: { "font-size": "14px" } }, "←", -1)
|
|
3052
|
-
])], 2)) : (i(),
|
|
3113
|
+
])], 2)) : (i(), h("p", fi, [
|
|
3053
3114
|
o("img", {
|
|
3054
|
-
src:
|
|
3115
|
+
src: ie(_n),
|
|
3055
3116
|
draggable: "false"
|
|
3056
3117
|
}, null, 8, mi)
|
|
3057
3118
|
])),
|
|
3058
3119
|
o("div", gi, [
|
|
3059
3120
|
o("span", {
|
|
3060
|
-
title:
|
|
3061
|
-
}, U(
|
|
3121
|
+
title: V.value === "info" ? "个人信息" : re.value || g.value
|
|
3122
|
+
}, U(V.value === "info" ? "个人信息" : re.value || g.value), 9, pi)
|
|
3062
3123
|
]),
|
|
3063
3124
|
o("p", null, [
|
|
3064
|
-
|
|
3125
|
+
qe(Ce(Ee, {
|
|
3065
3126
|
class: "op-icon",
|
|
3066
3127
|
name: "add",
|
|
3067
|
-
onClick:
|
|
3128
|
+
onClick: Gn
|
|
3068
3129
|
}, null, 512), [
|
|
3069
|
-
[
|
|
3130
|
+
[nt, Mn.value]
|
|
3070
3131
|
]),
|
|
3071
|
-
a.value ?
|
|
3132
|
+
a.value ? z("", !0) : (i(), _e(Ee, {
|
|
3072
3133
|
key: 0,
|
|
3073
|
-
class:
|
|
3134
|
+
class: ge(["mute", { active: de.value }]),
|
|
3074
3135
|
name: "history",
|
|
3075
|
-
onClick:
|
|
3136
|
+
onClick: d[1] || (d[1] = (M) => de.value ? Je() : Yn())
|
|
3076
3137
|
}, null, 8, ["class"])),
|
|
3077
|
-
!a.value && !J.value && !
|
|
3138
|
+
!a.value && !J.value && !p.value ? (i(), _e(Ee, {
|
|
3078
3139
|
key: 1,
|
|
3079
|
-
onClick:
|
|
3140
|
+
onClick: On,
|
|
3080
3141
|
name: R.value ? "fullscreenExit" : "fullscreen"
|
|
3081
|
-
}, null, 8, ["name"])) :
|
|
3082
|
-
|
|
3142
|
+
}, null, 8, ["name"])) : z("", !0),
|
|
3143
|
+
p.value && !a.value ? (i(), _e(Ee, {
|
|
3083
3144
|
key: 2,
|
|
3084
3145
|
name: "dockOut",
|
|
3085
|
-
onClick:
|
|
3086
|
-
})) :
|
|
3087
|
-
|
|
3146
|
+
onClick: Gt
|
|
3147
|
+
})) : z("", !0),
|
|
3148
|
+
Se.value && !p.value && !a.value ? (i(), _e(Ee, {
|
|
3088
3149
|
key: 3,
|
|
3089
3150
|
name: "dockIn",
|
|
3090
3151
|
onClick: zt,
|
|
3091
3152
|
class: "__minimize"
|
|
3092
|
-
})) :
|
|
3093
|
-
|
|
3153
|
+
})) : z("", !0),
|
|
3154
|
+
Ce(Ee, {
|
|
3094
3155
|
onClick: Xn,
|
|
3095
3156
|
name: "close"
|
|
3096
3157
|
})
|
|
3097
3158
|
])
|
|
3098
3159
|
], 32),
|
|
3099
|
-
a.value ? (i(),
|
|
3160
|
+
a.value ? (i(), _e(hi, {
|
|
3100
3161
|
key: 1,
|
|
3101
|
-
context:
|
|
3102
|
-
}, null, 8, ["context"])) :
|
|
3103
|
-
|
|
3162
|
+
context: f.value
|
|
3163
|
+
}, null, 8, ["context"])) : z("", !0),
|
|
3164
|
+
qe(Ce(Vo, {
|
|
3104
3165
|
ref_key: "answerRef",
|
|
3105
|
-
ref:
|
|
3106
|
-
defaultSayhello:
|
|
3107
|
-
defaultRecommend:
|
|
3108
|
-
onTitleGenerated:
|
|
3109
|
-
onSessionsChange:
|
|
3166
|
+
ref: ne,
|
|
3167
|
+
defaultSayhello: ie(e).defaultSayhello,
|
|
3168
|
+
defaultRecommend: l.value,
|
|
3169
|
+
onTitleGenerated: d[2] || (d[2] = (M) => re.value = M),
|
|
3170
|
+
onSessionsChange: d[3] || (d[3] = (M) => Z.value = M)
|
|
3110
3171
|
}, null, 8, ["defaultSayhello", "defaultRecommend"]), [
|
|
3111
|
-
[
|
|
3172
|
+
[nt, V.value === "answer"]
|
|
3112
3173
|
]),
|
|
3113
|
-
|
|
3114
|
-
|
|
3174
|
+
V.value === "info" ? (i(), _e(ci, { key: 2 })) : z("", !0),
|
|
3175
|
+
de.value ? (i(), h("div", {
|
|
3115
3176
|
key: 3,
|
|
3116
|
-
class:
|
|
3177
|
+
class: ge(["ai-history-drawer", { closing: k.value }])
|
|
3117
3178
|
}, [
|
|
3118
3179
|
o("div", {
|
|
3119
3180
|
class: "ai-history-backdrop",
|
|
3120
|
-
onClick:
|
|
3181
|
+
onClick: Je
|
|
3121
3182
|
}),
|
|
3122
3183
|
o("div", yi, [
|
|
3123
3184
|
o("div", wi, [
|
|
3124
|
-
|
|
3125
|
-
|
|
3185
|
+
d[7] || (d[7] = o("span", null, "对话记录", -1)),
|
|
3186
|
+
Ce(Ee, {
|
|
3126
3187
|
name: "close",
|
|
3127
3188
|
class: "ai-history-drawer-close",
|
|
3128
|
-
onClick:
|
|
3189
|
+
onClick: Je
|
|
3129
3190
|
})
|
|
3130
3191
|
]),
|
|
3131
|
-
|
|
3192
|
+
Ce(jo, {
|
|
3132
3193
|
localSessions: Z.value,
|
|
3133
|
-
onHistoryDetail:
|
|
3134
|
-
onNewConversation:
|
|
3194
|
+
onHistoryDetail: qn,
|
|
3195
|
+
onNewConversation: Kn
|
|
3135
3196
|
}, null, 8, ["localSessions"])
|
|
3136
3197
|
])
|
|
3137
|
-
], 2)) :
|
|
3138
|
-
|
|
3198
|
+
], 2)) : z("", !0),
|
|
3199
|
+
qe(o("div", ki, [
|
|
3139
3200
|
o("div", _i, [
|
|
3140
3201
|
o("div", Ci, [
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
"onUpdate:modelValue":
|
|
3202
|
+
d[8] || (d[8] = o("p", { class: "title" }, "修改标题", -1)),
|
|
3203
|
+
qe(o("textarea", {
|
|
3204
|
+
"onUpdate:modelValue": d[4] || (d[4] = (M) => s.value = M),
|
|
3144
3205
|
placeholder: "请输入新标题"
|
|
3145
3206
|
}, null, 512), [
|
|
3146
|
-
[
|
|
3207
|
+
[gn, s.value]
|
|
3147
3208
|
]),
|
|
3148
3209
|
o("p", bi, [
|
|
3149
3210
|
o("span", {
|
|
3150
|
-
onClick:
|
|
3211
|
+
onClick: d[5] || (d[5] = (M) => le.value = !1)
|
|
3151
3212
|
}, "取消"),
|
|
3152
|
-
o("span", { onClick:
|
|
3213
|
+
o("span", { onClick: Qn }, "确定")
|
|
3153
3214
|
])
|
|
3154
3215
|
])
|
|
3155
3216
|
])
|
|
3156
3217
|
], 512), [
|
|
3157
|
-
[
|
|
3218
|
+
[nt, le.value]
|
|
3158
3219
|
])
|
|
3159
3220
|
], 6), [
|
|
3160
|
-
[
|
|
3221
|
+
[nt, x.value || I.value !== "idle"]
|
|
3161
3222
|
]),
|
|
3162
|
-
|
|
3223
|
+
Y.value && Se.value ? (i(), h("div", {
|
|
3163
3224
|
key: 0,
|
|
3164
3225
|
class: "ai-dock-preview",
|
|
3165
|
-
style:
|
|
3166
|
-
}, [...
|
|
3226
|
+
style: kt({ width: we.value + "px" })
|
|
3227
|
+
}, [...d[9] || (d[9] = [
|
|
3167
3228
|
o("span", { class: "ai-dock-preview__text" }, "松开以停靠到右侧", -1)
|
|
3168
|
-
])], 4)) :
|
|
3169
|
-
|
|
3170
|
-
class:
|
|
3171
|
-
style:
|
|
3172
|
-
onMousedown:
|
|
3173
|
-
onTouchstart:
|
|
3174
|
-
onClick:
|
|
3229
|
+
])], 4)) : z("", !0),
|
|
3230
|
+
qe(o("div", {
|
|
3231
|
+
class: ge(["character", { dragging: O.value, recycling: q.value, "hover-preview": N.value }]),
|
|
3232
|
+
style: kt($n.value),
|
|
3233
|
+
onMousedown: Ot,
|
|
3234
|
+
onTouchstart: Ot,
|
|
3235
|
+
onClick: In
|
|
3175
3236
|
}, [
|
|
3176
|
-
o("img", { src:
|
|
3237
|
+
o("img", { src: xn.value }, null, 8, Si)
|
|
3177
3238
|
], 38), [
|
|
3178
|
-
[
|
|
3239
|
+
[nt, !x.value && !a.value]
|
|
3179
3240
|
])
|
|
3180
3241
|
]));
|
|
3181
3242
|
}
|
|
@@ -3204,7 +3265,7 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3204
3265
|
fill: "currentColor",
|
|
3205
3266
|
width: "16",
|
|
3206
3267
|
height: "16"
|
|
3207
|
-
}, Bi = /* @__PURE__ */
|
|
3268
|
+
}, Bi = /* @__PURE__ */ xe({
|
|
3208
3269
|
__name: "VoiceInput",
|
|
3209
3270
|
props: {
|
|
3210
3271
|
lang: {},
|
|
@@ -3220,101 +3281,101 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3220
3281
|
},
|
|
3221
3282
|
emits: ["result", "final", "error", "statusChange", "complete"],
|
|
3222
3283
|
setup(t, { expose: w, emit: e }) {
|
|
3223
|
-
const
|
|
3284
|
+
const v = t, a = e, f = {
|
|
3224
3285
|
idle: "开始录音",
|
|
3225
3286
|
connecting: "启动中…",
|
|
3226
3287
|
recording: "停止录音",
|
|
3227
3288
|
stopping: "识别中…",
|
|
3228
3289
|
error: "重试"
|
|
3229
|
-
},
|
|
3230
|
-
let
|
|
3231
|
-
const E =
|
|
3232
|
-
lang:
|
|
3233
|
-
continuous:
|
|
3234
|
-
interimResults:
|
|
3290
|
+
}, g = _(""), l = _(""), r = _("idle"), S = ot.isSupported();
|
|
3291
|
+
let b = null;
|
|
3292
|
+
const E = $(() => _s(v.theme)), x = () => ({
|
|
3293
|
+
lang: v.lang,
|
|
3294
|
+
continuous: v.continuous,
|
|
3295
|
+
interimResults: v.interimResults
|
|
3235
3296
|
}), I = () => {
|
|
3236
|
-
|
|
3297
|
+
S && (b = new ot(x(), {
|
|
3237
3298
|
onStatusChange: (s) => {
|
|
3238
|
-
|
|
3299
|
+
r.value = s, a("statusChange", s), s === "idle" && a("complete", g.value);
|
|
3239
3300
|
},
|
|
3240
3301
|
onInterim: (s) => {
|
|
3241
|
-
|
|
3302
|
+
l.value = s;
|
|
3242
3303
|
},
|
|
3243
|
-
onFinal: (s,
|
|
3244
|
-
|
|
3304
|
+
onFinal: (s, se) => {
|
|
3305
|
+
g.value += s, l.value = "", a("final", s, se);
|
|
3245
3306
|
},
|
|
3246
3307
|
onResult: (s) => a("result", s),
|
|
3247
3308
|
onError: (s) => a("error", s)
|
|
3248
3309
|
}));
|
|
3249
3310
|
};
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
}),
|
|
3253
|
-
() => [
|
|
3311
|
+
Ne(I), Lt(() => {
|
|
3312
|
+
b == null || b.destroy(), b = null;
|
|
3313
|
+
}), pe(
|
|
3314
|
+
() => [v.lang, v.continuous, v.interimResults],
|
|
3254
3315
|
() => {
|
|
3255
|
-
|
|
3316
|
+
b == null || b.destroy(), I();
|
|
3256
3317
|
}
|
|
3257
3318
|
);
|
|
3258
3319
|
const P = async () => {
|
|
3259
|
-
if (
|
|
3260
|
-
if (
|
|
3320
|
+
if (b)
|
|
3321
|
+
if (r.value === "idle" || r.value === "error")
|
|
3261
3322
|
try {
|
|
3262
|
-
await
|
|
3323
|
+
await b.start();
|
|
3263
3324
|
} catch {
|
|
3264
3325
|
}
|
|
3265
|
-
else
|
|
3326
|
+
else r.value === "recording" && b.stop();
|
|
3266
3327
|
}, y = () => {
|
|
3267
|
-
|
|
3268
|
-
},
|
|
3269
|
-
() =>
|
|
3270
|
-
), R =
|
|
3328
|
+
g.value = "", l.value = "";
|
|
3329
|
+
}, N = $(() => !g.value && !l.value), J = $(
|
|
3330
|
+
() => S ? v.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
|
|
3331
|
+
), R = $(() => S ? 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 = $(() => {
|
|
3271
3332
|
const s = ["ai-voice-input-btn"];
|
|
3272
|
-
return
|
|
3273
|
-
}),
|
|
3274
|
-
() => !
|
|
3333
|
+
return r.value === "recording" && s.push("is-recording"), r.value === "connecting" && s.push("is-connecting"), r.value === "stopping" && s.push("is-stopping"), s.join(" ");
|
|
3334
|
+
}), le = $(
|
|
3335
|
+
() => !S || r.value === "connecting" || r.value === "stopping"
|
|
3275
3336
|
);
|
|
3276
3337
|
return w({
|
|
3277
3338
|
start: async () => {
|
|
3278
|
-
await (
|
|
3339
|
+
await (b == null ? void 0 : b.start());
|
|
3279
3340
|
},
|
|
3280
|
-
stop: () =>
|
|
3281
|
-
cancel: () =>
|
|
3282
|
-
getText: () =>
|
|
3341
|
+
stop: () => b == null ? void 0 : b.stop(),
|
|
3342
|
+
cancel: () => b == null ? void 0 : b.cancel(),
|
|
3343
|
+
getText: () => g.value + l.value,
|
|
3283
3344
|
clear: () => {
|
|
3284
|
-
|
|
3345
|
+
g.value = "", l.value = "";
|
|
3285
3346
|
},
|
|
3286
|
-
getStatus: () => (
|
|
3287
|
-
}), (s,
|
|
3288
|
-
class:
|
|
3347
|
+
getStatus: () => (b == null ? void 0 : b.getStatus()) ?? "idle"
|
|
3348
|
+
}), (s, se) => (i(), h("div", {
|
|
3349
|
+
class: ge(["ai-voice-input", t.className]),
|
|
3289
3350
|
"data-theme": E.value
|
|
3290
3351
|
}, [
|
|
3291
3352
|
o("div", {
|
|
3292
|
-
class:
|
|
3353
|
+
class: ge(["ai-voice-input-display", { "is-empty": N.value }])
|
|
3293
3354
|
}, [
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3355
|
+
g.value ? (i(), h("span", Ri, U(g.value), 1)) : z("", !0),
|
|
3356
|
+
l.value ? (i(), h("span", Pi, U(l.value), 1)) : z("", !0),
|
|
3357
|
+
r.value === "recording" && !l.value ? (i(), h("span", Li)) : z("", !0),
|
|
3358
|
+
N.value ? (i(), h("span", Hi, U(J.value), 1)) : z("", !0)
|
|
3298
3359
|
], 2),
|
|
3299
3360
|
o("button", {
|
|
3300
3361
|
type: "button",
|
|
3301
|
-
class:
|
|
3302
|
-
disabled:
|
|
3362
|
+
class: ge(V.value),
|
|
3363
|
+
disabled: le.value,
|
|
3303
3364
|
onClick: P
|
|
3304
3365
|
}, [
|
|
3305
|
-
|
|
3366
|
+
r.value === "recording" ? (i(), h("span", Vi)) : r.value === "connecting" || r.value === "stopping" ? (i(), h("span", Oi, [...se[0] || (se[0] = [
|
|
3306
3367
|
o("span", null, null, -1),
|
|
3307
3368
|
o("span", null, null, -1),
|
|
3308
3369
|
o("span", null, null, -1),
|
|
3309
3370
|
o("span", null, null, -1),
|
|
3310
3371
|
o("span", null, null, -1)
|
|
3311
|
-
])])) : (i(),
|
|
3372
|
+
])])) : (i(), h("svg", Wi, [...se[1] || (se[1] = [
|
|
3312
3373
|
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
3374
|
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
3375
|
])])),
|
|
3315
3376
|
o("span", null, U(R.value), 1)
|
|
3316
3377
|
], 10, Ni),
|
|
3317
|
-
|
|
3378
|
+
N.value ? z("", !0) : (i(), h("button", {
|
|
3318
3379
|
key: 0,
|
|
3319
3380
|
type: "button",
|
|
3320
3381
|
class: "ai-voice-input-btn ai-voice-input-clear-btn",
|
|
@@ -3323,46 +3384,46 @@ const To = { class: "container" }, Do = { class: "chat-wrap" }, Eo = { class: "m
|
|
|
3323
3384
|
}, " 清空 "))
|
|
3324
3385
|
], 10, Ai));
|
|
3325
3386
|
}
|
|
3326
|
-
}), Fi = /* @__PURE__ */
|
|
3327
|
-
let
|
|
3387
|
+
}), Fi = /* @__PURE__ */ bn(Bi, [["__scopeId", "data-v-53d3cc6e"]]);
|
|
3388
|
+
let it = null;
|
|
3328
3389
|
const Ki = (t) => {
|
|
3329
|
-
|
|
3390
|
+
kn(t), wn(t);
|
|
3330
3391
|
}, Yi = (t) => {
|
|
3331
3392
|
const w = t || document.body, e = document.createElement("div");
|
|
3332
3393
|
e.id = "ai-assist-root";
|
|
3333
|
-
const
|
|
3334
|
-
|
|
3394
|
+
const v = lt();
|
|
3395
|
+
Pt(v.theme), Cs(), w.appendChild(e), it = ss(Sn), it.mount(e);
|
|
3335
3396
|
}, Qi = () => {
|
|
3336
|
-
|
|
3397
|
+
it && (it.unmount(), it = null);
|
|
3337
3398
|
const t = document.getElementById("ai-assist-root");
|
|
3338
|
-
t && t.remove(),
|
|
3399
|
+
t && t.remove(), bs();
|
|
3339
3400
|
}, ji = {
|
|
3340
3401
|
install(t, w) {
|
|
3341
|
-
|
|
3402
|
+
kn(w), wn(w), t.component("AiAssist", Sn), t.component("VoiceInput", Fi);
|
|
3342
3403
|
}
|
|
3343
3404
|
};
|
|
3344
3405
|
export {
|
|
3345
|
-
|
|
3406
|
+
Sn as AiAssist,
|
|
3346
3407
|
Fi as VoiceInput,
|
|
3347
|
-
|
|
3408
|
+
os as clearPageThreadId,
|
|
3348
3409
|
Ui as closeAiAssist,
|
|
3349
3410
|
el as collapsePageAssist,
|
|
3350
3411
|
ji as default,
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3412
|
+
Ct as getAiAssistMode,
|
|
3413
|
+
an as getPageContextSnapshot,
|
|
3414
|
+
Be as getPageModule,
|
|
3415
|
+
Rt as getPageThreadId,
|
|
3355
3416
|
Ki as initAiAssist,
|
|
3356
|
-
|
|
3357
|
-
|
|
3417
|
+
yn as isAiAssistPageMode,
|
|
3418
|
+
ln as isAiAssistVisible,
|
|
3358
3419
|
Yi as mountAiAssist,
|
|
3359
3420
|
tl as openAiAssist,
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3421
|
+
_t as refreshAiPanelContext,
|
|
3422
|
+
ks as setAiAssistMode,
|
|
3423
|
+
on as setAiAssistVisible,
|
|
3363
3424
|
nl as setPageModule,
|
|
3364
|
-
|
|
3365
|
-
|
|
3425
|
+
Tt as setPageThreadId,
|
|
3426
|
+
ps as subscribeAiAssistState,
|
|
3366
3427
|
sl as toggleAiAssist,
|
|
3367
3428
|
Qi as unmountAiAssist
|
|
3368
3429
|
};
|