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