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