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