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