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