@somecat/ai-assist-sdk 1.1.26 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,79 +1,79 @@
1
- import { defineComponent as ee, ref as C, watch as se, onUnmounted as Ae, openBlock as m, createElementBlock as k, normalizeClass as X, createElementVNode as n, toDisplayString as V, createVNode as Y, Transition as Ge, withCtx as Xe, createTextVNode as Je, createCommentVNode as _, reactive as ne, Fragment as I, createStaticVNode as qe, renderList as ve, unref as D, createBlock as Z, Teleport as Le, withModifiers as be, computed as F, onMounted as j, onBeforeUnmount as Ne, nextTick as K, normalizeStyle as Se, withKeys as Ue, withDirectives as re, vShow as he, vModelText as je, createApp as ze } from "vue";
2
- import { u as De, E as He, C as Ke, l as de, a as _e, f as Oe, n as Ze, z as Ie, e as Pe, h as et, B as tt, j as nt, F as st, m as ot, g as at, p as it, c as $e, D as lt, w as ct, G as rt, x as Ve } from "../chunks/engine-DxdqzC3A.mjs";
3
- import { f as ut, s as ue, b as We, a as vt, c as dt } from "../chunks/index-CgnkZbtP.mjs";
4
- import { SearchOutlined as gt, CheckOutlined as mt, CopyOutlined as ht, RedoOutlined as pt, CloseOutlined as ft } from "@ant-design/icons-vue";
5
- import { Icon as J } from "@iconify/vue";
6
- const yt = "data:image/png;base64,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", wt = { class: "thinking-block__title" }, kt = {
1
+ import { defineComponent as le, ref as k, watch as se, onUnmounted as Te, openBlock as m, createElementBlock as A, normalizeClass as J, createElementVNode as n, toDisplayString as V, createVNode as X, Transition as ut, withCtx as vt, createTextVNode as dt, createCommentVNode as N, computed as Y, reactive as K, Fragment as ie, createStaticVNode as ht, withModifiers as Ce, createBlock as Z, unref as H, renderList as me, Teleport as je, onMounted as ne, onBeforeUnmount as ze, nextTick as te, normalizeStyle as xe, withKeys as mt, withDirectives as de, vShow as we, vModelText as gt, createApp as pt } from "vue";
2
+ import { u as Xe, E as Fe, C as ft, l as ge, a as Ke, f as Qe, n as yt, z as wt, e as Ge, h as kt, B as Ct, j as At, F as bt, m as St, g as Mt, p as Tt, c as _e, D as xt, w as Et, G as Rt, x as Ze } from "../chunks/engine-DxdqzC3A.mjs";
3
+ import { f as $t, s as he, b as Ie, a as Pt, c as Dt } from "../chunks/index-CgnkZbtP.mjs";
4
+ import { BulbOutlined as Ht, SearchOutlined as Je, CheckOutlined as _t, CopyOutlined as Ot, RedoOutlined as Lt, CloseOutlined as Bt } from "@ant-design/icons-vue";
5
+ import { Icon as j } from "@iconify/vue";
6
+ const Nt = "data:image/png;base64,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", Wt = { class: "thinking-block__title" }, Yt = {
7
7
  key: 0,
8
8
  class: "thinking-block__content"
9
- }, Ct = {
9
+ }, Vt = {
10
10
  key: 0,
11
11
  class: "streaming-cursor"
12
- }, At = /* @__PURE__ */ ee({
12
+ }, Xt = /* @__PURE__ */ le({
13
13
  __name: "ThinkingBlock",
14
14
  props: {
15
15
  content: {},
16
16
  isStreaming: { type: Boolean }
17
17
  },
18
- setup(e) {
19
- const p = e, h = C(!1);
20
- function u() {
21
- h.value = !h.value;
18
+ setup(t) {
19
+ const C = t, f = k(!1);
20
+ function h() {
21
+ f.value = !f.value;
22
22
  }
23
- const l = C(p.content), c = C(p.content.length), i = C(0);
24
- let s = 0, a = 0;
25
- function d() {
26
- if (s) return;
27
- const v = 80, y = ($) => {
28
- if (a === 0) {
29
- a = $, s = requestAnimationFrame(y);
23
+ const o = k(C.content), r = k(C.content.length), l = k(0);
24
+ let i = 0, u = 0;
25
+ function g() {
26
+ if (i) return;
27
+ const c = 80, y = (P) => {
28
+ if (u === 0) {
29
+ u = P, i = requestAnimationFrame(y);
30
30
  return;
31
31
  }
32
- const M = Math.min($ - a, 100);
33
- a = $;
34
- const P = p.content, t = P.length - c.value;
35
- if (t > 0) {
36
- const E = v + t;
37
- i.value += E * M / 1e3;
38
- const x = Math.floor(i.value);
39
- x > 0 && (i.value -= x, c.value = Math.min(c.value + x, P.length), l.value = P.slice(0, c.value));
32
+ const x = Math.min(P - u, 100);
33
+ u = P;
34
+ const _ = C.content, e = _.length - r.value;
35
+ if (e > 0) {
36
+ const v = c + e;
37
+ l.value += v * x / 1e3;
38
+ const E = Math.floor(l.value);
39
+ E > 0 && (l.value -= E, r.value = Math.min(r.value + E, _.length), o.value = _.slice(0, r.value));
40
40
  } else
41
- i.value = 0;
42
- s = requestAnimationFrame(y);
41
+ l.value = 0;
42
+ i = requestAnimationFrame(y);
43
43
  };
44
- a = 0, s = requestAnimationFrame(y);
44
+ u = 0, i = requestAnimationFrame(y);
45
45
  }
46
- function f() {
47
- s && (cancelAnimationFrame(s), s = 0);
46
+ function D() {
47
+ i && (cancelAnimationFrame(i), i = 0);
48
48
  }
49
- function A() {
50
- f(), l.value = p.content, c.value = p.content.length, i.value = 0;
49
+ function $() {
50
+ D(), o.value = C.content, r.value = C.content.length, l.value = 0;
51
51
  }
52
52
  return se(
53
- () => p.content,
53
+ () => C.content,
54
54
  () => {
55
- p.isStreaming || A();
55
+ C.isStreaming || $();
56
56
  }
57
57
  ), se(
58
- () => p.isStreaming,
59
- (v) => {
60
- v ? d() : A();
58
+ () => C.isStreaming,
59
+ (c) => {
60
+ c ? g() : $();
61
61
  },
62
62
  { immediate: !0 }
63
- ), Ae(f), (v, y) => (m(), k("div", {
64
- class: X(["thinking-block", {
65
- "thinking-block--expanded": h.value,
66
- "thinking-block--active": e.isStreaming
63
+ ), Te(D), (c, y) => (m(), A("div", {
64
+ class: J(["thinking-block", {
65
+ "thinking-block--expanded": f.value,
66
+ "thinking-block--active": t.isStreaming
67
67
  }])
68
68
  }, [
69
69
  n("div", {
70
70
  class: "thinking-block__header",
71
- onClick: u
71
+ onClick: h
72
72
  }, [
73
73
  y[1] || (y[1] = n("span", { class: "thinking-block__indicator" }, null, -1)),
74
- n("span", wt, V(e.isStreaming ? "深度思考中" : "深度思考"), 1),
75
- (m(), k("svg", {
76
- class: X(["thinking-block__arrow", { "thinking-block__arrow--down": h.value }]),
74
+ n("span", Wt, V(t.isStreaming ? "深度思考中" : "深度思考"), 1),
75
+ (m(), A("svg", {
76
+ class: J(["thinking-block__arrow", { "thinking-block__arrow--down": f.value }]),
77
77
  viewBox: "0 0 24 24",
78
78
  width: "14",
79
79
  height: "14",
@@ -86,39 +86,42 @@ const yt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
86
86
  n("polyline", { points: "6 9 12 15 18 9" }, null, -1)
87
87
  ])], 2))
88
88
  ]),
89
- Y(Ge, { name: "thinking-expand" }, {
90
- default: Xe(() => [
91
- h.value ? (m(), k("div", kt, [
92
- Je(V(l.value), 1),
93
- e.isStreaming ? (m(), k("span", Ct)) : _("", !0)
94
- ])) : _("", !0)
89
+ X(ut, { name: "thinking-expand" }, {
90
+ default: vt(() => [
91
+ f.value ? (m(), A("div", Yt, [
92
+ dt(V(o.value), 1),
93
+ t.isStreaming ? (m(), A("span", Vt)) : N("", !0)
94
+ ])) : N("", !0)
95
95
  ]),
96
96
  _: 1
97
97
  })
98
98
  ], 2));
99
99
  }
100
- }), bt = {
100
+ }), Ft = {
101
101
  key: 0,
102
102
  class: "message-content ba-markdown"
103
- }, St = { class: "agent-thought__spinner" }, Tt = { class: "agent-thought__text" }, Et = { key: 2 }, Rt = ["innerHTML"], Mt = {
104
- key: 0,
103
+ }, Qt = { class: "thought-collapse-bar__text" }, Gt = {
104
+ key: 2,
105
+ class: "thought-collapse-bar__duration"
106
+ }, Jt = { class: "thought-collapse-bar__action" }, Ut = { class: "agent-thought__spinner" }, qt = { class: "agent-thought__text" }, jt = { key: 2 }, zt = ["innerHTML"], Kt = {
107
+ key: 1,
105
108
  class: "streaming-cursor"
106
- }, $t = ["innerHTML"], xt = {
109
+ }, Zt = ["innerHTML"], It = {
107
110
  key: 0,
108
111
  class: "streaming-cursor"
109
- }, Dt = {
112
+ }, en = {
110
113
  key: 3,
111
114
  class: "message-error"
112
- }, Ht = {
115
+ }, tn = {
113
116
  key: 4,
114
117
  class: "message-toolbar"
115
- }, Ot = ["data-tooltip"], Pt = {
118
+ }, nn = ["data-tooltip"], sn = {
116
119
  class: "tooltip-enhanced",
117
120
  "data-tooltip": "重新回答"
118
- }, Bt = {
121
+ }, an = {
119
122
  key: 1,
120
123
  class: "message-content"
121
- }, Lt = ["src"], Nt = /* @__PURE__ */ ee({
124
+ }, on = ["src"], ln = /* @__PURE__ */ le({
122
125
  __name: "MessageItem",
123
126
  props: {
124
127
  msg: {},
@@ -129,147 +132,196 @@ const yt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
129
132
  setMessageRef: { type: Function }
130
133
  },
131
134
  emits: ["regenerate"],
132
- setup(e, { emit: p }) {
133
- const h = ne(/* @__PURE__ */ new Map()), u = C("");
134
- function l(s) {
135
- const a = s.target;
136
- a.tagName === "IMG" && (u.value = a.src);
135
+ setup(t, { emit: C }) {
136
+ const f = t, h = Y(
137
+ () => f.msg.status === f.STATUS.COMPLETED || f.msg.status === f.STATUS.STOP
138
+ ), o = k(!1);
139
+ se(h, (e) => {
140
+ e && (o.value = !1);
141
+ });
142
+ const r = Y(
143
+ () => {
144
+ var e;
145
+ return ((e = f.msg.segments) == null ? void 0 : e.filter((v) => v.type === "thinking" || v.type === "agent_thought")) ?? [];
146
+ }
147
+ ), l = Y(() => r.value.length > 0), i = Y(() => r.value.some((e) => e.type === "thinking")), u = Y(() => {
148
+ const e = [];
149
+ return i.value && e.push("深度思考"), r.value.some((v) => v.type === "agent_thought") && e.push("工具调用"), e.join(" · ") || "思考过程";
150
+ }), g = Y(() => !h.value || o.value), D = Y(
151
+ () => r.value.reduce((e, v) => e + (v.duration ?? 0), 0)
152
+ );
153
+ function $(e) {
154
+ 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`;
137
155
  }
138
- function c() {
139
- u.value = "";
156
+ const c = K(/* @__PURE__ */ new Map()), y = k("");
157
+ function P(e) {
158
+ const v = e.target;
159
+ v.tagName === "IMG" && (y.value = v.src);
140
160
  }
141
- function i(s, a) {
142
- var d;
161
+ function x() {
162
+ y.value = "";
163
+ }
164
+ function _(e, v) {
165
+ var E;
143
166
  try {
144
- let f = s.content;
145
- if (!f && ((d = s.segments) != null && d.length) && (f = s.segments.filter((A) => A.type !== "thinking" && A.type !== "agent_thought").map((A) => A.content).join(`
146
- `)), f) {
147
- const { copy: A } = Ke();
148
- A(f), h.set(a, !0), setTimeout(() => h.set(a, !1), 2e3);
167
+ let b = e.content;
168
+ if (!b && ((E = e.segments) != null && E.length) && (b = e.segments.filter((s) => s.type !== "thinking" && s.type !== "agent_thought").map((s) => s.content).join(`
169
+ `)), b) {
170
+ const { copy: s } = ft();
171
+ s(b), c.set(v, !0), setTimeout(() => c.set(v, !1), 2e3);
149
172
  }
150
173
  } catch {
151
174
  }
152
175
  }
153
- return (s, a) => {
154
- var d;
155
- return m(), k("div", {
156
- class: X(["message", `${e.msg.type}-message`])
176
+ return (e, v) => {
177
+ var E;
178
+ return m(), A("div", {
179
+ class: J(["message", `${t.msg.type}-message`])
157
180
  }, [
158
- e.msg.type === "ai" ? (m(), k(I, { key: 0 }, [
159
- (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING) && !e.msg.thinkingContent && !e.msg.content ? (m(), k("div", bt, [...a[3] || (a[3] = [
160
- qe('<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)
161
- ])])) : _("", !0),
162
- e.msg.segments && e.msg.segments.length ? (m(), k("div", {
181
+ t.msg.type === "ai" ? (m(), A(ie, { key: 0 }, [
182
+ (t.msg.status === t.STATUS.THINKING || t.msg.status === t.STATUS.RETHINKING) && !t.msg.thinkingContent && !t.msg.content ? (m(), A("div", Ft, [...v[4] || (v[4] = [
183
+ ht('<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)
184
+ ])])) : N("", !0),
185
+ t.msg.segments && t.msg.segments.length ? (m(), A("div", {
163
186
  key: 1,
164
187
  class: "message-content ba-markdown",
165
- ref: (f) => e.setMessageRef(f, e.index),
166
- onClick: l
188
+ ref: (b) => t.setMessageRef(b, t.index),
189
+ onClick: P
167
190
  }, [
168
- (m(!0), k(I, null, ve(e.msg.segments, (f, A) => (m(), k(I, { key: A }, [
169
- f.type === "agent_thought" ? (m(), k("div", {
191
+ h.value && l.value ? (m(), A("div", {
192
+ key: 0,
193
+ class: J(["thought-collapse-bar", { "thought-collapse-bar--expanded": o.value }]),
194
+ onClick: v[0] || (v[0] = Ce((b) => o.value = !o.value, ["stop"]))
195
+ }, [
196
+ i.value ? (m(), Z(H(Ht), {
170
197
  key: 0,
171
- class: X(["agent-thought", { "agent-thought--done": f.duration != null }])
198
+ class: "thought-collapse-bar__icon"
199
+ })) : (m(), Z(H(Je), {
200
+ key: 1,
201
+ class: "thought-collapse-bar__icon"
202
+ })),
203
+ n("span", Qt, V(u.value), 1),
204
+ D.value > 0 ? (m(), A("span", Gt, V($(D.value)), 1)) : N("", !0),
205
+ n("span", Jt, V(o.value ? "收起" : "查看"), 1),
206
+ (m(), A("svg", {
207
+ class: J(["thought-collapse-bar__arrow", { "thought-collapse-bar__arrow--down": o.value }]),
208
+ viewBox: "0 0 24 24",
209
+ width: "12",
210
+ height: "12",
211
+ fill: "none",
212
+ stroke: "currentColor",
213
+ "stroke-width": "2.5",
214
+ "stroke-linecap": "round",
215
+ "stroke-linejoin": "round"
216
+ }, [...v[5] || (v[5] = [
217
+ n("polyline", { points: "6 9 12 15 18 9" }, null, -1)
218
+ ])], 2))
219
+ ], 2)) : N("", !0),
220
+ (m(!0), A(ie, null, me(t.msg.segments, (b, s) => (m(), A(ie, { key: s }, [
221
+ b.type === "agent_thought" && g.value ? (m(), A("div", {
222
+ key: 0,
223
+ class: J(["agent-thought", { "agent-thought--done": b.duration != null }])
172
224
  }, [
173
- n("span", St, [
174
- Y(D(gt))
225
+ n("span", Ut, [
226
+ X(H(Je))
175
227
  ]),
176
- n("span", Tt, V(f.duration != null ? "工具调用" : "工具调用中..."), 1)
177
- ], 2)) : f.type === "thinking" ? (m(), Z(At, {
228
+ n("span", qt, V(b.duration != null ? "工具调用" : "工具调用中..."), 1)
229
+ ], 2)) : b.type === "thinking" && g.value ? (m(), Z(Xt, {
178
230
  key: 1,
179
- content: f.content,
180
- "is-streaming": f.duration == null && (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING)
181
- }, null, 8, ["content", "is-streaming"])) : (m(), k("div", Et, [
231
+ content: b.content,
232
+ "is-streaming": b.duration == null && (t.msg.status === t.STATUS.THINKING || t.msg.status === t.STATUS.RETHINKING)
233
+ }, null, 8, ["content", "is-streaming"])) : b.type === "answer" ? (m(), A("div", jt, [
182
234
  n("div", {
183
- innerHTML: D(De)(D(He)(e.getSegmentDisplayContent(e.index, A, f, e.msg)))
184
- }, null, 8, Rt)
185
- ]))
235
+ innerHTML: H(Xe)(H(Fe)(t.getSegmentDisplayContent(t.index, s, b, t.msg)))
236
+ }, null, 8, zt)
237
+ ])) : N("", !0)
186
238
  ], 64))), 128)),
187
- e.msg.status === e.STATUS.ANSWERING ? (m(), k("span", Mt)) : _("", !0)
188
- ], 512)) : _("", !0),
189
- !((d = e.msg.segments) != null && d.length) && e.msg.content ? (m(), k("div", {
239
+ t.msg.status === t.STATUS.ANSWERING ? (m(), A("span", Kt)) : N("", !0)
240
+ ], 512)) : N("", !0),
241
+ !((E = t.msg.segments) != null && E.length) && t.msg.content ? (m(), A("div", {
190
242
  key: 2,
191
243
  class: "message-content ba-markdown",
192
- ref: (f) => e.setMessageRef(f, e.index),
193
- onClick: l
244
+ ref: (b) => t.setMessageRef(b, t.index),
245
+ onClick: P
194
246
  }, [
195
247
  n("div", {
196
- innerHTML: D(De)(D(He)(e.displayedContent.get(e.index) ?? e.msg.content))
197
- }, null, 8, $t),
198
- e.msg.status === e.STATUS.ANSWERING ? (m(), k("span", xt)) : _("", !0)
199
- ], 512)) : _("", !0),
200
- e.msg.errorMessage ? (m(), k("div", Dt, [
201
- a[4] || (a[4] = n("span", { class: "message-error__icon" }, "⚠️", -1)),
202
- n("span", null, V(e.msg.errorMessage), 1)
203
- ])) : _("", !0),
204
- e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP ? (m(), k("div", Ht, [
248
+ innerHTML: H(Xe)(H(Fe)(t.displayedContent.get(t.index) ?? t.msg.content))
249
+ }, null, 8, Zt),
250
+ t.msg.status === t.STATUS.ANSWERING ? (m(), A("span", It)) : N("", !0)
251
+ ], 512)) : N("", !0),
252
+ t.msg.errorMessage ? (m(), A("div", en, [
253
+ v[6] || (v[6] = n("span", { class: "message-error__icon" }, "⚠️", -1)),
254
+ n("span", null, V(t.msg.errorMessage), 1)
255
+ ])) : N("", !0),
256
+ t.msg.status === t.STATUS.COMPLETED || t.msg.status === t.STATUS.STOP ? (m(), A("div", tn, [
205
257
  n("div", {
206
258
  class: "tooltip-enhanced",
207
- "data-tooltip": h.get(e.index) ? "已复制" : "复制回答"
259
+ "data-tooltip": c.get(t.index) ? "已复制" : "复制回答"
208
260
  }, [
209
- h.get(e.index) ? (m(), Z(D(mt), {
261
+ c.get(t.index) ? (m(), Z(H(_t), {
210
262
  key: 0,
211
263
  class: "message-toolbar__check"
212
- })) : (m(), Z(D(ht), {
264
+ })) : (m(), Z(H(Ot), {
213
265
  key: 1,
214
- onClick: a[0] || (a[0] = (f) => i(e.msg, e.index))
266
+ onClick: v[1] || (v[1] = (b) => _(t.msg, t.index))
215
267
  }))
216
- ], 8, Ot),
217
- n("div", Pt, [
218
- Y(D(pt), {
219
- onClick: a[1] || (a[1] = (f) => s.$emit("regenerate"))
268
+ ], 8, nn),
269
+ n("div", sn, [
270
+ X(H(Lt), {
271
+ onClick: v[2] || (v[2] = (b) => e.$emit("regenerate"))
220
272
  })
221
273
  ])
222
- ])) : _("", !0)
223
- ], 64)) : (m(), k("div", Bt, V(e.msg.content), 1)),
224
- (m(), Z(Le, { to: "#ai-assist-root" }, [
225
- u.value ? (m(), k("div", {
274
+ ])) : N("", !0)
275
+ ], 64)) : (m(), A("div", an, V(t.msg.content), 1)),
276
+ (m(), Z(je, { to: "#ai-assist-root" }, [
277
+ y.value ? (m(), A("div", {
226
278
  key: 0,
227
279
  class: "ai-image-preview-overlay",
228
- onClick: c
280
+ onClick: x
229
281
  }, [
230
282
  n("img", {
231
- src: u.value,
283
+ src: y.value,
232
284
  class: "ai-image-preview-overlay__img",
233
- onClick: a[2] || (a[2] = be(() => {
285
+ onClick: v[3] || (v[3] = Ce(() => {
234
286
  }, ["stop"]))
235
- }, null, 8, Lt),
287
+ }, null, 8, on),
236
288
  n("button", {
237
289
  class: "ai-image-preview-overlay__close",
238
- onClick: be(c, ["stop"])
290
+ onClick: Ce(x, ["stop"])
239
291
  }, [
240
- Y(D(ft))
292
+ X(H(Bt))
241
293
  ])
242
- ])) : _("", !0)
294
+ ])) : N("", !0)
243
295
  ]))
244
296
  ], 2);
245
297
  };
246
298
  }
247
- }), _t = {
299
+ }), cn = {
248
300
  key: 0,
249
301
  class: "input-container voice-mode"
250
- }, Vt = {
302
+ }, rn = {
251
303
  key: 0,
252
304
  class: "final"
253
- }, Wt = {
305
+ }, un = {
254
306
  key: 1,
255
307
  class: "interim"
256
- }, Yt = {
308
+ }, vn = {
257
309
  key: 2,
258
310
  class: "placeholder"
259
- }, Ft = ["data-tooltip"], Qt = {
311
+ }, dn = ["data-tooltip"], hn = {
260
312
  key: 0,
261
313
  class: "moveTB"
262
- }, Gt = {
314
+ }, mn = {
263
315
  key: 1,
264
316
  class: "input-container"
265
- }, Xt = ["value", "disabled"], Jt = {
317
+ }, gn = ["value", "disabled"], pn = {
266
318
  key: 0,
267
319
  class: "tooltip-enhanced stop",
268
320
  "data-tooltip": "停止生成"
269
- }, qt = ["data-tooltip"], Ut = {
321
+ }, fn = ["data-tooltip"], yn = {
270
322
  key: 3,
271
323
  class: "moveTB"
272
- }, jt = /* @__PURE__ */ ee({
324
+ }, wn = /* @__PURE__ */ le({
273
325
  __name: "ChatInput",
274
326
  props: {
275
327
  modelValue: {},
@@ -279,673 +331,676 @@ const yt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
279
331
  isAtBottom: { type: Boolean }
280
332
  },
281
333
  emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
282
- setup(e, { emit: p }) {
283
- const h = e, u = p, c = de().voice, i = C(!1), s = C(""), a = C(""), d = C("idle"), f = C(0), A = C(null);
284
- let v = null;
285
- const y = F(() => d.value === "connecting"), $ = F(
286
- () => d.value === "recording" || d.value === "stopping"
287
- ), M = F(
288
- () => !!(s.value.trim() || a.value.trim())
289
- ), P = F(
290
- () => !!c && !h.modelValue.trim() && !h.isGenerating
334
+ setup(t, { emit: C }) {
335
+ const f = t, h = C, r = ge().voice, l = k(!1), i = k(""), u = k(""), g = k("idle"), D = k(0), $ = k(null);
336
+ let c = null;
337
+ const y = Y(() => g.value === "connecting"), P = Y(
338
+ () => g.value === "recording" || g.value === "stopping"
339
+ ), x = Y(
340
+ () => !!(i.value.trim() || u.value.trim())
341
+ ), _ = Y(
342
+ () => !!r && !f.modelValue.trim() && !f.isGenerating
291
343
  );
292
- function t() {
293
- c && (v = new _e(c, {
294
- onStatusChange: (o) => {
295
- d.value = o;
344
+ function e() {
345
+ r && (c = new Ke(r, {
346
+ onStatusChange: (s) => {
347
+ g.value = s;
296
348
  },
297
- onInterim: (o) => {
298
- a.value = o;
349
+ onInterim: (s) => {
350
+ u.value = s;
299
351
  },
300
- onFinal: (o) => {
301
- s.value += o, a.value = "";
352
+ onFinal: (s) => {
353
+ i.value += s, u.value = "";
302
354
  },
303
- onLevel: (o) => {
304
- f.value = o;
355
+ onLevel: (s) => {
356
+ D.value = s;
305
357
  },
306
358
  onError: () => {
307
- i.value = !1;
359
+ l.value = !1;
308
360
  }
309
361
  }));
310
362
  }
311
- j(t), Ne(() => {
312
- v == null || v.destroy(), v = null;
363
+ ne(e), ze(() => {
364
+ c == null || c.destroy(), c = null;
313
365
  }), se(
314
- () => [c == null ? void 0 : c.appId, c == null ? void 0 : c.appKey, c == null ? void 0 : c.devPid],
366
+ () => [r == null ? void 0 : r.appId, r == null ? void 0 : r.appKey, r == null ? void 0 : r.devPid],
315
367
  () => {
316
- v == null || v.destroy(), t();
368
+ c == null || c.destroy(), e();
317
369
  }
318
- ), se([s, a], () => {
319
- K(() => {
320
- A.value && (A.value.scrollTop = A.value.scrollHeight);
370
+ ), se([i, u], () => {
371
+ te(() => {
372
+ $.value && ($.value.scrollTop = $.value.scrollHeight);
321
373
  });
322
374
  });
323
- async function E() {
324
- if (v) {
325
- s.value = "", a.value = "", f.value = 0, i.value = !0;
375
+ async function v() {
376
+ if (c) {
377
+ i.value = "", u.value = "", D.value = 0, l.value = !0;
326
378
  try {
327
- await v.start();
379
+ await c.start();
328
380
  } catch {
329
- i.value = !1;
381
+ l.value = !1;
330
382
  }
331
383
  }
332
384
  }
333
- function x() {
334
- v == null || v.cancel(), i.value = !1, s.value = "", a.value = "", f.value = 0;
385
+ function E() {
386
+ c == null || c.cancel(), l.value = !1, i.value = "", u.value = "", D.value = 0;
335
387
  }
336
- function H() {
337
- const o = (s.value + a.value).trim();
338
- o && (v == null || v.stop(), i.value = !1, u("update:modelValue", o), setTimeout(() => u("send"), 0));
388
+ function b() {
389
+ const s = (i.value + u.value).trim();
390
+ s && (c == null || c.stop(), l.value = !1, h("update:modelValue", s), setTimeout(() => h("send"), 0));
339
391
  }
340
- return (o, g) => i.value ? (m(), k("div", _t, [
392
+ return (s, p) => l.value ? (m(), A("div", cn, [
341
393
  n("div", {
342
394
  class: "voice-visual",
343
- style: Se({
344
- transform: `scale(${1 + f.value * 1.2})`,
345
- opacity: 0.35 + f.value * 0.65,
346
- background: $.value ? `rgb(${74 + f.value * 181}, ${172 - f.value * 128}, ${178 - f.value * 128})` : "var(--ai-accent)"
395
+ style: xe({
396
+ transform: `scale(${1 + D.value * 1.2})`,
397
+ opacity: 0.35 + D.value * 0.65,
398
+ background: P.value ? `rgb(${74 + D.value * 181}, ${172 - D.value * 128}, ${178 - D.value * 128})` : "var(--ai-accent)"
347
399
  })
348
400
  }, null, 4),
349
401
  n("div", {
350
402
  class: "voice-text",
351
403
  ref_key: "voiceTextEl",
352
- ref: A
404
+ ref: $
353
405
  }, [
354
- s.value ? (m(), k("span", Vt, V(s.value), 1)) : _("", !0),
355
- a.value ? (m(), k("span", Wt, V(a.value), 1)) : _("", !0),
356
- !s.value && !a.value ? (m(), k("span", Yt, V(y.value ? "连接中…" : "正在聆听…"), 1)) : _("", !0)
406
+ i.value ? (m(), A("span", rn, V(i.value), 1)) : N("", !0),
407
+ u.value ? (m(), A("span", un, V(u.value), 1)) : N("", !0),
408
+ !i.value && !u.value ? (m(), A("span", vn, V(y.value ? "连接中…" : "正在聆听…"), 1)) : N("", !0)
357
409
  ], 512),
358
410
  n("div", {
359
411
  class: "tooltip-enhanced voice-close",
360
412
  "data-tooltip": "关闭",
361
- onClick: x
413
+ onClick: E
362
414
  }, [
363
- Y(D(J), {
415
+ X(H(j), {
364
416
  class: "op-icon",
365
417
  icon: "heroicons-solid:x-mark"
366
418
  })
367
419
  ]),
368
420
  n("div", {
369
- class: X(["tooltip-enhanced voice-send", { disabled: !M.value }]),
370
- "data-tooltip": M.value ? "发送" : "未识别到文字",
371
- onClick: g[0] || (g[0] = (S) => M.value && H())
421
+ class: J(["tooltip-enhanced voice-send", { disabled: !x.value }]),
422
+ "data-tooltip": x.value ? "发送" : "未识别到文字",
423
+ onClick: p[0] || (p[0] = (w) => x.value && b())
372
424
  }, [
373
- Y(D(J), {
425
+ X(H(j), {
374
426
  class: "op-icon",
375
427
  icon: "fluent-color:send-16"
376
428
  })
377
- ], 10, Ft),
378
- e.hasScroll && !e.isAtBottom ? (m(), k("div", Qt, [
379
- Y(D(J), {
429
+ ], 10, dn),
430
+ t.hasScroll && !t.isAtBottom ? (m(), A("div", hn, [
431
+ X(H(j), {
380
432
  class: "op-icon",
381
433
  icon: "ep:bottom",
382
- onClick: g[1] || (g[1] = (S) => o.$emit("scroll-to-bottom"))
434
+ onClick: p[1] || (p[1] = (w) => s.$emit("scroll-to-bottom"))
383
435
  })
384
- ])) : _("", !0)
385
- ])) : (m(), k("div", Gt, [
436
+ ])) : N("", !0)
437
+ ])) : (m(), A("div", mn, [
386
438
  n("input", {
387
- value: e.modelValue,
439
+ value: t.modelValue,
388
440
  type: "text",
389
441
  placeholder: "给AI助手发送消息...",
390
- onInput: g[2] || (g[2] = (S) => o.$emit("update:modelValue", S.target.value)),
391
- onKeyup: g[3] || (g[3] = Ue((S) => e.modelValue.trim() && o.$emit("send"), ["enter"])),
392
- disabled: e.isGenerating
393
- }, null, 40, Xt),
394
- e.isGenerating && e.lastUserMessage ? (m(), k("div", Jt, [
395
- Y(D(J), {
442
+ onInput: p[2] || (p[2] = (w) => s.$emit("update:modelValue", w.target.value)),
443
+ onKeyup: p[3] || (p[3] = mt((w) => t.modelValue.trim() && s.$emit("send"), ["enter"])),
444
+ disabled: t.isGenerating
445
+ }, null, 40, gn),
446
+ t.isGenerating && t.lastUserMessage ? (m(), A("div", pn, [
447
+ X(H(j), {
396
448
  class: "op-icon stop-icon",
397
449
  icon: "heroicons-solid:stop",
398
- onClick: g[4] || (g[4] = (S) => o.$emit("stop"))
450
+ onClick: p[4] || (p[4] = (w) => s.$emit("stop"))
399
451
  })
400
- ])) : P.value ? (m(), k("div", {
452
+ ])) : _.value ? (m(), A("div", {
401
453
  key: 1,
402
454
  class: "tooltip-enhanced send voice",
403
455
  "data-tooltip": "语音输入",
404
- onClick: E
456
+ onClick: v
405
457
  }, [
406
- Y(D(J), {
458
+ X(H(j), {
407
459
  class: "op-icon",
408
460
  icon: "mingcute:voice-line"
409
461
  })
410
- ])) : (m(), k("div", {
462
+ ])) : (m(), A("div", {
411
463
  key: 2,
412
- class: X(["tooltip-enhanced send", { disabled: !e.modelValue.trim() }]),
413
- "data-tooltip": e.modelValue.trim() ? "开始回答" : "请输入你的问题"
464
+ class: J(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
465
+ "data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
414
466
  }, [
415
- Y(D(J), {
467
+ X(H(j), {
416
468
  class: "op-icon",
417
469
  icon: "fluent-color:send-16",
418
- onClick: g[5] || (g[5] = (S) => e.modelValue.trim() && o.$emit("send"))
470
+ onClick: p[5] || (p[5] = (w) => t.modelValue.trim() && s.$emit("send"))
419
471
  })
420
- ], 10, qt)),
421
- e.hasScroll && !e.isAtBottom ? (m(), k("div", Ut, [
422
- Y(D(J), {
472
+ ], 10, fn)),
473
+ t.hasScroll && !t.isAtBottom ? (m(), A("div", yn, [
474
+ X(H(j), {
423
475
  class: "op-icon",
424
476
  icon: "ep:bottom",
425
- onClick: g[6] || (g[6] = (S) => o.$emit("scroll-to-bottom"))
477
+ onClick: p[6] || (p[6] = (w) => s.$emit("scroll-to-bottom"))
426
478
  })
427
- ])) : _("", !0)
479
+ ])) : N("", !0)
428
480
  ]));
429
481
  }
430
482
  });
431
- function zt(e) {
432
- const p = C(!0), h = C(!1);
433
- function u() {
434
- K(() => {
435
- e.value && (e.value.scrollTop = e.value.scrollHeight);
483
+ function kn(t) {
484
+ const C = k(!0), f = k(!1);
485
+ function h() {
486
+ te(() => {
487
+ t.value && (t.value.scrollTop = t.value.scrollHeight);
436
488
  });
437
489
  }
438
- function l() {
439
- if (!e.value) return;
440
- const c = e.value, i = c.scrollTop + c.clientHeight >= c.scrollHeight - 1, s = c.scrollHeight > c.clientHeight;
441
- p.value = i, h.value = s;
490
+ function o() {
491
+ if (!t.value) return;
492
+ const r = t.value, l = r.scrollTop + r.clientHeight >= r.scrollHeight - 1, i = r.scrollHeight > r.clientHeight;
493
+ C.value = l, f.value = i;
442
494
  }
443
- return { isAtBottom: p, hasScroll: h, scrollToBottom: u, checkScrollStatus: l };
495
+ return { isAtBottom: C, hasScroll: f, scrollToBottom: h, checkScrollStatus: o };
444
496
  }
445
- function Kt() {
446
- function e(p) {
447
- p.querySelectorAll("pre").forEach((u) => {
448
- if (u.querySelector(".copy-button")) return;
449
- const l = u.querySelector("code");
450
- if (!l) return;
451
- const i = (Array.from(l.classList).find((a) => a.startsWith("language-")) || "").replace("language-", "");
452
- if (i) {
453
- const a = document.createElement("span");
454
- a.className = "code-lang", a.textContent = i, u.appendChild(a);
497
+ function Cn() {
498
+ function t(C) {
499
+ C.querySelectorAll("pre").forEach((h) => {
500
+ if (h.querySelector(".copy-button")) return;
501
+ const o = h.querySelector("code");
502
+ if (!o) return;
503
+ const l = (Array.from(o.classList).find((u) => u.startsWith("language-")) || "").replace("language-", "");
504
+ if (l) {
505
+ const u = document.createElement("span");
506
+ u.className = "code-lang", u.textContent = l, h.appendChild(u);
455
507
  }
456
- const s = document.createElement("button");
457
- s.className = "copy-button", s.textContent = "复制", s.onclick = () => {
458
- navigator.clipboard.writeText(l.textContent || "").then(() => {
459
- s.textContent = "已复制", setTimeout(() => {
460
- s.textContent = "复制";
508
+ const i = document.createElement("button");
509
+ i.className = "copy-button", i.textContent = "复制", i.onclick = () => {
510
+ navigator.clipboard.writeText(o.textContent || "").then(() => {
511
+ i.textContent = "已复制", setTimeout(() => {
512
+ i.textContent = "复制";
461
513
  }, 2e3);
462
514
  });
463
- }, u.appendChild(s);
515
+ }, h.appendChild(i);
464
516
  });
465
517
  }
466
- return { enhanceCodeBlocks: e };
518
+ return { enhanceCodeBlocks: t };
467
519
  }
468
- function Zt(e) {
469
- let p = null, h = 0;
470
- function u(c) {
471
- p = c(p || [...e.value]), h || (h = requestAnimationFrame(() => {
472
- h = 0, p && (e.value = p, p = null);
520
+ function An(t) {
521
+ let C = null, f = 0;
522
+ function h(r) {
523
+ C = r(C || [...t.value]), f || (f = requestAnimationFrame(() => {
524
+ f = 0, C && (t.value = C, C = null);
473
525
  }));
474
526
  }
475
- function l() {
476
- h && (cancelAnimationFrame(h), h = 0), p && (e.value = p, p = null);
527
+ function o() {
528
+ f && (cancelAnimationFrame(f), f = 0), C && (t.value = C, C = null);
477
529
  }
478
- return { batchMessagesUpdate: u, flushMessagesBatch: l };
530
+ return { batchMessagesUpdate: h, flushMessagesBatch: o };
479
531
  }
480
- function It(e, p, h) {
481
- const u = ne(/* @__PURE__ */ new Map()), l = C(/* @__PURE__ */ new Map()), c = C(/* @__PURE__ */ new Map());
482
- let i = 0, s = 0;
483
- function a() {
484
- if (i) return;
485
- const v = 50, y = 100, $ = (M) => {
486
- if (s === 0) {
487
- s = M, i = requestAnimationFrame($);
532
+ function bn(t, C, f) {
533
+ const h = K(/* @__PURE__ */ new Map()), o = k(/* @__PURE__ */ new Map()), r = k(/* @__PURE__ */ new Map());
534
+ let l = 0, i = 0;
535
+ function u() {
536
+ if (l) return;
537
+ const c = 50, y = 100, P = (x) => {
538
+ if (i === 0) {
539
+ i = x, l = requestAnimationFrame(P);
488
540
  return;
489
541
  }
490
- const P = Math.min(M - s, 100);
491
- s = M;
492
- let t = !1;
493
- if (e.value.forEach((x, H) => {
494
- if (x.type !== "ai" || x.status !== h) return;
495
- const o = x.content, g = l.value.get(H) ?? 0, S = o.length - g;
496
- if (S > 0) {
497
- t = !0;
498
- const T = Math.min(v + S, y), r = (c.value.get(H) ?? 0) + T * P / 1e3, b = Math.floor(r);
499
- if (b > 0) {
500
- c.value.set(H, r - b);
501
- const R = Math.min(g + b, o.length);
502
- l.value.set(H, R), u.set(H, o.slice(0, R));
542
+ const _ = Math.min(x - i, 100);
543
+ i = x;
544
+ let e = !1;
545
+ if (t.value.forEach((E, b) => {
546
+ if (E.type !== "ai" || E.status !== f) return;
547
+ const s = E.content, p = o.value.get(b) ?? 0, w = s.length - p;
548
+ if (w > 0) {
549
+ e = !0;
550
+ const M = Math.min(c + w, y), d = (r.value.get(b) ?? 0) + M * _ / 1e3, S = Math.floor(d);
551
+ if (S > 0) {
552
+ r.value.set(b, d - S);
553
+ const R = Math.min(p + S, s.length);
554
+ o.value.set(b, R), h.set(b, s.slice(0, R));
503
555
  } else
504
- c.value.set(H, r);
556
+ r.value.set(b, d);
505
557
  } else
506
- c.value.set(H, 0);
507
- }), t && p(), !e.value.some((x) => x.type === "ai" && x.status === h)) {
508
- i = 0;
558
+ r.value.set(b, 0);
559
+ }), e && C(), !t.value.some((E) => E.type === "ai" && E.status === f)) {
560
+ l = 0;
509
561
  return;
510
562
  }
511
- i = requestAnimationFrame($);
563
+ l = requestAnimationFrame(P);
512
564
  };
513
- s = 0, i = requestAnimationFrame($);
565
+ i = 0, l = requestAnimationFrame(P);
514
566
  }
515
- function d() {
516
- i && (cancelAnimationFrame(i), i = 0), e.value.forEach((v, y) => {
517
- v.type === "ai" && (u.set(y, v.content), l.value.set(y, v.content.length), c.value.set(y, 0));
567
+ function g() {
568
+ l && (cancelAnimationFrame(l), l = 0), t.value.forEach((c, y) => {
569
+ c.type === "ai" && (h.set(y, c.content), o.value.set(y, c.content.length), r.value.set(y, 0));
518
570
  });
519
571
  }
520
- function f() {
521
- i && (cancelAnimationFrame(i), i = 0);
572
+ function D() {
573
+ l && (cancelAnimationFrame(l), l = 0);
522
574
  }
523
- function A(v, y, $, M) {
524
- if ($.type !== "answer" || M.status !== h) return $.content;
525
- const P = M.segments || [];
526
- if (P.slice(y + 1).some((o) => o.type === "answer")) return $.content;
527
- const E = l.value.get(v);
528
- if (E == null) return $.content;
529
- let x = 0;
530
- for (let o = 0; o < y; o++)
531
- P[o].type === "answer" && (x += P[o].content.length);
532
- const H = x + $.content.length;
533
- return E >= H ? $.content : E <= x ? "" : $.content.slice(0, E - x);
575
+ function $(c, y, P, x) {
576
+ if (P.type !== "answer" || x.status !== f) return P.content;
577
+ const _ = x.segments || [];
578
+ if (_.slice(y + 1).some((s) => s.type === "answer")) return P.content;
579
+ const v = o.value.get(c);
580
+ if (v == null) return P.content;
581
+ let E = 0;
582
+ for (let s = 0; s < y; s++)
583
+ _[s].type === "answer" && (E += _[s].content.length);
584
+ const b = E + P.content.length;
585
+ return v >= b ? P.content : v <= E ? "" : P.content.slice(0, v - E);
534
586
  }
535
- return { displayedContent: u, streamingIndexRef: l, startTypewriter: a, flushTypewriter: d, getSegmentDisplayContent: A, stopTypewriter: f };
587
+ return { displayedContent: h, streamingIndexRef: o, startTypewriter: u, flushTypewriter: g, getSegmentDisplayContent: $, stopTypewriter: D };
536
588
  }
537
- function en({
538
- messages: e,
539
- isGenerating: p,
540
- lastUserMessage: h,
541
- batchMessagesUpdate: u,
542
- flushMessagesBatch: l,
543
- STATUS: c,
544
- cfg: i
589
+ function Sn({
590
+ messages: t,
591
+ isGenerating: C,
592
+ lastUserMessage: f,
593
+ batchMessagesUpdate: h,
594
+ flushMessagesBatch: o,
595
+ STATUS: r,
596
+ cfg: l
545
597
  }) {
546
- const s = C(/* @__PURE__ */ new Map()), a = C(/* @__PURE__ */ new Map()), d = C(/* @__PURE__ */ new Map()), f = C(/* @__PURE__ */ new Map()), A = C(!1);
547
- function v(M) {
548
- const P = s.value.get(M) || [];
549
- u((t) => {
550
- if (t[M]) {
551
- const E = [...t];
552
- return E[M] = { ...E[M], segments: P.map((x) => ({ ...x })) }, E;
598
+ const i = k(/* @__PURE__ */ new Map()), u = k(/* @__PURE__ */ new Map()), g = k(/* @__PURE__ */ new Map()), D = k(/* @__PURE__ */ new Map()), $ = k(!1);
599
+ function c(x) {
600
+ const _ = i.value.get(x) || [];
601
+ h((e) => {
602
+ if (e[x]) {
603
+ const v = [...e];
604
+ return v[x] = { ...v[x], segments: _.map((E) => ({ ...E })) }, v;
553
605
  }
554
- return t;
606
+ return e;
555
607
  });
556
608
  }
557
- function y(M) {
558
- const P = s.value.get(M) || [], t = d.value.get(M);
559
- let E = 0, x = !1;
560
- P.forEach((H) => {
561
- if (H.type === "thinking" && H.duration == null) {
562
- const o = t ? Math.round((Date.now() - t) / 1e3 * 10) / 10 : 0;
563
- H.duration = o, E += o, x = !0;
609
+ function y(x) {
610
+ const _ = i.value.get(x) || [], e = g.value.get(x);
611
+ let v = 0, E = !1;
612
+ _.forEach((b) => {
613
+ if (b.type === "thinking" && b.duration == null) {
614
+ const s = e ? Math.round((Date.now() - e) / 1e3 * 10) / 10 : 0;
615
+ b.duration = s, v += s, E = !0;
564
616
  }
565
- }), x && (s.value.set(M, P), u((H) => {
566
- if (H[M]) {
567
- const o = [...H];
568
- return o[M] = {
569
- ...o[M],
570
- segments: P.map((g) => ({ ...g })),
571
- thinkingDuration: (o[M].thinkingDuration || 0) + E
572
- }, o;
617
+ }), E && (i.value.set(x, _), h((b) => {
618
+ if (b[x]) {
619
+ const s = [...b];
620
+ return s[x] = {
621
+ ...s[x],
622
+ segments: _.map((p) => ({ ...p })),
623
+ thinkingDuration: (s[x].thinkingDuration || 0) + v
624
+ }, s;
573
625
  }
574
- return H;
626
+ return b;
575
627
  }));
576
628
  }
577
- async function $(M, P, t, E, x = !1) {
578
- A.value = !1, s.value.set(t, []), p.value = !0;
629
+ async function P(x, _, e, v, E = !1) {
630
+ $.value = !1, i.value.set(e, []), C.value = !0;
579
631
  try {
580
- const H = i.baseUrl.replace(/\/+$/, "") + "/" + M.replace(/^\/+/, "");
581
- await ut(H, {
632
+ const b = l.baseUrl.replace(/\/+$/, "") + "/" + x.replace(/^\/+/, "");
633
+ await $t(b, {
582
634
  method: "POST",
583
- headers: { "Content-Type": "application/json" },
584
- body: JSON.stringify({ app: i.app ?? 1, data: P }),
585
- signal: E,
635
+ headers: {
636
+ "Content-Type": "application/json",
637
+ Authorization: `Bearer ${l.token}`
638
+ },
639
+ body: JSON.stringify({ app: l.app ?? 1, data: _ }),
640
+ signal: v,
586
641
  openWhenHidden: !0,
587
- async onopen(o) {
588
- o.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", o.status, o.statusText);
642
+ async onopen(s) {
643
+ s.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", s.status, s.statusText);
589
644
  },
590
- onmessage(o) {
591
- var g;
645
+ onmessage(s) {
646
+ var p;
592
647
  try {
593
- let S = o.data || "";
594
- for (; S.startsWith("data:"); )
595
- S = S.replace(/^data:\s*/, "");
596
- if (!S) return;
597
- let T;
648
+ let w = s.data || "";
649
+ for (; w.startsWith("data:"); )
650
+ w = w.replace(/^data:\s*/, "");
651
+ if (!w) return;
652
+ let M;
598
653
  try {
599
- T = JSON.parse(S);
654
+ M = JSON.parse(w);
600
655
  } catch {
601
656
  return;
602
657
  }
603
- switch (T.event) {
658
+ switch (M.event) {
604
659
  case "message_start":
605
- x || (h.value = T.id), a.value.set(t, "answer");
660
+ E || (f.value = M.id), u.value.set(e, "answer");
606
661
  break;
607
662
  case "think_message_output_start": {
608
- d.value.set(t, Date.now()), a.value.set(t, "thinking");
609
- const r = s.value.get(t) || [];
610
- s.value.set(t, [...r, { type: "thinking", content: "" }]), v(t);
663
+ g.value.set(e, Date.now()), u.value.set(e, "thinking");
664
+ const d = i.value.get(e) || [];
665
+ i.value.set(e, [...d, { type: "thinking", content: "" }]), c(e);
611
666
  break;
612
667
  }
613
668
  case "agent_thought": {
614
- const r = T.thought || T.thinking || "", b = s.value.get(t) || [], R = b[b.length - 1];
615
- R && R.type === "agent_thought" ? R.content += r : (a.value.set(t, "agent_thought"), b.push({ type: "agent_thought", content: r }), f.value.set(t, Date.now())), s.value.set(t, b), u((B) => {
616
- if (B[t]) {
617
- const L = [...B];
618
- return L[t] = {
619
- ...L[t],
620
- segments: b.map((N) => ({ ...N })),
621
- thinkingContent: (L[t].thinkingContent || "") + r,
622
- status: c.THINKING
669
+ const d = M.thought || M.thinking || "", S = i.value.get(e) || [], R = S[S.length - 1];
670
+ R && R.type === "agent_thought" ? R.content += d : (u.value.set(e, "agent_thought"), S.push({ type: "agent_thought", content: d }), D.value.set(e, Date.now())), i.value.set(e, S), h((O) => {
671
+ if (O[e]) {
672
+ const L = [...O];
673
+ return L[e] = {
674
+ ...L[e],
675
+ segments: S.map((B) => ({ ...B })),
676
+ thinkingContent: (L[e].thinkingContent || "") + d,
677
+ status: r.THINKING
623
678
  }, L;
624
679
  }
625
- return B;
680
+ return O;
626
681
  });
627
682
  break;
628
683
  }
629
684
  case "think_message": {
630
- const r = T.thinking || T.answer || T.text || "", b = s.value.get(t) || [], R = b[b.length - 1];
631
- R && R.type === "thinking" ? R.content += r : (b.push({ type: "thinking", content: r }), d.value.set(t, Date.now())), s.value.set(t, b), u((B) => {
632
- if (B[t]) {
633
- const L = [...B];
634
- return L[t] = {
635
- ...L[t],
636
- segments: b.map((N) => ({ ...N })),
637
- thinkingContent: (L[t].thinkingContent || "") + r,
638
- status: c.THINKING
685
+ const d = M.thinking || M.answer || M.text || "", S = i.value.get(e) || [], R = S[S.length - 1];
686
+ R && R.type === "thinking" ? R.content += d : (S.push({ type: "thinking", content: d }), g.value.set(e, Date.now())), i.value.set(e, S), h((O) => {
687
+ if (O[e]) {
688
+ const L = [...O];
689
+ return L[e] = {
690
+ ...L[e],
691
+ segments: S.map((B) => ({ ...B })),
692
+ thinkingContent: (L[e].thinkingContent || "") + d,
693
+ status: r.THINKING
639
694
  }, L;
640
695
  }
641
- return B;
696
+ return O;
642
697
  });
643
698
  break;
644
699
  }
645
700
  case "agent_thought_end": {
646
- const r = f.value.get(t), b = r ? Math.round((Date.now() - r) / 1e3 * 10) / 10 : 0, R = s.value.get(t) || [], B = R[R.length - 1];
647
- B && B.type === "agent_thought" && (B.duration = b), s.value.set(t, R), u((L) => {
648
- if (L[t]) {
649
- const N = [...L];
650
- return N[t] = {
651
- ...N[t],
652
- segments: R.map((q) => ({ ...q })),
653
- thinkingDuration: (N[t].thinkingDuration || 0) + b
654
- }, N;
701
+ const d = D.value.get(e), S = d ? Math.round((Date.now() - d) / 1e3 * 10) / 10 : 0, R = i.value.get(e) || [], O = R[R.length - 1];
702
+ O && O.type === "agent_thought" && (O.duration = S), i.value.set(e, R), h((L) => {
703
+ if (L[e]) {
704
+ const B = [...L];
705
+ return B[e] = {
706
+ ...B[e],
707
+ segments: R.map((Q) => ({ ...Q })),
708
+ thinkingDuration: (B[e].thinkingDuration || 0) + S
709
+ }, B;
655
710
  }
656
711
  return L;
657
712
  });
658
713
  break;
659
714
  }
660
715
  case "think_message_output_end": {
661
- const r = d.value.get(t), b = r ? Math.round((Date.now() - r) / 1e3 * 10) / 10 : 0, R = s.value.get(t) || [], B = R[R.length - 1];
662
- B && B.type === "thinking" && (B.duration = b), s.value.set(t, R), u((L) => {
663
- if (L[t]) {
664
- const N = [...L];
665
- return N[t] = {
666
- ...N[t],
667
- segments: R.map((q) => ({ ...q })),
668
- thinkingDuration: (N[t].thinkingDuration || 0) + b
669
- }, N;
716
+ const d = g.value.get(e), S = d ? Math.round((Date.now() - d) / 1e3 * 10) / 10 : 0, R = i.value.get(e) || [], O = R[R.length - 1];
717
+ O && O.type === "thinking" && (O.duration = S), i.value.set(e, R), h((L) => {
718
+ if (L[e]) {
719
+ const B = [...L];
720
+ return B[e] = {
721
+ ...B[e],
722
+ segments: R.map((Q) => ({ ...Q })),
723
+ thinkingDuration: (B[e].thinkingDuration || 0) + S
724
+ }, B;
670
725
  }
671
726
  return L;
672
727
  });
673
728
  break;
674
729
  }
675
730
  case "tool_message": {
676
- const r = T.answer || T.text || T.content || "";
677
- if (!r) break;
678
- const b = s.value.get(t) || [];
679
- b.push({ type: "answer", content: r }), s.value.set(t, b), v(t);
731
+ const d = M.answer || M.text || M.content || "";
732
+ if (!d) break;
733
+ const S = i.value.get(e) || [];
734
+ S.push({ type: "answer", content: d }), i.value.set(e, S), c(e);
680
735
  break;
681
736
  }
682
737
  case "message_output_start":
683
- a.value.set(t, "answer"), y(t);
738
+ u.value.set(e, "answer"), y(e);
684
739
  break;
685
740
  case "message": {
686
- const r = T.answer || "", b = a.value.get(t), R = s.value.get(t) || [], B = R[R.length - 1];
687
- b === "answer" && B && B.type === "answer" ? B.content += r : (y(t), a.value.set(t, "answer"), R.push({ type: "answer", content: r })), s.value.set(t, R);
688
- const L = R.filter((N) => N.type === "answer").map((N) => N.content).join("");
689
- u((N) => {
690
- if (N[t]) {
691
- const q = [...N];
692
- return q[t] = {
693
- ...q[t],
694
- segments: R.map((ge) => ({ ...ge })),
741
+ const d = M.answer || "", S = u.value.get(e), R = i.value.get(e) || [], O = R[R.length - 1];
742
+ S === "answer" && O && O.type === "answer" ? O.content += d : (y(e), u.value.set(e, "answer"), R.push({ type: "answer", content: d })), i.value.set(e, R);
743
+ const L = R.filter((B) => B.type === "answer").map((B) => B.content).join("");
744
+ h((B) => {
745
+ if (B[e]) {
746
+ const Q = [...B];
747
+ return Q[e] = {
748
+ ...Q[e],
749
+ segments: R.map((I) => ({ ...I })),
695
750
  content: L,
696
- status: A.value ? c.STOP : c.ANSWERING
697
- }, q;
751
+ status: $.value ? r.STOP : r.ANSWERING
752
+ }, Q;
698
753
  }
699
- return N;
754
+ return B;
700
755
  });
701
756
  break;
702
757
  }
703
758
  case "message_end": {
704
- l();
705
- const r = [...e.value];
706
- r[t] && (r[t] = { ...r[t], status: A.value ? c.STOP : c.COMPLETED }), e.value = r, p.value = !1;
759
+ o();
760
+ const d = [...t.value];
761
+ d[e] && (d[e] = { ...d[e], status: $.value ? r.STOP : r.COMPLETED }), t.value = d, C.value = !1;
707
762
  break;
708
763
  }
709
764
  case "agent_error":
710
765
  case "message_failed": {
711
- l();
712
- const r = [...e.value];
713
- r[t] && (r[t] = {
714
- ...r[t],
715
- status: c.ERROR,
716
- content: T.error_msg || T.message || "请求失败",
717
- errorMessage: T.error_msg || T.message || "请求失败"
718
- }, e.value = r), p.value = !1;
766
+ o();
767
+ const d = [...t.value];
768
+ d[e] && (d[e] = {
769
+ ...d[e],
770
+ status: r.ERROR,
771
+ content: M.error_msg || M.message || "请求失败",
772
+ errorMessage: M.error_msg || M.message || "请求失败"
773
+ }, t.value = d), C.value = !1;
719
774
  break;
720
775
  }
721
776
  case "message_replace": {
722
- const r = T.answer || "", b = s.value.get(t) || [], R = (g = b.map((B, L) => ({ s: B, i: L })).reverse().find((B) => B.s.type === "answer")) == null ? void 0 : g.i;
723
- R != null ? b[R] = { ...b[R], content: r } : b.push({ type: "answer", content: r }), s.value.set(t, b), u((B) => {
724
- if (B[t]) {
725
- const L = [...B];
726
- return L[t] = {
727
- ...L[t],
728
- segments: b.map((N) => ({ ...N })),
729
- content: r
777
+ const d = M.answer || "", S = i.value.get(e) || [], R = (p = S.map((O, L) => ({ s: O, i: L })).reverse().find((O) => O.s.type === "answer")) == null ? void 0 : p.i;
778
+ R != null ? S[R] = { ...S[R], content: d } : S.push({ type: "answer", content: d }), i.value.set(e, S), h((O) => {
779
+ if (O[e]) {
780
+ const L = [...O];
781
+ return L[e] = {
782
+ ...L[e],
783
+ segments: S.map((B) => ({ ...B })),
784
+ content: d
730
785
  }, L;
731
786
  }
732
- return B;
787
+ return O;
733
788
  });
734
789
  break;
735
790
  }
736
791
  case "message_cost": {
737
- const r = {
738
- inputTokens: T.input_tokens || 0,
739
- outputTokens: T.output_tokens || 0,
740
- latency: T.latency || 0,
741
- latencyFirstResp: T.latency_first_resp
792
+ const d = {
793
+ inputTokens: M.input_tokens || 0,
794
+ outputTokens: M.output_tokens || 0,
795
+ latency: M.latency || 0,
796
+ latencyFirstResp: M.latency_first_resp
742
797
  };
743
- u((b) => {
744
- if (b[t]) {
745
- const R = [...b];
746
- return R[t] = { ...R[t], cost: r }, R;
798
+ h((S) => {
799
+ if (S[e]) {
800
+ const R = [...S];
801
+ return R[e] = { ...R[e], cost: d }, R;
747
802
  }
748
- return b;
803
+ return S;
749
804
  });
750
805
  break;
751
806
  }
752
807
  default:
753
808
  }
754
- } catch (S) {
755
- console.error("[ai-assist-sdk] onmessage 解析失败:", S);
809
+ } catch (w) {
810
+ console.error("[ai-assist-sdk] onmessage 解析失败:", w);
756
811
  }
757
812
  },
758
813
  onclose() {
759
- l(), y(t), l();
760
- const g = (s.value.get(t) || []).filter((T) => T.type === "answer").map((T) => T.content).join(""), S = [...e.value];
761
- S[t] && S[t].status !== c.ERROR && (S[t] = {
762
- ...S[t],
763
- content: A.value && !g ? "已停止回答" : g,
764
- status: A.value ? c.STOP : c.COMPLETED
765
- }), e.value = S, p.value = !1;
814
+ o(), y(e), o();
815
+ const p = (i.value.get(e) || []).filter((M) => M.type === "answer").map((M) => M.content).join(""), w = [...t.value];
816
+ w[e] && w[e].status !== r.ERROR && (w[e] = {
817
+ ...w[e],
818
+ content: $.value && !p ? "已停止回答" : p,
819
+ status: $.value ? r.STOP : r.COMPLETED
820
+ }), t.value = w, C.value = !1;
766
821
  },
767
- onerror(o) {
768
- console.error("[ai-assist-sdk] ❌ 连接错误:", o), l();
769
- const g = [...e.value];
770
- g[t] && (g[t] = { ...g[t], content: `
771
- ⚠️ 请求异常,已终止`, status: c.ERROR }), e.value = g, p.value = !1;
822
+ onerror(s) {
823
+ console.error("[ai-assist-sdk] ❌ 连接错误:", s), o();
824
+ const p = [...t.value];
825
+ p[e] && (p[e] = { ...p[e], content: `
826
+ ⚠️ 请求异常,已终止`, status: r.ERROR }), t.value = p, C.value = !1;
772
827
  }
773
828
  });
774
- } catch (H) {
775
- if (console.error("[ai-assist-sdk] doStreamRequest error:", H), !A.value) {
776
- l();
777
- const o = [...e.value];
778
- o[t] && (o[t] = { ...o[t], content: "服务连接失败,请稍后重试", status: c.ERROR }), e.value = o, p.value = !1;
829
+ } catch (b) {
830
+ if (console.error("[ai-assist-sdk] doStreamRequest error:", b), !$.value) {
831
+ o();
832
+ const s = [...t.value];
833
+ s[e] && (s[e] = { ...s[e], content: "服务连接失败,请稍后重试", status: r.ERROR }), t.value = s, C.value = !1;
779
834
  }
780
835
  }
781
836
  }
782
- return { doStreamRequest: $, issTop: A };
837
+ return { doStreamRequest: P, issTop: $ };
783
838
  }
784
- function Be(e) {
785
- var p;
786
- if (e && typeof e == "object" && typeof e.data == "string" && (e = e.data), typeof e == "string") {
787
- const h = e.split(`
839
+ function Ue(t) {
840
+ var C;
841
+ if (t && typeof t == "object" && typeof t.data == "string" && (t = t.data), typeof t == "string") {
842
+ const f = t.split(`
788
843
  `);
789
- let u = "";
790
- for (const l of h) {
791
- const c = l.startsWith("data:") ? l.slice(5).trim() : "";
792
- if (c)
844
+ let h = "";
845
+ for (const o of f) {
846
+ const r = o.startsWith("data:") ? o.slice(5).trim() : "";
847
+ if (r)
793
848
  try {
794
- const i = JSON.parse(c);
795
- i.event === "message" && i.answer !== void 0 && (u += i.answer);
849
+ const l = JSON.parse(r);
850
+ l.event === "message" && l.answer !== void 0 && (h += l.answer);
796
851
  } catch {
797
852
  }
798
853
  }
799
- return u || e;
854
+ return h || t;
800
855
  }
801
- return (e == null ? void 0 : e.answer) || ((p = e == null ? void 0 : e.data) == null ? void 0 : p.answer) || String(e || "");
856
+ return (t == null ? void 0 : t.answer) || ((C = t == null ? void 0 : t.data) == null ? void 0 : C.answer) || String(t || "");
802
857
  }
803
- function tn(e) {
804
- return e.queryAgainStreamApi || e.queryAgainApi || e.chatQueryStreamApi || e.chatQueryApi;
858
+ function Mn(t) {
859
+ return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
805
860
  }
806
- function nn({
807
- messages: e,
808
- userInput: p,
809
- isGenerating: h,
810
- lastUserMessage: u,
811
- conversationId: l,
812
- doStreamRequest: c,
813
- issTop: i,
814
- scrollToBottom: s,
815
- STATUS: a,
816
- cfg: d,
817
- onTitleGenerated: f
861
+ function Tn({
862
+ messages: t,
863
+ userInput: C,
864
+ isGenerating: f,
865
+ lastUserMessage: h,
866
+ conversationId: o,
867
+ doStreamRequest: r,
868
+ issTop: l,
869
+ scrollToBottom: i,
870
+ STATUS: u,
871
+ cfg: g,
872
+ onTitleGenerated: D
818
873
  }) {
819
- const A = d.apis, v = ne({
874
+ const $ = g.apis, c = K({
820
875
  first: new AbortController(),
821
876
  again: new AbortController()
822
- }), y = C(!1);
823
- async function $(o, g) {
824
- var T;
825
- if (!d.titleGenerateApp || !A.updateConversationApi || y.value) return;
826
- let S = l.value;
827
- if (!S)
877
+ }), y = k(!1);
878
+ async function P(s, p) {
879
+ var M;
880
+ if (!g.titleGenerateApp || !$.updateConversationApi || y.value) return;
881
+ let w = o.value;
882
+ if (!w)
828
883
  try {
829
- const r = await Oe(A);
830
- (T = r == null ? void 0 : r.conversation) != null && T.appConversationID && (S = r.conversation.appConversationID, l.value = S);
831
- } catch (r) {
832
- console.error("[ai-assist-sdk] 创建会话失败:", r);
884
+ const d = await Qe($);
885
+ (M = d == null ? void 0 : d.conversation) != null && M.appConversationID && (w = d.conversation.appConversationID, o.value = w);
886
+ } catch (d) {
887
+ console.error("[ai-assist-sdk] 创建会话失败:", d);
833
888
  return;
834
889
  }
835
- if (S)
890
+ if (w)
836
891
  try {
837
- const r = await et(A, d.titleGenerateApp);
838
- if (!r) return;
839
- const b = g.length > 500 ? g.slice(0, 500) : g, R = `用户提问:${o}
840
- AI回答:${b}`, L = await Pe().post(A.chatQueryApi, {
841
- app: d.titleGenerateApp,
842
- data: { Query: R, AppConversationID: r }
843
- }), N = Be(L.data.data);
844
- N && (await tt(A, S, N), y.value = !0, f == null || f(N));
845
- } catch (r) {
846
- console.error("[ai-assist-sdk] 生成对话标题失败:", r);
892
+ const d = await kt($, g.titleGenerateApp);
893
+ if (!d) return;
894
+ const S = p.length > 500 ? p.slice(0, 500) : p, R = `用户提问:${s}
895
+ AI回答:${S}`, L = await Ge().post($.chatQueryApi, {
896
+ app: g.titleGenerateApp,
897
+ data: { Query: R, AppConversationID: d }
898
+ }), B = Ue(L.data.data);
899
+ B && (await Ct($, w, B), y.value = !0, D == null || D(B));
900
+ } catch (d) {
901
+ console.error("[ai-assist-sdk] 生成对话标题失败:", d);
847
902
  }
848
903
  }
849
- async function M() {
850
- const o = p.value.trim();
851
- if (!o || h.value) return;
852
- if (!l.value && (await x(), !l.value)) {
853
- ue("创建会话失败,请重试");
904
+ async function x() {
905
+ const s = C.value.trim();
906
+ if (!s || f.value) return;
907
+ if (!o.value && (await E(), !o.value)) {
908
+ he("创建会话失败,请重试");
854
909
  return;
855
910
  }
856
- const g = e.value.length === 0, S = [
857
- ...e.value,
858
- { type: "user", content: o },
859
- { type: "ai", content: "", status: a.THINKING }
911
+ const p = t.value.length === 0, w = [
912
+ ...t.value,
913
+ { type: "user", content: s },
914
+ { type: "ai", content: "", status: u.THINKING }
860
915
  ];
861
- e.value = S, p.value = "", s();
862
- const T = S.length - 1;
863
- if (A.chatQueryStreamApi) {
864
- if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", A.chatQueryStreamApi), await c(A.chatQueryStreamApi, {
865
- Query: o,
866
- AppConversationID: l.value,
916
+ t.value = w, C.value = "", i();
917
+ const M = w.length - 1;
918
+ if ($.chatQueryStreamApi) {
919
+ if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", $.chatQueryStreamApi), await r($.chatQueryStreamApi, {
920
+ Query: s,
921
+ AppConversationID: o.value,
867
922
  ResponseMode: "streaming"
868
- }, T, v.first.signal), g && !y.value) {
869
- const r = e.value[T];
870
- r && r.status !== a.ERROR && $(o, r.content);
923
+ }, M, c.first.signal), p && !y.value) {
924
+ const d = t.value[M];
925
+ d && d.status !== u.ERROR && P(s, d.content);
871
926
  }
872
927
  return;
873
928
  }
874
929
  console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
875
930
  try {
876
- const b = await Pe().post(A.chatQueryApi, {
877
- app: d.app ?? 1,
878
- data: { Query: o, AppConversationID: l.value }
879
- }), R = Be(b.data);
880
- e.value = [...e.value.slice(0, -1), { type: "ai", content: R, status: a.COMPLETED }], g && !y.value && $(o, R);
881
- } catch (r) {
882
- e.value = [...e.value.slice(0, -1), { type: "ai", content: (r == null ? void 0 : r.message) || "服务连接失败,请稍后重试", status: a.ERROR }];
931
+ const S = await Ge().post($.chatQueryApi, {
932
+ app: g.app ?? 1,
933
+ data: { Query: s, AppConversationID: o.value }
934
+ }), R = Ue(S.data);
935
+ t.value = [...t.value.slice(0, -1), { type: "ai", content: R, status: u.COMPLETED }], p && !y.value && P(s, R);
936
+ } catch (d) {
937
+ t.value = [...t.value.slice(0, -1), { type: "ai", content: (d == null ? void 0 : d.message) || "服务连接失败,请稍后重试", status: u.ERROR }];
883
938
  }
884
939
  }
885
- async function P() {
886
- if (!u.value || h.value) return;
887
- v.again.abort(), v.again = new AbortController();
888
- const o = [...e.value];
889
- o.length > 0 && o[o.length - 1].type === "ai" && o.pop(), o.push({ type: "ai", content: "", status: a.RETHINKING }), e.value = o, s();
890
- const g = e.value.length - 1, S = tn(A);
891
- await c(S, {
892
- MessageID: u.value,
893
- AppConversationID: l.value,
940
+ async function _() {
941
+ if (!h.value || f.value) return;
942
+ c.again.abort(), c.again = new AbortController();
943
+ const s = [...t.value];
944
+ s.length > 0 && s[s.length - 1].type === "ai" && s.pop(), s.push({ type: "ai", content: "", status: u.RETHINKING }), t.value = s, i();
945
+ const p = t.value.length - 1, w = Mn($);
946
+ await r(w, {
947
+ MessageID: h.value,
948
+ AppConversationID: o.value,
894
949
  ResponseMode: "streaming"
895
- }, g, v.again.signal, !0);
950
+ }, p, c.again.signal, !0);
896
951
  }
897
- async function t() {
898
- if (!A.stopMessageApi || !h.value) return;
899
- const o = e.value.length - 1 - 1;
952
+ async function e() {
953
+ if (!$.stopMessageApi || !f.value) return;
954
+ const s = t.value.length - 1 - 1;
900
955
  try {
901
- await Ie(A, u.value);
902
- const g = [...e.value];
903
- g[o] && (g[o] = { ...g[o], content: g[o].content || "已停止回答", status: a.STOP }), e.value = g, h.value = !1, v.first.abort(), v.first = new AbortController(), v.again.abort(), v.again = new AbortController(), i.value = !0;
904
- } catch (g) {
905
- const S = [...e.value];
906
- S[o] && (S[o] = { ...S[o], content: (g == null ? void 0 : g.message) || "系统繁忙,请稍后再试", status: a.ERROR }), e.value = S;
956
+ await wt($, h.value);
957
+ const p = [...t.value];
958
+ p[s] && (p[s] = { ...p[s], content: p[s].content || "已停止回答", status: u.STOP }), t.value = p, f.value = !1, c.first.abort(), c.first = new AbortController(), c.again.abort(), c.again = new AbortController(), l.value = !0;
959
+ } catch (p) {
960
+ const w = [...t.value];
961
+ w[s] && (w[s] = { ...w[s], content: (p == null ? void 0 : p.message) || "系统繁忙,请稍后再试", status: u.ERROR }), t.value = w;
907
962
  }
908
963
  }
909
- async function E(o) {
910
- var g, S;
911
- l.value = o, y.value = !0;
964
+ async function v(s) {
965
+ var p, w;
966
+ o.value = s, y.value = !0;
912
967
  try {
913
- const T = await Ze(A, o), r = [];
914
- if ((g = T == null ? void 0 : T.messages) != null && g.length)
915
- for (const b of T.messages)
916
- b.query && r.push({ type: "user", content: b.query }), (S = b.answerInfo) != null && S.answer && r.push({ type: "ai", content: b.answerInfo.answer, status: a.COMPLETED });
917
- e.value = r, s();
918
- } catch (T) {
919
- ue((T == null ? void 0 : T.message) || "加载历史会话失败");
968
+ const M = await yt($, s), d = [];
969
+ if ((p = M == null ? void 0 : M.messages) != null && p.length)
970
+ for (const S of M.messages)
971
+ S.query && d.push({ type: "user", content: S.query }), (w = S.answerInfo) != null && w.answer && d.push({ type: "ai", content: S.answerInfo.answer, status: u.COMPLETED });
972
+ t.value = d, i();
973
+ } catch (M) {
974
+ he((M == null ? void 0 : M.message) || "加载历史会话失败");
920
975
  }
921
976
  }
922
- async function x() {
923
- var o;
977
+ async function E() {
978
+ var s;
924
979
  y.value = !1;
925
980
  try {
926
- const g = await Oe(A);
927
- (o = g == null ? void 0 : g.conversation) != null && o.appConversationID && (l.value = g.conversation.appConversationID);
928
- } catch (g) {
929
- ue((g == null ? void 0 : g.message) || "创建会话失败");
981
+ const p = await Qe($);
982
+ (s = p == null ? void 0 : p.conversation) != null && s.appConversationID && (o.value = p.conversation.appConversationID);
983
+ } catch (p) {
984
+ he((p == null ? void 0 : p.message) || "创建会话失败");
930
985
  }
931
986
  }
932
- function H() {
933
- l.value = "", y.value = !1;
987
+ function b() {
988
+ o.value = "", y.value = !1;
934
989
  }
935
- return { sendMessage: M, regenerateResponse: P, toggleStop: t, goHistoryMessage: E, initConversation: x, resetConversation: H, controllers: v };
990
+ return { sendMessage: x, regenerateResponse: _, toggleStop: e, goHistoryMessage: v, initConversation: E, resetConversation: b, controllers: c };
936
991
  }
937
- const sn = { class: "container" }, on = { class: "message ai-message greet-message" }, an = { class: "ai-greet" }, ln = ["src"], cn = {
992
+ const xn = { class: "container" }, En = { class: "message ai-message greet-message" }, Rn = { class: "ai-greet" }, $n = ["src"], Pn = {
938
993
  key: 0,
939
994
  class: "message ai-message recommend-message"
940
- }, rn = { class: "ai-recommend" }, un = { class: "recommend-header" }, vn = ["src"], dn = ["onClick"], gn = /* @__PURE__ */ ee({
995
+ }, Dn = { class: "ai-recommend" }, Hn = { class: "recommend-header" }, _n = ["src"], On = ["onClick"], Ln = /* @__PURE__ */ le({
941
996
  __name: "Answer",
942
997
  props: {
943
998
  defaultSayhello: {},
944
999
  defaultRecommend: {}
945
1000
  },
946
1001
  emits: ["title-generated"],
947
- setup(e, { expose: p, emit: h }) {
948
- const u = {
1002
+ setup(t, { expose: C, emit: f }) {
1003
+ const h = {
949
1004
  THINKING: "thinking",
950
1005
  RETHINKING: "rethinking",
951
1006
  ANSWERING: "answering",
@@ -953,358 +1008,421 @@ const sn = { class: "container" }, on = { class: "message ai-message greet-messa
953
1008
  COMPLETED: "completed",
954
1009
  STOP: "stop",
955
1010
  ERROR: "error"
956
- }, l = e, c = h, i = de(), s = C([]), a = C(""), d = C(!1), f = C(""), A = C(""), v = C(null), y = ne({ text1: "", text2: "" }), $ = C([]), M = C(0), P = F(
957
- () => $.value[M.value % ($.value.length || 1)]
1011
+ }, o = t, r = f, l = ge(), i = k([]), u = k(""), g = k(!1), D = k(""), $ = k(""), c = k(null), y = K({ text1: "", text2: "" }), P = k([]), x = k(0), _ = Y(
1012
+ () => P.value[x.value % (P.value.length || 1)]
958
1013
  );
959
- function t() {
960
- M.value++;
1014
+ function e() {
1015
+ x.value++;
961
1016
  }
962
- function E(Q) {
963
- a.value = Q;
1017
+ function v(G) {
1018
+ u.value = G;
964
1019
  }
965
- const { isAtBottom: x, hasScroll: H, scrollToBottom: o, checkScrollStatus: g } = zt(v), { enhanceCodeBlocks: S } = Kt(), { batchMessagesUpdate: T, flushMessagesBatch: r } = Zt(s), { displayedContent: b, streamingIndexRef: R, startTypewriter: B, stopTypewriter: L, getSegmentDisplayContent: N } = It(
1020
+ const { isAtBottom: E, hasScroll: b, scrollToBottom: s, checkScrollStatus: p } = kn(c), { enhanceCodeBlocks: w } = Cn(), { batchMessagesUpdate: M, flushMessagesBatch: d } = An(i), { displayedContent: S, streamingIndexRef: R, startTypewriter: O, stopTypewriter: L, getSegmentDisplayContent: B } = bn(
1021
+ i,
966
1022
  s,
967
- o,
968
- u.ANSWERING
969
- ), { doStreamRequest: q, issTop: ge } = en({
970
- messages: s,
971
- isGenerating: d,
972
- lastUserMessage: f,
973
- batchMessagesUpdate: T,
974
- flushMessagesBatch: r,
975
- STATUS: u,
976
- cfg: i
977
- }), { sendMessage: me, regenerateResponse: ye, toggleStop: we, goHistoryMessage: Te, resetConversation: Ee } = nn({
978
- messages: s,
979
- userInput: a,
980
- isGenerating: d,
981
- lastUserMessage: f,
982
- conversationId: A,
983
- doStreamRequest: q,
984
- issTop: ge,
985
- scrollToBottom: o,
986
- STATUS: u,
987
- cfg: i,
988
- onTitleGenerated: (Q) => c("title-generated", Q)
1023
+ h.ANSWERING
1024
+ ), { doStreamRequest: Q, issTop: I } = Sn({
1025
+ messages: i,
1026
+ isGenerating: g,
1027
+ lastUserMessage: D,
1028
+ batchMessagesUpdate: M,
1029
+ flushMessagesBatch: d,
1030
+ STATUS: h,
1031
+ cfg: l
1032
+ }), { sendMessage: ce, regenerateResponse: re, toggleStop: ue, goHistoryMessage: Ee, resetConversation: Re } = Tn({
1033
+ messages: i,
1034
+ userInput: u,
1035
+ isGenerating: g,
1036
+ lastUserMessage: D,
1037
+ conversationId: $,
1038
+ doStreamRequest: Q,
1039
+ issTop: I,
1040
+ scrollToBottom: s,
1041
+ STATUS: h,
1042
+ cfg: l,
1043
+ onTitleGenerated: (G) => r("title-generated", G)
989
1044
  });
990
- function oe() {
991
- s.value = [], f.value = "", Ee();
1045
+ function $e() {
1046
+ i.value = [], D.value = "", Re();
992
1047
  }
993
- const ae = F(() => s.value.length === 0);
994
- p({ goHistoryMessage: Te, createNewConversation: oe, isEmptyConversation: ae });
995
- const ie = C(/* @__PURE__ */ new Map());
996
- function Re(Q, G) {
997
- Q ? ie.value.set(G, Q) : ie.value.delete(G);
1048
+ const Pe = Y(() => i.value.length === 0);
1049
+ C({ goHistoryMessage: Ee, createNewConversation: $e, isEmptyConversation: Pe });
1050
+ const pe = k(/* @__PURE__ */ new Map());
1051
+ function De(G, F) {
1052
+ G ? pe.value.set(F, G) : pe.value.delete(F);
998
1053
  }
999
- se(s, () => {
1000
- K(() => {
1001
- s.value.forEach((Q, G) => {
1002
- Q.type === "ai" && Q.status !== u.ANSWERING && (b.set(G, Q.content), R.value.set(G, Q.content.length));
1003
- }), B(), ie.value.forEach((Q) => {
1004
- S(Q);
1054
+ se(i, () => {
1055
+ te(() => {
1056
+ i.value.forEach((G, F) => {
1057
+ G.type === "ai" && G.status !== h.ANSWERING && (S.set(F, G.content), R.value.set(F, G.content.length));
1058
+ }), O(), pe.value.forEach((G) => {
1059
+ w(G);
1005
1060
  });
1006
1061
  });
1007
1062
  }, { deep: !0 });
1008
- let te = null;
1009
- return j(() => {
1010
- l.defaultSayhello && (y.text1 = l.defaultSayhello.text1, y.text2 = l.defaultSayhello.text2), l.defaultRecommend && ($.value = nt(l.defaultRecommend));
1011
- }), j(() => {
1012
- v.value && (te = () => g(), v.value.addEventListener("scroll", te));
1013
- }), Ae(() => {
1014
- L(), v.value && te && v.value.removeEventListener("scroll", te);
1015
- }), (Q, G) => {
1016
- var ke;
1017
- return m(), k("div", sn, [
1063
+ let ae = null;
1064
+ return ne(() => {
1065
+ o.defaultSayhello && (y.text1 = o.defaultSayhello.text1, y.text2 = o.defaultSayhello.text2), o.defaultRecommend && (P.value = At(o.defaultRecommend));
1066
+ }), ne(() => {
1067
+ c.value && (ae = () => p(), c.value.addEventListener("scroll", ae));
1068
+ }), Te(() => {
1069
+ L(), c.value && ae && c.value.removeEventListener("scroll", ae);
1070
+ }), (G, F) => {
1071
+ var be;
1072
+ return m(), A("div", xn, [
1018
1073
  n("div", {
1019
1074
  class: "chat-box scrollWrap",
1020
1075
  ref_key: "chatBoxRef",
1021
- ref: v
1076
+ ref: c
1022
1077
  }, [
1023
- n("div", on, [
1024
- n("div", an, [
1025
- n("img", { src: D(We) }, null, 8, ln),
1078
+ n("div", En, [
1079
+ n("div", Rn, [
1080
+ n("img", { src: H(Ie) }, null, 8, $n),
1026
1081
  n("h1", null, V(y.text1), 1),
1027
1082
  n("p", null, V(y.text2), 1)
1028
1083
  ])
1029
1084
  ]),
1030
- (ke = P.value) != null && ke.length ? (m(), k("div", cn, [
1031
- n("div", rn, [
1032
- n("div", un, [
1033
- G[2] || (G[2] = n("span", null, "你可以尝试这样问我:", -1)),
1085
+ (be = _.value) != null && be.length ? (m(), A("div", Pn, [
1086
+ n("div", Dn, [
1087
+ n("div", Hn, [
1088
+ F[2] || (F[2] = n("span", null, "你可以尝试这样问我:", -1)),
1034
1089
  n("p", {
1035
1090
  class: "refresh-btn",
1036
- onClick: t
1091
+ onClick: e
1037
1092
  }, [
1038
- n("img", { src: D(yt) }, null, 8, vn),
1039
- G[1] || (G[1] = n("span", null, "换一换", -1))
1093
+ n("img", { src: H(Nt) }, null, 8, _n),
1094
+ F[1] || (F[1] = n("span", null, "换一换", -1))
1040
1095
  ])
1041
1096
  ]),
1042
1097
  n("ul", null, [
1043
- (m(!0), k(I, null, ve(P.value, (z, le) => (m(), k("li", {
1044
- key: le,
1045
- onClick: (ce) => E(z)
1046
- }, V(z), 9, dn))), 128))
1098
+ (m(!0), A(ie, null, me(_.value, (oe, ee) => (m(), A("li", {
1099
+ key: ee,
1100
+ onClick: (fe) => v(oe)
1101
+ }, V(oe), 9, On))), 128))
1047
1102
  ])
1048
1103
  ])
1049
- ])) : _("", !0),
1050
- (m(!0), k(I, null, ve(s.value, (z, le) => (m(), Z(Nt, {
1051
- key: le,
1052
- msg: z,
1053
- index: le,
1054
- STATUS: u,
1055
- displayedContent: D(b),
1056
- getSegmentDisplayContent: D(N),
1057
- setMessageRef: Re,
1058
- onRegenerate: D(ye)
1104
+ ])) : N("", !0),
1105
+ (m(!0), A(ie, null, me(i.value, (oe, ee) => (m(), Z(ln, {
1106
+ key: ee,
1107
+ msg: oe,
1108
+ index: ee,
1109
+ STATUS: h,
1110
+ displayedContent: H(S),
1111
+ getSegmentDisplayContent: H(B),
1112
+ setMessageRef: De,
1113
+ onRegenerate: H(re)
1059
1114
  }, null, 8, ["msg", "index", "displayedContent", "getSegmentDisplayContent", "onRegenerate"]))), 128))
1060
1115
  ], 512),
1061
- Y(jt, {
1062
- modelValue: a.value,
1063
- "onUpdate:modelValue": G[0] || (G[0] = (z) => a.value = z),
1064
- isGenerating: d.value,
1065
- lastUserMessage: f.value,
1066
- hasScroll: D(H),
1067
- isAtBottom: D(x),
1068
- onSend: D(me),
1069
- onRegenerate: D(ye),
1070
- onStop: D(we),
1071
- onScrollToBottom: D(o)
1116
+ X(wn, {
1117
+ modelValue: u.value,
1118
+ "onUpdate:modelValue": F[0] || (F[0] = (oe) => u.value = oe),
1119
+ isGenerating: g.value,
1120
+ lastUserMessage: D.value,
1121
+ hasScroll: H(b),
1122
+ isAtBottom: H(E),
1123
+ onSend: H(ce),
1124
+ onRegenerate: H(re),
1125
+ onStop: H(ue),
1126
+ onScrollToBottom: H(s)
1072
1127
  }, null, 8, ["modelValue", "isGenerating", "lastUserMessage", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
1073
- G[3] || (G[3] = n("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
1128
+ F[3] || (F[3] = n("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
1074
1129
  ]);
1075
1130
  };
1076
1131
  }
1077
- }), mn = { class: "ai-history" }, hn = { class: "content" }, pn = {
1132
+ }), Bn = { class: "ai-history" }, Nn = { class: "content" }, Wn = {
1078
1133
  key: 0,
1079
1134
  class: "ai-history-loading"
1080
- }, fn = { class: "ai-history-group-title" }, yn = ["onClick"], wn = { class: "ai-history-item-title" }, kn = ["onClick"], Cn = {
1135
+ }, Yn = { class: "ai-history-group-title" }, Vn = ["onClick"], Xn = { class: "ai-history-item-title" }, Fn = ["onClick"], Qn = {
1081
1136
  key: 2,
1082
1137
  class: "ai-history-empty"
1083
- }, An = ["src"], bn = { class: "ai-modal" }, Sn = { class: "ai-modal-footer" }, Tn = /* @__PURE__ */ ee({
1138
+ }, Gn = ["src"], Jn = { class: "ai-modal" }, Un = { class: "ai-modal-footer" }, qn = /* @__PURE__ */ le({
1084
1139
  __name: "History",
1085
1140
  emits: ["history-detail", "new-conversation"],
1086
- setup(e, { emit: p }) {
1087
- const u = de().apis, l = C([]), c = C(!0), i = C(!1), s = C(""), a = F(() => st(l.value));
1088
- async function d() {
1141
+ setup(t, { emit: C }) {
1142
+ const h = ge().apis, o = k([]), r = k(!0), l = k(!1), i = k(""), u = Y(() => bt(o.value));
1143
+ async function g() {
1089
1144
  try {
1090
- const v = await ot(u);
1091
- v != null && v.conversationList && (l.value = v.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
1092
- } catch (v) {
1093
- ue((v == null ? void 0 : v.message) || "获取历史记录失败");
1145
+ const c = await St(h);
1146
+ c != null && c.conversationList && (o.value = c.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
1147
+ } catch (c) {
1148
+ he((c == null ? void 0 : c.message) || "获取历史记录失败");
1094
1149
  } finally {
1095
- c.value = !1;
1150
+ r.value = !1;
1096
1151
  }
1097
1152
  }
1098
- function f(v) {
1099
- s.value = v, i.value = !0;
1153
+ function D(c) {
1154
+ i.value = c, l.value = !0;
1100
1155
  }
1101
- async function A() {
1102
- i.value = !1;
1156
+ async function $() {
1157
+ l.value = !1;
1103
1158
  try {
1104
- await at(u, s.value), await d();
1105
- } catch (v) {
1106
- ue((v == null ? void 0 : v.message) || "删除失败"), await d();
1159
+ await Mt(h, i.value), await g();
1160
+ } catch (c) {
1161
+ he((c == null ? void 0 : c.message) || "删除失败"), await g();
1107
1162
  }
1108
1163
  }
1109
- return j(() => {
1110
- d();
1111
- }), (v, y) => (m(), k("div", mn, [
1112
- n("div", hn, [
1113
- c.value ? (m(), k("div", pn, [...y[3] || (y[3] = [
1164
+ return ne(() => {
1165
+ g();
1166
+ }), (c, y) => (m(), A("div", Bn, [
1167
+ n("div", Nn, [
1168
+ r.value ? (m(), A("div", Wn, [...y[3] || (y[3] = [
1114
1169
  n("div", { class: "ai-history-spinner" }, null, -1)
1115
- ])])) : a.value.length > 0 ? (m(!0), k(I, { key: 1 }, ve(a.value, ($) => (m(), k("div", {
1116
- key: $.label,
1170
+ ])])) : u.value.length > 0 ? (m(!0), A(ie, { key: 1 }, me(u.value, (P) => (m(), A("div", {
1171
+ key: P.label,
1117
1172
  class: "ai-history-group"
1118
1173
  }, [
1119
- n("div", fn, V($.label), 1),
1120
- (m(!0), k(I, null, ve($.items, (M, P) => (m(), k("div", {
1121
- key: M.appConversationID,
1174
+ n("div", Yn, V(P.label), 1),
1175
+ (m(!0), A(ie, null, me(P.items, (x, _) => (m(), A("div", {
1176
+ key: x.appConversationID,
1122
1177
  class: "ai-history-item",
1123
- style: Se({ "--i": P }),
1124
- onClick: (t) => v.$emit("history-detail", M.appConversationID)
1178
+ style: xe({ "--i": _ }),
1179
+ onClick: (e) => c.$emit("history-detail", x.appConversationID)
1125
1180
  }, [
1126
- n("div", wn, V(M.conversationName), 1),
1181
+ n("div", Xn, V(x.conversationName), 1),
1127
1182
  n("div", {
1128
1183
  class: "ai-history-item-delete",
1129
- onClick: be((t) => f(M.appConversationID), ["stop"])
1130
- }, "删除", 8, kn)
1131
- ], 12, yn))), 128))
1132
- ]))), 128)) : (m(), k("div", Cn, "暂无历史记录"))
1184
+ onClick: Ce((e) => D(x.appConversationID), ["stop"])
1185
+ }, "删除", 8, Fn)
1186
+ ], 12, Vn))), 128))
1187
+ ]))), 128)) : (m(), A("div", Qn, "暂无历史记录"))
1133
1188
  ]),
1134
1189
  n("div", {
1135
1190
  class: "ai-add",
1136
- onClick: y[0] || (y[0] = ($) => v.$emit("new-conversation"))
1191
+ onClick: y[0] || (y[0] = (P) => c.$emit("new-conversation"))
1137
1192
  }, [
1138
- n("img", { src: D(vt) }, null, 8, An),
1193
+ n("img", { src: H(Pt) }, null, 8, Gn),
1139
1194
  y[4] || (y[4] = n("span", null, "新建AI对话", -1))
1140
1195
  ]),
1141
- (m(), Z(Le, { to: "#ai-assist-root" }, [
1142
- i.value ? (m(), k("div", {
1196
+ (m(), Z(je, { to: "#ai-assist-root" }, [
1197
+ l.value ? (m(), A("div", {
1143
1198
  key: 0,
1144
1199
  class: "ai-modal-overlay",
1145
- onClick: y[2] || (y[2] = be(($) => i.value = !1, ["self"]))
1200
+ onClick: y[2] || (y[2] = Ce((P) => l.value = !1, ["self"]))
1146
1201
  }, [
1147
- n("div", bn, [
1202
+ n("div", Jn, [
1148
1203
  y[5] || (y[5] = n("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
1149
1204
  y[6] || (y[6] = n("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
1150
- n("div", Sn, [
1205
+ n("div", Un, [
1151
1206
  n("button", {
1152
1207
  class: "ai-modal-btn cancel",
1153
- onClick: y[1] || (y[1] = ($) => i.value = !1)
1208
+ onClick: y[1] || (y[1] = (P) => l.value = !1)
1154
1209
  }, "取消"),
1155
1210
  n("button", {
1156
1211
  class: "ai-modal-btn confirm",
1157
- onClick: A
1212
+ onClick: $
1158
1213
  }, "确定")
1159
1214
  ])
1160
1215
  ])
1161
- ])) : _("", !0)
1216
+ ])) : N("", !0)
1162
1217
  ]))
1163
1218
  ]));
1164
1219
  }
1165
- }), En = { class: "container info" }, Rn = { class: "info-item" }, Mn = { class: "basic-content" }, $n = { class: "basic-content-text" }, xn = { class: "basic-content" }, Dn = { class: "basic-content-text" }, Hn = { class: "info-item" }, On = { class: "permission-content" }, Pn = { class: "info-item" }, Bn = { class: "basic-content" }, Ln = { class: "basic-content-text" }, Nn = { class: "basic-content" }, _n = { class: "basic-content-text" }, Vn = /* @__PURE__ */ ee({
1220
+ }), jn = { class: "container info" }, zn = { class: "info-item" }, Kn = { class: "basic-content" }, Zn = { class: "basic-content-text" }, In = { class: "basic-content" }, es = { class: "basic-content-text" }, ts = { class: "info-item" }, ns = { class: "permission-content" }, ss = { class: "info-item" }, as = { class: "basic-content" }, os = { class: "basic-content-text" }, is = { class: "basic-content" }, ls = { class: "basic-content-text" }, cs = /* @__PURE__ */ le({
1166
1221
  __name: "Info",
1167
- setup(e) {
1168
- const p = de(), h = C(null);
1169
- return j(async () => {
1222
+ setup(t) {
1223
+ const C = ge(), f = k(null);
1224
+ return ne(async () => {
1170
1225
  try {
1171
- h.value = await it(p.apis);
1172
- } catch (u) {
1173
- ue((u == null ? void 0 : u.message) || "获取个人信息失败");
1226
+ f.value = await Tt(C.apis);
1227
+ } catch (h) {
1228
+ he((h == null ? void 0 : h.message) || "获取个人信息失败");
1174
1229
  }
1175
- }), (u, l) => {
1176
- var c, i, s, a, d;
1177
- return m(), k("div", En, [
1178
- n("div", Rn, [
1179
- l[2] || (l[2] = n("div", { class: "heading" }, [
1230
+ }), (h, o) => {
1231
+ var r, l, i, u, g;
1232
+ return m(), A("div", jn, [
1233
+ n("div", zn, [
1234
+ o[2] || (o[2] = n("div", { class: "heading" }, [
1180
1235
  n("div", { class: "heading-column" }),
1181
1236
  n("div", { class: "heading-title" }, "基本信息")
1182
1237
  ], -1)),
1183
- n("div", Mn, [
1184
- l[0] || (l[0] = n("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
1185
- n("div", $n, V(((c = h.value) == null ? void 0 : c.name) || ""), 1)
1238
+ n("div", Kn, [
1239
+ o[0] || (o[0] = n("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
1240
+ n("div", Zn, V(((r = f.value) == null ? void 0 : r.name) || ""), 1)
1186
1241
  ]),
1187
- n("div", xn, [
1188
- l[1] || (l[1] = n("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
1189
- n("div", Dn, V(((i = h.value) == null ? void 0 : i.userName) || ""), 1)
1242
+ n("div", In, [
1243
+ o[1] || (o[1] = n("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
1244
+ n("div", es, V(((l = f.value) == null ? void 0 : l.userName) || ""), 1)
1190
1245
  ])
1191
1246
  ]),
1192
- n("div", Hn, [
1193
- l[3] || (l[3] = n("div", { class: "heading" }, [
1247
+ n("div", ts, [
1248
+ o[3] || (o[3] = n("div", { class: "heading" }, [
1194
1249
  n("div", { class: "heading-column" }),
1195
1250
  n("div", { class: "heading-title" }, "数据权限")
1196
1251
  ], -1)),
1197
- n("div", On, [
1198
- (m(!0), k(I, null, ve((s = h.value) == null ? void 0 : s.ptnameList, (f, A) => (m(), k("div", {
1199
- key: A,
1252
+ n("div", ns, [
1253
+ (m(!0), A(ie, null, me((i = f.value) == null ? void 0 : i.ptnameList, (D, $) => (m(), A("div", {
1254
+ key: $,
1200
1255
  class: "permission-content-text"
1201
- }, V(f), 1))), 128))
1256
+ }, V(D), 1))), 128))
1202
1257
  ])
1203
1258
  ]),
1204
- n("div", Pn, [
1205
- l[6] || (l[6] = n("div", { class: "heading" }, [
1259
+ n("div", ss, [
1260
+ o[6] || (o[6] = n("div", { class: "heading" }, [
1206
1261
  n("div", { class: "heading-column" }),
1207
1262
  n("div", { class: "heading-title" }, "帮助信息")
1208
1263
  ], -1)),
1209
- n("div", Bn, [
1210
- l[4] || (l[4] = n("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
1211
- n("div", Ln, V(((a = h.value) == null ? void 0 : a.dept) || ""), 1)
1264
+ n("div", as, [
1265
+ o[4] || (o[4] = n("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
1266
+ n("div", os, V(((u = f.value) == null ? void 0 : u.dept) || ""), 1)
1212
1267
  ]),
1213
- n("div", Nn, [
1214
- l[5] || (l[5] = n("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
1215
- n("div", _n, V(((d = h.value) == null ? void 0 : d.email) || ""), 1)
1268
+ n("div", is, [
1269
+ o[5] || (o[5] = n("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
1270
+ n("div", ls, V(((g = f.value) == null ? void 0 : g.email) || ""), 1)
1216
1271
  ])
1217
1272
  ])
1218
1273
  ]);
1219
1274
  };
1220
1275
  }
1221
- }), Wn = { class: "header" }, Yn = { key: 1 }, Fn = ["src"], Qn = { class: "header-title" }, Gn = ["title"], Xn = { class: "ai-history-drawer-panel" }, Jn = { class: "ai-history-drawer-header" }, qn = { class: "setTitle" }, Un = { class: "content" }, jn = { class: "main" }, zn = { class: "btn" }, Kn = ["src"], Zn = 78, pe = 78, Ye = /* @__PURE__ */ ee({
1276
+ }), rs = { key: 1 }, us = ["src"], vs = { class: "header-title" }, ds = ["title"], hs = { class: "ai-history-drawer-panel" }, ms = { class: "ai-history-drawer-header" }, gs = { class: "setTitle" }, ps = { class: "content" }, fs = { class: "main" }, ys = { class: "btn" }, ws = ["src"], ks = 78, ke = 78, q = 8, Cs = 490, qe = "aiPanelPosition", et = /* @__PURE__ */ le({
1222
1277
  __name: "AiAssist",
1223
- setup(e) {
1224
- const p = Zn / 2, h = de(), u = C(!1), l = C("idle"), c = C(!1), i = ne({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), s = C(!1), a = C(window.innerWidth < 768), d = C(window.innerWidth < 768), f = C("answer"), A = C(!1), v = C(""), y = C(""), $ = C(""), M = C(!1), P = C(!1), t = ne({
1225
- x: window.innerWidth - p,
1226
- y: window.innerHeight / 2 - pe / 2
1227
- }), E = C(!1), x = C(!1), H = C("right"), o = C("left"), g = ne({ x: 0, y: 0 }), S = C(!1), T = C(null);
1228
- let r = null, b = null;
1229
- const R = F(() => {
1230
- const w = window.innerWidth / 2;
1231
- return t.x + p < w ? 5 : -5;
1232
- }), B = F(() => d.value ? "" : `panel-${H.value}`), L = F(() => {
1233
- var w;
1234
- return !((w = T.value) != null && w.isEmptyConversation);
1235
- }), N = F(() => ({
1236
- left: `${t.x}px`,
1237
- top: `${t.y}px`,
1238
- transition: E.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
1239
- "--direction": String(R.value)
1240
- })), q = F(() => h.characterImage || dt), ge = F(() => l.value === "idle" ? {} : {
1241
- left: `${i.x}px`,
1242
- top: `${i.y}px`,
1243
- width: `${i.w}px`,
1244
- height: `${i.h}px`,
1245
- borderRadius: i.radius
1278
+ setup(t) {
1279
+ const C = ks / 2, f = ge(), h = k(!1), o = k("idle"), r = k(!1), l = K({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), i = k(!1), u = k(window.innerWidth < 768), g = k(window.innerWidth < 768), D = k("answer"), $ = k(!1), c = k(""), y = k(""), P = k(""), x = k(!1), _ = k(!1), e = K({
1280
+ x: window.innerWidth - C,
1281
+ y: window.innerHeight / 2 - ke / 2
1282
+ }), v = k(!1), E = k(!1), b = k("right"), s = k("left"), p = k(null), w = K({ x: 0, y: 0 }), M = k(!1), d = k(!1), S = K({ x: 0, y: 0 }), R = k(!1), O = K({ x: 0, y: 0 });
1283
+ let L = !1;
1284
+ const B = K({ x: 0, y: 0 }), Q = k(!1), I = k(null);
1285
+ let ce = null, re = null;
1286
+ const ue = Y(() => {
1287
+ const a = window.innerWidth / 2;
1288
+ return e.x + C < a ? 5 : -5;
1289
+ }), Ee = Y(() => g.value ? "" : `panel-${b.value}`), Re = Y(() => {
1290
+ var a;
1291
+ return !((a = I.value) != null && a.isEmptyConversation);
1292
+ }), $e = Y(() => ({
1293
+ left: `${e.x}px`,
1294
+ top: `${e.y}px`,
1295
+ transition: v.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
1296
+ "--direction": String(ue.value)
1297
+ })), Pe = Y(() => f.characterImage || Dt), pe = Y(() => o.value === "idle" ? {} : {
1298
+ left: `${l.x}px`,
1299
+ top: `${l.y}px`,
1300
+ width: `${l.w}px`,
1301
+ height: `${l.h}px`,
1302
+ borderRadius: l.radius
1303
+ }), De = Y(() => {
1304
+ const a = {};
1305
+ return M.value && !g.value && !u.value && (a["--ai-panel-x"] = `${w.x}px`, a["--ai-panel-y"] = `${w.y}px`), a;
1246
1306
  });
1247
- function me() {
1248
- const w = window.innerWidth / 2;
1249
- t.x + p < w ? (H.value = "left", o.value = "right") : (H.value = "right", o.value = "left");
1307
+ function ae() {
1308
+ const a = window.innerWidth / 2;
1309
+ e.x + C < a ? (b.value = "left", s.value = "right") : (b.value = "right", s.value = "left");
1250
1310
  }
1251
- function ye() {
1252
- const w = window.innerWidth, O = Math.max(0, Math.min(t.y, window.innerHeight - pe));
1253
- return { x: t.x + p >= w / 2 ? w - p : -p, y: O };
1311
+ function G() {
1312
+ const a = window.innerWidth, T = Math.max(0, Math.min(e.y, window.innerHeight - ke));
1313
+ return { x: e.x + C >= a / 2 ? a - C : -C, y: T };
1254
1314
  }
1255
- function we() {
1256
- x.value = !0;
1257
- const w = ye();
1258
- t.x = w.x, t.y = w.y, setTimeout(() => {
1259
- x.value = !1, me(), Te();
1315
+ function F() {
1316
+ E.value = !0;
1317
+ const a = G();
1318
+ e.x = a.x, e.y = a.y, setTimeout(() => {
1319
+ E.value = !1, ae(), be();
1260
1320
  }, 400);
1261
1321
  }
1262
- function Te() {
1322
+ function be() {
1263
1323
  try {
1264
- localStorage.setItem("characterPosition", JSON.stringify({ x: t.x, y: t.y })), localStorage.setItem("panelPosition", H.value), localStorage.setItem("backPosition", o.value);
1324
+ localStorage.setItem("characterPosition", JSON.stringify({ x: e.x, y: e.y })), localStorage.setItem("panelPosition", b.value), localStorage.setItem("backPosition", s.value);
1265
1325
  } catch {
1266
1326
  }
1267
1327
  }
1268
- function Ee() {
1269
- const w = localStorage.getItem("characterPosition");
1270
- if (w) {
1271
- const U = JSON.parse(w);
1272
- t.x = U.x, t.y = Math.min(Math.max(U.y, 0), window.innerHeight - pe);
1328
+ function oe() {
1329
+ const a = localStorage.getItem("characterPosition");
1330
+ if (a) {
1331
+ const U = JSON.parse(a);
1332
+ e.x = U.x, e.y = Math.min(Math.max(U.y, 0), window.innerHeight - ke);
1273
1333
  } else
1274
- t.x = window.innerWidth - p, t.y = window.innerHeight / 2 - pe / 2;
1275
- const O = localStorage.getItem("panelPosition"), W = localStorage.getItem("backPosition");
1276
- O && (H.value = O), W && (o.value = W);
1334
+ e.x = window.innerWidth - C, e.y = window.innerHeight / 2 - ke / 2;
1335
+ const T = localStorage.getItem("panelPosition"), W = localStorage.getItem("backPosition");
1336
+ T && (b.value = T), W && (s.value = W);
1277
1337
  }
1278
- function oe(w) {
1279
- if (!E.value) return;
1280
- const O = "touches" in w ? w.touches[0].clientX : w.clientX, W = "touches" in w ? w.touches[0].clientY : w.clientY, U = O - g.x, Me = Math.max(0, Math.min(W - g.y, window.innerHeight - pe)), Ce = Math.abs(U - t.x), Qe = Math.abs(Me - t.y);
1281
- Ce + Qe > 5 && (S.value = !0), t.x = U, t.y = Me;
1338
+ function ee(a) {
1339
+ if (!v.value) return;
1340
+ const T = "touches" in a ? a.touches[0].clientX : a.clientX, W = "touches" in a ? a.touches[0].clientY : a.clientY, U = T - B.x, z = Math.max(0, Math.min(W - B.y, window.innerHeight - ke)), ve = Math.abs(U - e.x), He = Math.abs(z - e.y);
1341
+ ve + He > 5 && (Q.value = !0), e.x = U, e.y = z;
1282
1342
  }
1283
- function ae() {
1284
- E.value && (E.value = !1, S.value && (we(), S.value = !1));
1343
+ function fe() {
1344
+ v.value && (v.value = !1, Q.value && (F(), Q.value = !1));
1345
+ }
1346
+ function Oe(a) {
1347
+ E.value = !1, v.value = !0, Q.value = !1;
1348
+ const T = "touches" in a ? a.touches[0].clientX : a.clientX, W = "touches" in a ? a.touches[0].clientY : a.clientY;
1349
+ B.x = T - e.x, B.y = W - e.y;
1350
+ }
1351
+ function Le() {
1352
+ const a = p.value, T = (a == null ? void 0 : a.offsetWidth) || Cs, W = (a == null ? void 0 : a.offsetHeight) || window.innerHeight - 78;
1353
+ return {
1354
+ maxX: Math.max(q, window.innerWidth - T - q),
1355
+ maxY: Math.max(q, window.innerHeight - W - q)
1356
+ };
1357
+ }
1358
+ function Be() {
1359
+ const { maxX: a, maxY: T } = Le();
1360
+ w.x = Math.min(Math.max(w.x, q), a), w.y = Math.min(Math.max(w.y, q), T);
1361
+ }
1362
+ function Ne(a) {
1363
+ if (g.value || u.value || o.value !== "idle") return;
1364
+ if (d.value = !0, R.value = !1, !M.value) {
1365
+ const U = p.value;
1366
+ if (U) {
1367
+ const z = U.getBoundingClientRect();
1368
+ w.x = z.left, w.y = z.top, M.value = !0;
1369
+ }
1370
+ }
1371
+ const T = "touches" in a ? a.touches[0].clientX : a.clientX, W = "touches" in a ? a.touches[0].clientY : a.clientY;
1372
+ O.x = T, O.y = W, S.x = T - w.x, S.y = W - w.y;
1373
+ }
1374
+ function Se(a) {
1375
+ if (!d.value) return;
1376
+ const T = "touches" in a ? a.touches[0].clientX : a.clientX, W = "touches" in a ? a.touches[0].clientY : a.clientY;
1377
+ if (!R.value) {
1378
+ const ve = Math.abs(T - O.x), He = Math.abs(W - O.y);
1379
+ if (ve + He <= 5) return;
1380
+ R.value = !0;
1381
+ }
1382
+ const { maxX: U, maxY: z } = Le();
1383
+ w.x = Math.min(Math.max(T - S.x, q), U), w.y = Math.min(Math.max(W - S.y, q), z);
1384
+ }
1385
+ function Me() {
1386
+ d.value && (d.value = !1, R.value && (R.value = !1, L = !0, setTimeout(() => {
1387
+ L = !1;
1388
+ }, 0), tt()));
1389
+ }
1390
+ function We(a) {
1391
+ L && (a.preventDefault(), a.stopPropagation(), L = !1);
1285
1392
  }
1286
- function ie(w) {
1287
- x.value = !1, E.value = !0, S.value = !1;
1288
- const O = "touches" in w ? w.touches[0].clientX : w.clientX, W = "touches" in w ? w.touches[0].clientY : w.clientY;
1289
- g.x = O - t.x, g.y = W - t.y;
1393
+ function tt() {
1394
+ try {
1395
+ localStorage.setItem(qe, JSON.stringify({ x: w.x, y: w.y }));
1396
+ } catch {
1397
+ }
1398
+ }
1399
+ function nt() {
1400
+ try {
1401
+ const a = localStorage.getItem(qe);
1402
+ if (a) {
1403
+ const T = JSON.parse(a);
1404
+ typeof T.x == "number" && typeof T.y == "number" && (w.x = T.x, w.y = T.y, M.value = !0);
1405
+ }
1406
+ } catch {
1407
+ }
1290
1408
  }
1291
- function Re() {
1292
- if (!S.value && !x.value) {
1293
- me();
1294
- const w = te();
1295
- i.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + R.value * 3)), i.y = t.y - R.value * 2, i.w = 53, i.h = 53, i.radius = "50%", c.value = !0, l.value = "expanding", u.value = !0, K(() => {
1409
+ function st() {
1410
+ if (!Q.value && !E.value) {
1411
+ ae();
1412
+ const a = Ye();
1413
+ l.x = Math.max(0, Math.min(window.innerWidth - 53, e.x + ue.value * 3)), l.y = e.y - ue.value * 2, l.w = 53, l.h = 53, l.radius = "50%", r.value = !0, o.value = "expanding", h.value = !0, te(() => {
1296
1414
  requestAnimationFrame(() => {
1297
- c.value = !1, i.x = w.x, i.y = w.y, i.w = w.w, i.h = w.h, i.radius = w.radius;
1415
+ r.value = !1, l.x = a.x, l.y = a.y, l.w = a.w, l.h = a.h, l.radius = a.radius;
1298
1416
  });
1299
1417
  }), setTimeout(() => {
1300
- l.value = "idle";
1418
+ o.value = "idle";
1301
1419
  }, 400);
1302
1420
  } else
1303
- S.value = !1;
1421
+ Q.value = !1;
1304
1422
  }
1305
- function te() {
1423
+ function Ye() {
1306
1424
  if (window.innerWidth < 768)
1307
- return d.value ? {
1425
+ return g.value ? {
1308
1426
  x: 0,
1309
1427
  y: 0,
1310
1428
  w: window.innerWidth,
@@ -1317,223 +1435,243 @@ const sn = { class: "container" }, on = { class: "message ai-message greet-messa
1317
1435
  h: window.innerHeight - 16,
1318
1436
  radius: "14px"
1319
1437
  };
1320
- const O = window.innerHeight - 78, W = 54;
1321
- if (d.value) {
1322
- const Ce = window.innerWidth * 0.8;
1438
+ const T = window.innerHeight - 78;
1439
+ let W = 54;
1440
+ if (g.value) {
1441
+ const ve = window.innerWidth * 0.8;
1323
1442
  return {
1324
- x: (window.innerWidth - Ce) / 2,
1443
+ x: (window.innerWidth - ve) / 2,
1325
1444
  y: W,
1326
- w: Ce,
1327
- h: O,
1445
+ w: ve,
1446
+ h: T,
1328
1447
  radius: "14px"
1329
1448
  };
1330
1449
  }
1331
1450
  const U = 490;
1332
- return { x: H.value === "left" ? 24 : window.innerWidth - U - 24, y: W, w: U, h: O, radius: "14px" };
1451
+ let z;
1452
+ return M.value ? (z = Math.min(Math.max(w.x, q), Math.max(q, window.innerWidth - U - q)), W = Math.min(Math.max(w.y, q), Math.max(q, T - q))) : z = b.value === "left" ? 24 : window.innerWidth - U - 24, { x: z, y: W, w: U, h: T, radius: "14px" };
1333
1453
  }
1334
- function Q() {
1335
- if (l.value !== "idle") return;
1336
- const w = te();
1337
- i.x = w.x, i.y = w.y, i.w = w.w, i.h = w.h, i.radius = w.radius, c.value = !0, l.value = "collapsing", K(() => {
1454
+ function at() {
1455
+ if (o.value !== "idle") return;
1456
+ const a = Ye();
1457
+ l.x = a.x, l.y = a.y, l.w = a.w, l.h = a.h, l.radius = a.radius, r.value = !0, o.value = "collapsing", te(() => {
1338
1458
  requestAnimationFrame(() => {
1339
- c.value = !1, i.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + R.value * 3)), i.y = t.y + Math.abs(R.value) * 2, i.w = 53, i.h = 53, i.radius = "50%";
1459
+ r.value = !1, l.x = Math.max(0, Math.min(window.innerWidth - 53, e.x + ue.value * 3)), l.y = e.y + Math.abs(ue.value) * 2, l.w = 53, l.h = 53, l.radius = "50%";
1340
1460
  });
1341
1461
  }), setTimeout(() => {
1342
- u.value = !1, l.value = "idle", s.value = !0;
1462
+ h.value = !1, o.value = "idle", i.value = !0;
1343
1463
  }, 400), setTimeout(() => {
1344
- s.value = !1;
1464
+ i.value = !1;
1345
1465
  }, 1400);
1346
1466
  }
1347
- function G(w) {
1348
- ce(), f.value = "answer", K(() => {
1349
- var O;
1350
- (O = T.value) == null || O.goHistoryMessage(w);
1467
+ function ot(a) {
1468
+ ye(), D.value = "answer", te(() => {
1469
+ var T;
1470
+ (T = I.value) == null || T.goHistoryMessage(a);
1351
1471
  });
1352
1472
  }
1353
- function ke() {
1354
- $.value = "", f.value = "answer", K(() => {
1355
- var w;
1356
- (w = T.value) == null || w.createNewConversation();
1473
+ function it() {
1474
+ P.value = "", D.value = "answer", te(() => {
1475
+ var a;
1476
+ (a = I.value) == null || a.createNewConversation();
1357
1477
  });
1358
1478
  }
1359
- function z() {
1360
- ce(), $.value = "", K(() => {
1361
- var w;
1362
- (w = T.value) == null || w.createNewConversation();
1479
+ function lt() {
1480
+ ye(), P.value = "", te(() => {
1481
+ var a;
1482
+ (a = I.value) == null || a.createNewConversation();
1363
1483
  });
1364
1484
  }
1365
- function le() {
1366
- P.value = !1, M.value = !0;
1485
+ function ct() {
1486
+ _.value = !1, x.value = !0;
1367
1487
  }
1368
- function ce() {
1369
- P.value = !0, setTimeout(() => {
1370
- M.value = !1, P.value = !1;
1488
+ function ye() {
1489
+ _.value = !0, setTimeout(() => {
1490
+ x.value = !1, _.value = !1;
1371
1491
  }, 300);
1372
1492
  }
1373
- function Fe() {
1374
- y.value = v.value, A.value = !1;
1493
+ function rt() {
1494
+ y.value = c.value, $.value = !1;
1375
1495
  }
1376
- se(d, (w) => {
1377
- w ? H.value = "center" : me();
1378
- }), j(() => {
1379
- Ee();
1380
- const w = h.theme || "light";
1381
- $e(w), w === "auto" && (b = lt(() => $e("auto")));
1496
+ se(g, (a) => {
1497
+ a ? b.value = "center" : ae();
1498
+ }), se(h, (a) => {
1499
+ a && M.value && te(() => Be());
1500
+ }), ne(() => {
1501
+ oe(), nt();
1502
+ const a = f.theme || "light";
1503
+ _e(a), a === "auto" && (re = xt(() => _e("auto")));
1382
1504
  });
1383
- function xe() {
1384
- r && clearTimeout(r), r = setTimeout(() => {
1385
- const w = window.innerWidth < 768;
1386
- a.value = w, w && (d.value = !0), we();
1505
+ function Ve() {
1506
+ ce && clearTimeout(ce), ce = setTimeout(() => {
1507
+ const a = window.innerWidth < 768;
1508
+ u.value = a, a && (g.value = !0), F(), M.value && Be();
1387
1509
  }, 100);
1388
1510
  }
1389
- return j(() => {
1390
- window.addEventListener("resize", xe);
1391
- }), Ae(() => {
1392
- window.removeEventListener("resize", xe), r && clearTimeout(r), b == null || b();
1393
- }), j(() => {
1394
- document.addEventListener("mousemove", oe), document.addEventListener("touchmove", oe, { passive: !0 }), document.addEventListener("mouseup", ae), document.addEventListener("touchend", ae);
1395
- }), Ae(() => {
1396
- document.removeEventListener("mousemove", oe), document.removeEventListener("touchmove", oe), document.removeEventListener("mouseup", ae), document.removeEventListener("touchend", ae);
1397
- }), (w, O) => (m(), k("div", null, [
1398
- re(n("div", {
1399
- class: X(["ai-panel", d.value ? "maxWrap" : "minWrap", B.value, l.value !== "idle" ? l.value : "", { morphing: l.value !== "idle", "morph-instant": c.value }]),
1400
- style: Se(ge.value)
1511
+ return ne(() => {
1512
+ window.addEventListener("resize", Ve);
1513
+ }), Te(() => {
1514
+ window.removeEventListener("resize", Ve), ce && clearTimeout(ce), re == null || re();
1515
+ }), ne(() => {
1516
+ document.addEventListener("mousemove", ee), document.addEventListener("touchmove", ee, { passive: !0 }), document.addEventListener("mouseup", fe), document.addEventListener("touchend", fe), document.addEventListener("mousemove", Se), document.addEventListener("touchmove", Se, { passive: !0 }), document.addEventListener("mouseup", Me), document.addEventListener("touchend", Me), document.addEventListener("click", We, !0);
1517
+ }), Te(() => {
1518
+ document.removeEventListener("mousemove", ee), document.removeEventListener("touchmove", ee), document.removeEventListener("mouseup", fe), document.removeEventListener("touchend", fe), document.removeEventListener("mousemove", Se), document.removeEventListener("touchmove", Se), document.removeEventListener("mouseup", Me), document.removeEventListener("touchend", Me), document.removeEventListener("click", We, !0);
1519
+ }), (a, T) => (m(), A("div", null, [
1520
+ de(n("div", {
1521
+ ref_key: "panelRef",
1522
+ ref: p,
1523
+ class: J([
1524
+ "ai-panel",
1525
+ g.value ? "maxWrap" : "minWrap",
1526
+ Ee.value,
1527
+ { "panel-custom": M.value && !g.value && !u.value, dragging: d.value },
1528
+ o.value !== "idle" ? o.value : "",
1529
+ { morphing: o.value !== "idle", "morph-instant": r.value }
1530
+ ]),
1531
+ style: xe([De.value, pe.value])
1401
1532
  }, [
1402
- n("div", Wn, [
1403
- f.value === "info" ? (m(), k("span", {
1533
+ n("div", {
1534
+ class: "header",
1535
+ onMousedown: Ne,
1536
+ onTouchstart: Ne
1537
+ }, [
1538
+ D.value === "info" ? (m(), A("span", {
1404
1539
  key: 0,
1405
- class: X(["back", o.value]),
1406
- onClick: O[0] || (O[0] = (W) => f.value = "answer")
1407
- }, [...O[6] || (O[6] = [
1540
+ class: J(["back", s.value]),
1541
+ onClick: T[0] || (T[0] = (W) => D.value = "answer")
1542
+ }, [...T[6] || (T[6] = [
1408
1543
  n("span", { style: { "font-size": "14px" } }, "←", -1)
1409
- ])], 2)) : (m(), k("p", Yn, [
1410
- n("img", { src: D(We) }, null, 8, Fn)
1544
+ ])], 2)) : (m(), A("p", rs, [
1545
+ n("img", {
1546
+ src: H(Ie),
1547
+ draggable: "false"
1548
+ }, null, 8, us)
1411
1549
  ])),
1412
- n("div", Qn, [
1550
+ n("div", vs, [
1413
1551
  n("span", {
1414
- title: f.value === "info" ? "个人信息" : $.value || D(h).name
1415
- }, V(f.value === "info" ? "个人信息" : $.value || D(h).name), 9, Gn)
1552
+ title: D.value === "info" ? "个人信息" : P.value || H(f).name
1553
+ }, V(D.value === "info" ? "个人信息" : P.value || H(f).name), 9, ds)
1416
1554
  ]),
1417
1555
  n("p", null, [
1418
- re(Y(D(J), {
1556
+ de(X(H(j), {
1419
1557
  class: "op-icon",
1420
1558
  icon: "ic:round-add",
1421
- onClick: ke
1559
+ onClick: it
1422
1560
  }, null, 512), [
1423
- [he, L.value]
1561
+ [we, Re.value]
1424
1562
  ]),
1425
- Y(D(J), {
1426
- class: X(["mute", { active: M.value }]),
1563
+ X(H(j), {
1564
+ class: J(["mute", { active: x.value }]),
1427
1565
  icon: "ic:round-history",
1428
- onClick: O[1] || (O[1] = (W) => M.value ? ce() : le())
1566
+ onClick: T[1] || (T[1] = (W) => x.value ? ye() : ct())
1429
1567
  }, null, 8, ["class"]),
1430
- a.value ? _("", !0) : (m(), Z(D(J), {
1568
+ u.value ? N("", !0) : (m(), Z(H(j), {
1431
1569
  key: 0,
1432
- onClick: O[2] || (O[2] = (W) => d.value = !d.value),
1433
- icon: d.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
1570
+ onClick: T[2] || (T[2] = (W) => g.value = !g.value),
1571
+ icon: g.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
1434
1572
  }, null, 8, ["icon"])),
1435
- Y(D(J), {
1436
- onClick: Q,
1573
+ X(H(j), {
1574
+ onClick: at,
1437
1575
  icon: "ic:round-close"
1438
1576
  })
1439
1577
  ])
1440
- ]),
1441
- re(Y(gn, {
1578
+ ], 32),
1579
+ de(X(Ln, {
1442
1580
  ref_key: "answerRef",
1443
- ref: T,
1444
- defaultSayhello: D(h).defaultSayhello,
1445
- defaultRecommend: D(h).defaultRecommend,
1446
- onTitleGenerated: O[3] || (O[3] = (W) => $.value = W)
1581
+ ref: I,
1582
+ defaultSayhello: H(f).defaultSayhello,
1583
+ defaultRecommend: H(f).defaultRecommend,
1584
+ onTitleGenerated: T[3] || (T[3] = (W) => P.value = W)
1447
1585
  }, null, 8, ["defaultSayhello", "defaultRecommend"]), [
1448
- [he, f.value === "answer"]
1586
+ [we, D.value === "answer"]
1449
1587
  ]),
1450
- f.value === "info" ? (m(), Z(Vn, { key: 0 })) : _("", !0),
1451
- M.value ? (m(), k("div", {
1588
+ D.value === "info" ? (m(), Z(cs, { key: 0 })) : N("", !0),
1589
+ x.value ? (m(), A("div", {
1452
1590
  key: 1,
1453
- class: X(["ai-history-drawer", { closing: P.value }])
1591
+ class: J(["ai-history-drawer", { closing: _.value }])
1454
1592
  }, [
1455
1593
  n("div", {
1456
1594
  class: "ai-history-backdrop",
1457
- onClick: ce
1595
+ onClick: ye
1458
1596
  }),
1459
- n("div", Xn, [
1460
- n("div", Jn, [
1461
- O[7] || (O[7] = n("span", null, "对话记录", -1)),
1462
- Y(D(J), {
1597
+ n("div", hs, [
1598
+ n("div", ms, [
1599
+ T[7] || (T[7] = n("span", null, "对话记录", -1)),
1600
+ X(H(j), {
1463
1601
  icon: "ic:round-close",
1464
1602
  class: "ai-history-drawer-close",
1465
- onClick: ce
1603
+ onClick: ye
1466
1604
  })
1467
1605
  ]),
1468
- Y(Tn, {
1469
- onHistoryDetail: G,
1470
- onNewConversation: z
1606
+ X(qn, {
1607
+ onHistoryDetail: ot,
1608
+ onNewConversation: lt
1471
1609
  })
1472
1610
  ])
1473
- ], 2)) : _("", !0),
1474
- re(n("div", qn, [
1475
- n("div", Un, [
1476
- n("div", jn, [
1477
- O[8] || (O[8] = n("p", { class: "title" }, "修改标题", -1)),
1478
- re(n("textarea", {
1479
- "onUpdate:modelValue": O[4] || (O[4] = (W) => v.value = W),
1611
+ ], 2)) : N("", !0),
1612
+ de(n("div", gs, [
1613
+ n("div", ps, [
1614
+ n("div", fs, [
1615
+ T[8] || (T[8] = n("p", { class: "title" }, "修改标题", -1)),
1616
+ de(n("textarea", {
1617
+ "onUpdate:modelValue": T[4] || (T[4] = (W) => c.value = W),
1480
1618
  placeholder: "请输入新标题"
1481
1619
  }, null, 512), [
1482
- [je, v.value]
1620
+ [gt, c.value]
1483
1621
  ]),
1484
- n("p", zn, [
1622
+ n("p", ys, [
1485
1623
  n("span", {
1486
- onClick: O[5] || (O[5] = (W) => A.value = !1)
1624
+ onClick: T[5] || (T[5] = (W) => $.value = !1)
1487
1625
  }, "取消"),
1488
- n("span", { onClick: Fe }, "确定")
1626
+ n("span", { onClick: rt }, "确定")
1489
1627
  ])
1490
1628
  ])
1491
1629
  ])
1492
1630
  ], 512), [
1493
- [he, A.value]
1631
+ [we, $.value]
1494
1632
  ])
1495
1633
  ], 6), [
1496
- [he, u.value || l.value !== "idle"]
1634
+ [we, h.value || o.value !== "idle"]
1497
1635
  ]),
1498
- re(n("div", {
1499
- class: X(["character", { dragging: E.value, recycling: x.value, "hover-preview": s.value }]),
1500
- style: Se(N.value),
1501
- onMousedown: ie,
1502
- onTouchstart: ie,
1503
- onClick: Re
1636
+ de(n("div", {
1637
+ class: J(["character", { dragging: v.value, recycling: E.value, "hover-preview": i.value }]),
1638
+ style: xe($e.value),
1639
+ onMousedown: Oe,
1640
+ onTouchstart: Oe,
1641
+ onClick: st
1504
1642
  }, [
1505
- n("img", { src: q.value }, null, 8, Kn)
1643
+ n("img", { src: Pe.value }, null, 8, ws)
1506
1644
  ], 38), [
1507
- [he, !u.value]
1645
+ [we, !h.value]
1508
1646
  ])
1509
1647
  ]));
1510
1648
  }
1511
- }), In = ["data-theme"], es = {
1649
+ }), As = ["data-theme"], bs = {
1512
1650
  key: 0,
1513
1651
  class: "ai-voice-input-final"
1514
- }, ts = {
1652
+ }, Ss = {
1515
1653
  key: 1,
1516
1654
  class: "ai-voice-input-interim"
1517
- }, ns = {
1655
+ }, Ms = {
1518
1656
  key: 2,
1519
1657
  class: "ai-voice-input-cursor"
1520
- }, ss = {
1658
+ }, Ts = {
1521
1659
  key: 3,
1522
1660
  class: "ai-voice-input-placeholder"
1523
- }, os = ["disabled"], as = {
1661
+ }, xs = ["disabled"], Es = {
1524
1662
  key: 0,
1525
1663
  class: "ai-voice-input-pulse"
1526
- }, is = {
1664
+ }, Rs = {
1527
1665
  key: 1,
1528
1666
  class: "ai-voice-input-wave"
1529
- }, ls = {
1667
+ }, $s = {
1530
1668
  key: 2,
1531
1669
  class: "ai-voice-input-btn-icon",
1532
1670
  viewBox: "0 0 24 24",
1533
1671
  fill: "currentColor",
1534
1672
  width: "16",
1535
1673
  height: "16"
1536
- }, cs = /* @__PURE__ */ ee({
1674
+ }, Ps = /* @__PURE__ */ le({
1537
1675
  __name: "VoiceInput",
1538
1676
  props: {
1539
1677
  config: {},
@@ -1545,130 +1683,130 @@ const sn = { class: "container" }, on = { class: "message ai-message greet-messa
1545
1683
  className: {}
1546
1684
  },
1547
1685
  emits: ["result", "final", "error", "statusChange", "complete"],
1548
- setup(e, { expose: p, emit: h }) {
1549
- const u = e, l = h, c = {
1686
+ setup(t, { expose: C, emit: f }) {
1687
+ const h = t, o = f, r = {
1550
1688
  idle: "开始录音",
1551
1689
  connecting: "连接中…",
1552
1690
  recording: "停止录音",
1553
1691
  stopping: "识别中…",
1554
1692
  error: "重试"
1555
- }, i = C(""), s = C(""), a = C("idle");
1556
- let d = null;
1557
- const f = F(() => ct(u.config.theme ?? "light")), A = () => {
1558
- d = new _e(u.config, {
1559
- onStatusChange: (E) => {
1560
- a.value = E, l("statusChange", E), E === "idle" && l("complete", i.value);
1693
+ }, l = k(""), i = k(""), u = k("idle");
1694
+ let g = null;
1695
+ const D = Y(() => Et(h.config.theme ?? "light")), $ = () => {
1696
+ g = new Ke(h.config, {
1697
+ onStatusChange: (v) => {
1698
+ u.value = v, o("statusChange", v), v === "idle" && o("complete", l.value);
1561
1699
  },
1562
- onInterim: (E) => {
1563
- s.value = E;
1700
+ onInterim: (v) => {
1701
+ i.value = v;
1564
1702
  },
1565
- onFinal: (E, x) => {
1566
- i.value += E, s.value = "", l("final", E, x);
1703
+ onFinal: (v, E) => {
1704
+ l.value += v, i.value = "", o("final", v, E);
1567
1705
  },
1568
- onResult: (E) => l("result", E),
1569
- onError: (E) => l("error", E)
1706
+ onResult: (v) => o("result", v),
1707
+ onError: (v) => o("error", v)
1570
1708
  });
1571
1709
  };
1572
- j(A), Ne(() => {
1573
- d == null || d.destroy(), d = null;
1710
+ ne($), ze(() => {
1711
+ g == null || g.destroy(), g = null;
1574
1712
  }), se(
1575
- () => [u.config.appId, u.config.appKey, u.config.devPid, u.config.url],
1713
+ () => [h.config.appId, h.config.appKey, h.config.devPid, h.config.url],
1576
1714
  () => {
1577
- d == null || d.destroy(), A();
1715
+ g == null || g.destroy(), $();
1578
1716
  }
1579
1717
  );
1580
- const v = async () => {
1581
- if (d)
1582
- if (a.value === "idle" || a.value === "error")
1718
+ const c = async () => {
1719
+ if (g)
1720
+ if (u.value === "idle" || u.value === "error")
1583
1721
  try {
1584
- await d.start();
1722
+ await g.start();
1585
1723
  } catch {
1586
1724
  }
1587
- else a.value === "recording" && d.stop();
1725
+ else u.value === "recording" && g.stop();
1588
1726
  }, y = () => {
1589
- i.value = "", s.value = "";
1590
- }, $ = F(() => !i.value && !s.value), M = F(() => a.value === "connecting" ? u.connectingText || c.connecting : a.value === "recording" ? u.stopText || c.recording : a.value === "stopping" ? u.stoppingText || c.stopping : a.value === "error" ? c.error : u.startText || c.idle), P = F(() => {
1591
- const E = ["ai-voice-input-btn"];
1592
- return a.value === "recording" && E.push("is-recording"), a.value === "connecting" && E.push("is-connecting"), a.value === "stopping" && E.push("is-stopping"), E.join(" ");
1593
- }), t = F(() => a.value === "connecting" || a.value === "stopping");
1594
- return p({
1727
+ l.value = "", i.value = "";
1728
+ }, P = Y(() => !l.value && !i.value), x = Y(() => u.value === "connecting" ? h.connectingText || r.connecting : u.value === "recording" ? h.stopText || r.recording : u.value === "stopping" ? h.stoppingText || r.stopping : u.value === "error" ? r.error : h.startText || r.idle), _ = Y(() => {
1729
+ const v = ["ai-voice-input-btn"];
1730
+ return u.value === "recording" && v.push("is-recording"), u.value === "connecting" && v.push("is-connecting"), u.value === "stopping" && v.push("is-stopping"), v.join(" ");
1731
+ }), e = Y(() => u.value === "connecting" || u.value === "stopping");
1732
+ return C({
1595
1733
  start: async () => {
1596
- await (d == null ? void 0 : d.start());
1734
+ await (g == null ? void 0 : g.start());
1597
1735
  },
1598
- stop: () => d == null ? void 0 : d.stop(),
1599
- cancel: () => d == null ? void 0 : d.cancel(),
1600
- getText: () => i.value + s.value,
1736
+ stop: () => g == null ? void 0 : g.stop(),
1737
+ cancel: () => g == null ? void 0 : g.cancel(),
1738
+ getText: () => l.value + i.value,
1601
1739
  clear: () => {
1602
- i.value = "", s.value = "";
1740
+ l.value = "", i.value = "";
1603
1741
  },
1604
- getStatus: () => (d == null ? void 0 : d.getStatus()) ?? "idle"
1605
- }), (E, x) => (m(), k("div", {
1606
- class: X(["ai-voice-input", e.className]),
1607
- "data-theme": f.value
1742
+ getStatus: () => (g == null ? void 0 : g.getStatus()) ?? "idle"
1743
+ }), (v, E) => (m(), A("div", {
1744
+ class: J(["ai-voice-input", t.className]),
1745
+ "data-theme": D.value
1608
1746
  }, [
1609
1747
  n("div", {
1610
- class: X(["ai-voice-input-display", { "is-empty": $.value }])
1748
+ class: J(["ai-voice-input-display", { "is-empty": P.value }])
1611
1749
  }, [
1612
- i.value ? (m(), k("span", es, V(i.value), 1)) : _("", !0),
1613
- s.value ? (m(), k("span", ts, V(s.value), 1)) : _("", !0),
1614
- a.value === "recording" && !s.value ? (m(), k("span", ns)) : _("", !0),
1615
- $.value ? (m(), k("span", ss, V(e.placeholder), 1)) : _("", !0)
1750
+ l.value ? (m(), A("span", bs, V(l.value), 1)) : N("", !0),
1751
+ i.value ? (m(), A("span", Ss, V(i.value), 1)) : N("", !0),
1752
+ u.value === "recording" && !i.value ? (m(), A("span", Ms)) : N("", !0),
1753
+ P.value ? (m(), A("span", Ts, V(t.placeholder), 1)) : N("", !0)
1616
1754
  ], 2),
1617
1755
  n("button", {
1618
1756
  type: "button",
1619
- class: X(P.value),
1620
- disabled: t.value,
1621
- onClick: v
1757
+ class: J(_.value),
1758
+ disabled: e.value,
1759
+ onClick: c
1622
1760
  }, [
1623
- a.value === "recording" ? (m(), k("span", as)) : a.value === "connecting" || a.value === "stopping" ? (m(), k("span", is, [...x[0] || (x[0] = [
1761
+ u.value === "recording" ? (m(), A("span", Es)) : u.value === "connecting" || u.value === "stopping" ? (m(), A("span", Rs, [...E[0] || (E[0] = [
1624
1762
  n("span", null, null, -1),
1625
1763
  n("span", null, null, -1),
1626
1764
  n("span", null, null, -1),
1627
1765
  n("span", null, null, -1),
1628
1766
  n("span", null, null, -1)
1629
- ])])) : (m(), k("svg", ls, [...x[1] || (x[1] = [
1767
+ ])])) : (m(), A("svg", $s, [...E[1] || (E[1] = [
1630
1768
  n("path", { d: "M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3z" }, null, -1),
1631
1769
  n("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)
1632
1770
  ])])),
1633
- n("span", null, V(M.value), 1)
1634
- ], 10, os),
1635
- $.value ? _("", !0) : (m(), k("button", {
1771
+ n("span", null, V(x.value), 1)
1772
+ ], 10, xs),
1773
+ P.value ? N("", !0) : (m(), A("button", {
1636
1774
  key: 0,
1637
1775
  type: "button",
1638
1776
  class: "ai-voice-input-btn ai-voice-input-clear-btn",
1639
1777
  title: "清空",
1640
1778
  onClick: y
1641
1779
  }, " 清空 "))
1642
- ], 10, In));
1780
+ ], 10, As));
1643
1781
  }
1644
- }), rs = (e, p) => {
1645
- const h = e.__vccOpts || e;
1646
- for (const [u, l] of p)
1647
- h[u] = l;
1648
- return h;
1649
- }, us = /* @__PURE__ */ rs(cs, [["__scopeId", "data-v-5b959b70"]]);
1650
- let fe = null;
1651
- const ps = (e) => {
1652
- Ve(e);
1653
- }, fs = (e) => {
1654
- const p = e || document.body, h = document.createElement("div");
1655
- h.id = "ai-assist-root";
1656
- const u = de();
1657
- $e(u.theme), rt(), p.appendChild(h), fe = ze(Ye), fe.mount(h);
1658
- }, ys = () => {
1659
- fe && (fe.unmount(), fe = null);
1660
- const e = document.getElementById("ai-assist-root");
1661
- e && e.remove();
1662
- }, ws = {
1663
- install(e, p) {
1664
- Ve(p), e.component("AiAssist", Ye), e.component("VoiceInput", us);
1782
+ }), Ds = (t, C) => {
1783
+ const f = t.__vccOpts || t;
1784
+ for (const [h, o] of C)
1785
+ f[h] = o;
1786
+ return f;
1787
+ }, Hs = /* @__PURE__ */ Ds(Ps, [["__scopeId", "data-v-5b959b70"]]);
1788
+ let Ae = null;
1789
+ const Ws = (t) => {
1790
+ Ze(t);
1791
+ }, Ys = (t) => {
1792
+ const C = t || document.body, f = document.createElement("div");
1793
+ f.id = "ai-assist-root";
1794
+ const h = ge();
1795
+ _e(h.theme), Rt(), C.appendChild(f), Ae = pt(et), Ae.mount(f);
1796
+ }, Vs = () => {
1797
+ Ae && (Ae.unmount(), Ae = null);
1798
+ const t = document.getElementById("ai-assist-root");
1799
+ t && t.remove();
1800
+ }, Xs = {
1801
+ install(t, C) {
1802
+ Ze(C), t.component("AiAssist", et), t.component("VoiceInput", Hs);
1665
1803
  }
1666
1804
  };
1667
1805
  export {
1668
- Ye as AiAssist,
1669
- us as VoiceInput,
1670
- ws as default,
1671
- ps as initAiAssist,
1672
- fs as mountAiAssist,
1673
- ys as unmountAiAssist
1806
+ et as AiAssist,
1807
+ Hs as VoiceInput,
1808
+ Xs as default,
1809
+ Ws as initAiAssist,
1810
+ Ys as mountAiAssist,
1811
+ Vs as unmountAiAssist
1674
1812
  };