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