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