@somecat/ai-assist-sdk 1.2.4 → 1.2.5
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-Bqxc2mD6.mjs → index-DElfgKrt.mjs} +5 -2
- 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 +2565 -2561
- package/dist/vue/components/answer/composables/useTypewriter.d.ts +2 -2
- package/dist/vue/index.mjs +1133 -1128
- package/package.json +1 -1
package/dist/vue/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as xe, ref as p, watch as ae, nextTick as ne, onUnmounted as st, openBlock as m, createElementBlock as
|
|
2
|
-
import { a as
|
|
3
|
-
import { f as bn, s as Le, a as
|
|
4
|
-
import { BulbOutlined as xn, SearchOutlined as
|
|
5
|
-
import { Icon as
|
|
6
|
-
const Rn = "data:image/png;base64,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",
|
|
1
|
+
import { defineComponent as xe, ref as p, watch as ae, nextTick as ne, onUnmounted as st, openBlock as m, createElementBlock as x, normalizeClass as q, createElementVNode as a, toDisplayString as G, createVNode as K, Transition as sn, withCtx as an, unref as $, createCommentVNode as X, computed as O, reactive as te, Fragment as Se, createStaticVNode as ln, withModifiers as se, createBlock as oe, renderList as Oe, Teleport as _t, onMounted as pe, onBeforeUnmount as $t, withDirectives as De, withKeys as lt, vModelText as Pt, normalizeStyle as ot, vShow as Ve, createApp as un } from "vue";
|
|
2
|
+
import { a as ut, r as ct, p as rt, u as cn, V as at, c as St, g as rn, s as vn, b as xt, e as dn, d as hn, f as Qe, h as gn, i as mn, j as fn, k as pn, l as yn, m as vt, w as wn, n as kn, o as Cn, q as Lt } from "../chunks/index-DElfgKrt.mjs";
|
|
3
|
+
import { f as bn, s as Le, a as Ot, b as An, c as Sn } from "../chunks/index-DBik4Gma.mjs";
|
|
4
|
+
import { BulbOutlined as xn, SearchOutlined as Tt, CheckOutlined as Tn, CopyOutlined as En, RedoOutlined as Mn, CloseOutlined as Dn } from "@ant-design/icons-vue";
|
|
5
|
+
import { Icon as Z } from "@iconify/vue";
|
|
6
|
+
const Rn = "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==", Hn = { class: "thinking-block__title" }, _n = ["innerHTML"], $n = /* @__PURE__ */ xe({
|
|
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 = (f) => {
|
|
32
|
+
if (S === 0) {
|
|
33
|
+
S = f, w = requestAnimationFrame(i);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
36
|
+
const g = Math.min(f - S, 100);
|
|
37
|
+
S = f;
|
|
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
|
ae(
|
|
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
|
), ae(
|
|
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
|
), ae(
|
|
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
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const
|
|
90
|
-
!
|
|
88
|
+
function B() {
|
|
89
|
+
const T = R.value;
|
|
90
|
+
!T || !d.value || L || (T.scrollTop = T.scrollHeight);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
y.isStreaming &&
|
|
92
|
+
function W() {
|
|
93
|
+
y.isStreaming && B();
|
|
94
94
|
}
|
|
95
|
-
return ae(
|
|
96
|
-
y.isStreaming && ne(
|
|
95
|
+
return ae(l, () => {
|
|
96
|
+
y.isStreaming && ne(B);
|
|
97
97
|
}), st(() => {
|
|
98
|
-
k(),
|
|
99
|
-
}), (
|
|
100
|
-
class:
|
|
101
|
-
"thinking-block--expanded":
|
|
98
|
+
k(), D();
|
|
99
|
+
}), (T, i) => (m(), 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
|
-
(m(),
|
|
112
|
-
class:
|
|
110
|
+
a("span", Hn, G(e.isStreaming ? "深度思考中" : "深度思考"), 1),
|
|
111
|
+
(m(), 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,23 +122,23 @@ 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(sn, {
|
|
126
126
|
name: "thinking-expand",
|
|
127
|
-
onAfterEnter:
|
|
127
|
+
onAfterEnter: W
|
|
128
128
|
}, {
|
|
129
|
-
default:
|
|
130
|
-
|
|
129
|
+
default: an(() => [
|
|
130
|
+
d.value ? (m(), 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, _n)
|
|
141
|
+
], 544)) : X("", !0)
|
|
142
142
|
]),
|
|
143
143
|
_: 1
|
|
144
144
|
})
|
|
@@ -150,31 +150,25 @@ const Rn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
150
150
|
}, Ln = { class: "thought-collapse-bar__text" }, On = {
|
|
151
151
|
key: 2,
|
|
152
152
|
class: "thought-collapse-bar__duration"
|
|
153
|
-
},
|
|
153
|
+
}, Nn = { class: "thought-collapse-bar__action" }, Wn = { class: "agent-thought__spinner" }, Bn = { class: "agent-thought__text" }, Yn = {
|
|
154
154
|
key: 0,
|
|
155
155
|
class: "agent-thought__duration"
|
|
156
156
|
}, Vn = {
|
|
157
157
|
key: 1,
|
|
158
158
|
class: "agent-thought__duration"
|
|
159
|
-
}, Xn = { key: 0 }, Fn = ["innerHTML"], Qn = {
|
|
160
|
-
key: 3,
|
|
161
|
-
class: "streaming-cursor"
|
|
162
|
-
}, Gn = ["innerHTML"], Un = {
|
|
163
|
-
key: 0,
|
|
164
|
-
class: "streaming-cursor"
|
|
165
|
-
}, qn = {
|
|
159
|
+
}, Xn = { key: 0 }, Fn = ["innerHTML"], Gn = ["innerHTML"], Qn = {
|
|
166
160
|
key: 3,
|
|
167
161
|
class: "message-error"
|
|
168
|
-
},
|
|
162
|
+
}, Kn = {
|
|
169
163
|
key: 4,
|
|
170
164
|
class: "message-toolbar"
|
|
171
|
-
},
|
|
165
|
+
}, In = ["data-tooltip"], qn = {
|
|
172
166
|
class: "tooltip-enhanced",
|
|
173
167
|
"data-tooltip": "重新回答"
|
|
174
|
-
},
|
|
168
|
+
}, Jn = {
|
|
175
169
|
key: 1,
|
|
176
170
|
class: "message-content"
|
|
177
|
-
},
|
|
171
|
+
}, zn = ["src"], Un = /* @__PURE__ */ xe({
|
|
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
|
-
ae(
|
|
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
|
+
ae(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 = te(/* @__PURE__ */ new Map()),
|
|
215
|
-
function
|
|
214
|
+
const W = te(/* @__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 f() {
|
|
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: _ } = cn();
|
|
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 m(),
|
|
237
|
-
class:
|
|
235
|
+
var A;
|
|
236
|
+
return m(), x("div", {
|
|
237
|
+
class: q(["message", `${e.msg.type}-message`])
|
|
238
238
|
}, [
|
|
239
|
-
e.msg.type === "ai" ? (m(),
|
|
240
|
-
(e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING) && !e.msg.thinkingContent && !e.msg.content ? (m(),
|
|
241
|
-
|
|
242
|
-
])])) :
|
|
243
|
-
e.msg.segments && e.msg.segments.length ? (m(),
|
|
239
|
+
e.msg.type === "ai" ? (m(), x(Se, { key: 0 }, [
|
|
240
|
+
(e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING) && !e.msg.thinkingContent && !e.msg.content ? (m(), x("div", Pn, [...s[4] || (s[4] = [
|
|
241
|
+
ln('<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 ? (m(), 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 ? (m(), x("div", {
|
|
250
250
|
key: 0,
|
|
251
|
-
class:
|
|
252
|
-
onClick: s[0] || (s[0] = se((
|
|
251
|
+
class: q(["thought-collapse-bar", { "thought-collapse-bar--expanded": u.value }]),
|
|
252
|
+
onClick: s[0] || (s[0] = se((b) => u.value = !u.value, ["stop"]))
|
|
253
253
|
}, [
|
|
254
|
-
|
|
254
|
+
P.value ? (m(), oe($(xn), {
|
|
255
255
|
key: 0,
|
|
256
256
|
class: "thought-collapse-bar__icon"
|
|
257
|
-
})) : (m(), oe(
|
|
257
|
+
})) : (m(), oe($(Tt), {
|
|
258
258
|
key: 1,
|
|
259
259
|
class: "thought-collapse-bar__icon"
|
|
260
260
|
})),
|
|
261
|
-
a("span", Ln,
|
|
262
|
-
|
|
263
|
-
a("span",
|
|
264
|
-
(m(),
|
|
265
|
-
class:
|
|
261
|
+
a("span", Ln, G(R.value), 1),
|
|
262
|
+
n.value > 0 ? (m(), x("span", On, G(B(n.value)), 1)) : X("", !0),
|
|
263
|
+
a("span", Nn, G(u.value ? "收起" : "查看"), 1),
|
|
264
|
+
(m(), 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,117 +274,121 @@ 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 ? (m(), oe($n, {
|
|
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 ? (m(), 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", Wn, [
|
|
289
|
+
K($(Tt))
|
|
290
290
|
]),
|
|
291
|
-
a("span",
|
|
292
|
-
!
|
|
293
|
-
!
|
|
294
|
-
], 2)) :
|
|
295
|
-
(m(!0),
|
|
296
|
-
|
|
291
|
+
a("span", Bn, G(w.value ? "工具调用中" : "工具调用"), 1),
|
|
292
|
+
!w.value && C.value.length > 1 ? (m(), x("span", Yn, " 已调用 " + G(C.value.length) + " 次 ", 1)) : X("", !0),
|
|
293
|
+
!w.value && S.value > 0 ? (m(), x("span", Vn, G(B(S.value)), 1)) : X("", !0)
|
|
294
|
+
], 2)) : X("", !0),
|
|
295
|
+
(m(!0), x(Se, null, Oe(e.msg.segments, (b, _) => (m(), x(Se, { key: _ }, [
|
|
296
|
+
b.type === "answer" ? (m(), x("div", Xn, [
|
|
297
297
|
a("div", {
|
|
298
|
-
innerHTML:
|
|
298
|
+
innerHTML: $(ut)(
|
|
299
|
+
$(ct)($(rt)(e.getSegmentDisplayContent(e.index, _, b, e.msg))),
|
|
300
|
+
e.msg.status === e.STATUS.ANSWERING && _ === r.value
|
|
301
|
+
)
|
|
299
302
|
}, null, 8, Fn)
|
|
300
|
-
])) :
|
|
301
|
-
], 64))), 128))
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
!((r = e.msg.segments) != null && r.length) && e.msg.content ? (m(), S("div", {
|
|
303
|
+
])) : X("", !0)
|
|
304
|
+
], 64))), 128))
|
|
305
|
+
], 512)) : X("", !0),
|
|
306
|
+
!((A = e.msg.segments) != null && A.length) && e.msg.content ? (m(), 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, Gn)
|
|
318
|
+
], 512)) : X("", !0),
|
|
319
|
+
e.msg.errorMessage ? (m(), x("div", Qn, [
|
|
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 ? (m(),
|
|
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 ? (m(), x("div", Kn, [
|
|
320
324
|
a("div", {
|
|
321
325
|
class: "tooltip-enhanced",
|
|
322
326
|
"data-tooltip": W.get(e.index) ? "已复制" : "复制回答"
|
|
323
327
|
}, [
|
|
324
|
-
W.get(e.index) ? (m(), oe(
|
|
328
|
+
W.get(e.index) ? (m(), oe($(Tn), {
|
|
325
329
|
key: 0,
|
|
326
330
|
class: "message-toolbar__check"
|
|
327
|
-
})) : (m(), oe(
|
|
331
|
+
})) : (m(), oe($(En), {
|
|
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,
|
|
332
|
-
a("div",
|
|
333
|
-
|
|
334
|
-
onClick: s[2] || (s[2] = (
|
|
335
|
+
], 8, In),
|
|
336
|
+
a("div", qn, [
|
|
337
|
+
K($(Mn), {
|
|
338
|
+
onClick: s[2] || (s[2] = (b) => o.$emit("regenerate"))
|
|
335
339
|
})
|
|
336
340
|
])
|
|
337
|
-
])) :
|
|
338
|
-
], 64)) : (m(),
|
|
341
|
+
])) : X("", !0)
|
|
342
|
+
], 64)) : (m(), x("div", Jn, G(e.msg.content), 1)),
|
|
339
343
|
(m(), oe(_t, { to: "#ai-assist-root" }, [
|
|
340
|
-
|
|
344
|
+
T.value ? (m(), x("div", {
|
|
341
345
|
key: 0,
|
|
342
346
|
class: "ai-image-preview-overlay",
|
|
343
|
-
onClick:
|
|
347
|
+
onClick: f
|
|
344
348
|
}, [
|
|
345
349
|
a("img", {
|
|
346
|
-
src:
|
|
350
|
+
src: T.value,
|
|
347
351
|
class: "ai-image-preview-overlay__img",
|
|
348
352
|
onClick: s[3] || (s[3] = se(() => {
|
|
349
353
|
}, ["stop"]))
|
|
350
|
-
}, null, 8,
|
|
354
|
+
}, null, 8, zn),
|
|
351
355
|
a("button", {
|
|
352
356
|
class: "ai-image-preview-overlay__close",
|
|
353
|
-
onClick: se(
|
|
357
|
+
onClick: se(f, ["stop"])
|
|
354
358
|
}, [
|
|
355
|
-
|
|
359
|
+
K($(Dn))
|
|
356
360
|
])
|
|
357
|
-
])) :
|
|
361
|
+
])) : X("", !0)
|
|
358
362
|
]))
|
|
359
363
|
], 2);
|
|
360
364
|
};
|
|
361
365
|
}
|
|
362
|
-
}),
|
|
366
|
+
}), jn = {
|
|
363
367
|
key: 0,
|
|
364
368
|
class: "input-container voice-mode"
|
|
365
|
-
},
|
|
369
|
+
}, Zn = {
|
|
366
370
|
key: 0,
|
|
367
371
|
class: "final"
|
|
368
|
-
},
|
|
372
|
+
}, eo = {
|
|
369
373
|
key: 1,
|
|
370
374
|
class: "interim"
|
|
371
|
-
},
|
|
375
|
+
}, to = {
|
|
372
376
|
key: 2,
|
|
373
377
|
class: "placeholder"
|
|
374
|
-
},
|
|
378
|
+
}, no = ["onKeydown"], oo = ["data-tooltip"], so = {
|
|
375
379
|
key: 2,
|
|
376
380
|
class: "moveTB"
|
|
377
|
-
},
|
|
381
|
+
}, ao = {
|
|
378
382
|
key: 1,
|
|
379
383
|
class: "input-container"
|
|
380
|
-
},
|
|
384
|
+
}, io = ["value", "disabled"], lo = {
|
|
381
385
|
key: 0,
|
|
382
386
|
class: "tooltip-enhanced stop",
|
|
383
387
|
"data-tooltip": "停止生成"
|
|
384
|
-
},
|
|
388
|
+
}, uo = ["data-tooltip"], co = {
|
|
385
389
|
key: 3,
|
|
386
390
|
class: "moveTB"
|
|
387
|
-
},
|
|
391
|
+
}, ro = /* @__PURE__ */ xe({
|
|
388
392
|
__name: "ChatInput",
|
|
389
393
|
props: {
|
|
390
394
|
modelValue: {},
|
|
@@ -395,695 +399,695 @@ 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
|
-
() => at.isSupported() && !
|
|
411
|
+
() => at.isSupported() && !d.modelValue.trim() && !d.isGenerating
|
|
408
412
|
);
|
|
409
|
-
function
|
|
410
|
-
|
|
411
|
-
onStatusChange: (
|
|
412
|
-
|
|
413
|
+
function B() {
|
|
414
|
+
S = new at({}, {
|
|
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
|
-
pe(
|
|
426
|
-
|
|
427
|
-
}), ae([k,
|
|
429
|
+
pe(B), $t(() => {
|
|
430
|
+
S == null || S.destroy(), S = null;
|
|
431
|
+
}), ae([k, c], () => {
|
|
428
432
|
ne(() => {
|
|
429
|
-
|
|
433
|
+
C.value && (C.value.scrollTop = C.value.scrollHeight);
|
|
430
434
|
});
|
|
431
|
-
}), ae(
|
|
432
|
-
|
|
433
|
-
var
|
|
434
|
-
return (
|
|
435
|
+
}), ae(l, (g) => {
|
|
436
|
+
g === "idle" && u.value && (r.value = (k.value + c.value).trim(), ne(() => {
|
|
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 f() {
|
|
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 ? (m(), x("div", jn, [
|
|
458
462
|
a("div", {
|
|
459
|
-
class:
|
|
463
|
+
class: q(["voice-visual", { recording: D.value }])
|
|
460
464
|
}, null, 2),
|
|
461
|
-
|
|
465
|
+
P.value ? (m(), 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 ? (m(),
|
|
469
|
-
|
|
470
|
-
!k.value && !
|
|
471
|
-
], 512)) : De((m(),
|
|
472
|
+
k.value ? (m(), x("span", Zn, G(k.value), 1)) : X("", !0),
|
|
473
|
+
c.value ? (m(), x("span", eo, G(c.value), 1)) : X("", !0),
|
|
474
|
+
!k.value && !c.value ? (m(), x("span", to, G(E.value ? "启动中…" : "正在聆听…"), 1)) : X("", !0)
|
|
475
|
+
], 512)) : De((m(), 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
483
|
onKeydown: lt(se(i, ["prevent"]), ["esc"]),
|
|
480
|
-
onKeyup:
|
|
481
|
-
}, null, 40,
|
|
482
|
-
[
|
|
484
|
+
onKeyup: o[1] || (o[1] = lt((s) => L.value && f(), ["enter"]))
|
|
485
|
+
}, null, 40, no)), [
|
|
486
|
+
[Pt, 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 && f())
|
|
498
502
|
}, [
|
|
499
|
-
|
|
503
|
+
K($(Z), {
|
|
500
504
|
class: "op-icon",
|
|
501
505
|
icon: "fluent-color:send-16"
|
|
502
506
|
})
|
|
503
|
-
], 10,
|
|
504
|
-
e.hasScroll && !e.isAtBottom ? (m(),
|
|
505
|
-
|
|
507
|
+
], 10, oo),
|
|
508
|
+
e.hasScroll && !e.isAtBottom ? (m(), x("div", so, [
|
|
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
|
-
])) : (m(),
|
|
514
|
+
])) : X("", !0)
|
|
515
|
+
])) : (m(), x("div", ao, [
|
|
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
|
-
}, null, 40,
|
|
520
|
-
e.isGenerating && e.lastUserMessage ? (m(),
|
|
521
|
-
|
|
523
|
+
}, null, 40, io),
|
|
524
|
+
e.isGenerating && e.lastUserMessage ? (m(), x("div", lo, [
|
|
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 ? (m(),
|
|
530
|
+
])) : n.value ? (m(), 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
|
-
])) : (m(),
|
|
540
|
+
])) : (m(), 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
|
-
], 10,
|
|
547
|
-
e.hasScroll && !e.isAtBottom ? (m(),
|
|
548
|
-
|
|
550
|
+
], 10, uo)),
|
|
551
|
+
e.hasScroll && !e.isAtBottom ? (m(), x("div", co, [
|
|
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
|
-
function
|
|
558
|
-
const y = p(!0),
|
|
559
|
-
function
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
|
|
561
|
+
function vo(e) {
|
|
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
|
|
572
|
+
function u() {
|
|
569
573
|
ne(() => {
|
|
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
|
-
function
|
|
584
|
+
function ho() {
|
|
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
|
-
function
|
|
604
|
-
let y = null,
|
|
605
|
-
function
|
|
606
|
-
y = k(y || [...e.value]),
|
|
607
|
-
|
|
607
|
+
function go(e) {
|
|
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
|
|
616
|
-
const
|
|
617
|
-
let
|
|
618
|
-
function
|
|
619
|
-
if (
|
|
620
|
-
const
|
|
621
|
-
if (
|
|
622
|
-
|
|
619
|
+
function mo(e, y, d) {
|
|
620
|
+
const h = /* @__PURE__ */ new Set([d.ANSWERING, d.THINKING, d.RETHINKING]), u = te(/* @__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 f = T.content, g = k.value.get(i) ?? 0, o = f.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, f.length);
|
|
641
|
+
k.value.set(i, _), u.set(i, f.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
|
-
function
|
|
676
|
+
function fo({
|
|
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((f) => ({ ...f })),
|
|
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 bn(
|
|
719
|
+
const T = c.baseUrl.replace(/\/+$/, "") + "/" + R.replace(/^\/+/, "");
|
|
720
|
+
await bn(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 f;
|
|
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((ue) => ({ ...ue })),
|
|
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 = (f = A.map((_, H) => ({ s: _, i: H })).reverse().find((_) => _.s.type === "answer")) == null ? void 0 : f.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 f = (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 && !f ? "已停止回答" : f,
|
|
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 f = [...e.value];
|
|
912
|
+
f[n] && (f[n] = { ...f[n], content: `
|
|
913
|
+
⚠️ 请求异常,已终止`, status: k.ERROR }), e.value = f, 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 Et(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
|
}
|
|
941
|
-
function
|
|
945
|
+
function po(e) {
|
|
942
946
|
return e.queryAgainStreamApi || e.queryAgainApi || e.chatQueryStreamApi || e.chatQueryApi;
|
|
943
947
|
}
|
|
944
|
-
function
|
|
948
|
+
function yo({
|
|
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 = te({
|
|
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, f) {
|
|
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 St(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 dn(S, C.titleGenerateApp);
|
|
980
|
+
if (!s) return;
|
|
981
|
+
const A = f.length > 500 ? f.slice(0, 500) : f, b = `用户提问:${i}
|
|
982
|
+
AI回答:${A}`, H = await xt().post(S.chatQueryApi, {
|
|
983
|
+
app: C.titleGenerateApp,
|
|
984
|
+
data: { Query: b, AppConversationID: s }
|
|
985
|
+
}), N = Et(H.data.data);
|
|
986
|
+
N && (await hn(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 (!
|
|
993
|
+
if (!i || d.value) return;
|
|
994
|
+
if (!u.value && (await W(), !u.value)) {
|
|
991
995
|
Le("创建会话失败,请重试");
|
|
992
996
|
return;
|
|
993
997
|
}
|
|
994
|
-
const
|
|
998
|
+
const f = 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), f && !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 xt().post(S.chatQueryApi, {
|
|
1019
|
+
app: C.app ?? 1,
|
|
1020
|
+
data: { Query: i, AppConversationID: u.value }
|
|
1021
|
+
}), b = Et(A.data);
|
|
1022
|
+
e.value = [...e.value.slice(0, -1), { type: "ai", content: b, status: r.COMPLETED }], f && !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 f = e.value.length - 1, g = po(S);
|
|
1033
|
+
await k(g, {
|
|
1034
|
+
MessageID: h.value,
|
|
1035
|
+
AppConversationID: u.value,
|
|
1032
1036
|
ResponseMode: "streaming"
|
|
1033
|
-
},
|
|
1037
|
+
}, f, 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 vn(
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
} catch (
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1043
|
+
await vn(S, h.value);
|
|
1044
|
+
const f = [...e.value];
|
|
1045
|
+
f[i] && (f[i] = { ...f[i], content: f[i].content || "已停止回答", status: r.STOP }), e.value = f, d.value = !1, E.first.abort(), E.first = new AbortController(), E.again.abort(), E.again = new AbortController(), c.value = !0;
|
|
1046
|
+
} catch (f) {
|
|
1047
|
+
const g = [...e.value];
|
|
1048
|
+
g[i] && (g[i] = { ...g[i], content: (f == null ? void 0 : f.message) || "系统繁忙,请稍后再试", status: r.ERROR }), e.value = g;
|
|
1045
1049
|
}
|
|
1046
1050
|
}
|
|
1047
|
-
async function
|
|
1048
|
-
var
|
|
1049
|
-
|
|
1051
|
+
async function B(i) {
|
|
1052
|
+
var f, 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
|
-
Le((
|
|
1055
|
+
const o = await rn(S, i), s = [];
|
|
1056
|
+
if ((f = o == null ? void 0 : o.messages) != null && f.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
|
+
Le((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
|
-
Le((
|
|
1068
|
+
const f = await St(S);
|
|
1069
|
+
(i = f == null ? void 0 : f.conversation) != null && i.appConversationID && (u.value = f.conversation.appConversationID);
|
|
1070
|
+
} catch (f) {
|
|
1071
|
+
Le((f == null ? void 0 : f.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
|
-
const
|
|
1079
|
+
const wo = { class: "container" }, ko = { class: "chat-wrap" }, Co = { class: "message ai-message greet-message" }, bo = { class: "ai-greet" }, Ao = ["src"], So = {
|
|
1076
1080
|
key: 0,
|
|
1077
1081
|
class: "message ai-message recommend-message"
|
|
1078
|
-
},
|
|
1082
|
+
}, xo = { class: "ai-recommend" }, To = { class: "recommend-header" }, Eo = ["src"], Mo = ["onClick"], Do = /* @__PURE__ */ xe({
|
|
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,150 +1095,151 @@ 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 = Qe(), l = p([]), r = p(""), C = p(!1), w = p(""), S = p(""), E = p(null), D = te({ 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: f } = vo(E), { enhanceCodeBlocks: g } = ho(), { batchMessagesUpdate: o, flushMessagesBatch: s } = go(l), { displayedContent: A, streamingIndexRef: b, startTypewriter: _, stopTypewriter: H, getSegmentDisplayContent: N } = mo(
|
|
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: ye, toggleStop: we, goHistoryMessage:
|
|
1116
|
-
messages:
|
|
1117
|
-
userInput:
|
|
1118
|
-
isGenerating:
|
|
1119
|
-
lastUserMessage:
|
|
1120
|
-
conversationId:
|
|
1121
|
-
doStreamRequest:
|
|
1110
|
+
h
|
|
1111
|
+
), { doStreamRequest: J, issTop: ue } = fo({
|
|
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: ye, toggleStop: we, goHistoryMessage: Ne, resetConversation: He } = yo({
|
|
1120
|
+
messages: l,
|
|
1121
|
+
userInput: r,
|
|
1122
|
+
isGenerating: C,
|
|
1123
|
+
lastUserMessage: w,
|
|
1124
|
+
conversationId: S,
|
|
1125
|
+
doStreamRequest: J,
|
|
1122
1126
|
issTop: ue,
|
|
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
|
-
|
|
1132
|
+
function I() {
|
|
1133
|
+
l.value = [], w.value = "", He();
|
|
1130
1134
|
}
|
|
1131
|
-
const ke = O(() =>
|
|
1132
|
-
y({ goHistoryMessage:
|
|
1135
|
+
const ke = O(() => l.value.length === 0);
|
|
1136
|
+
y({ goHistoryMessage: Ne, createNewConversation: I, isEmptyConversation: ke });
|
|
1133
1137
|
const Ce = p(/* @__PURE__ */ new Map());
|
|
1134
|
-
function Te(
|
|
1135
|
-
|
|
1138
|
+
function Te(Y, V) {
|
|
1139
|
+
Y ? Ce.value.set(V, Y) : Ce.value.delete(V);
|
|
1136
1140
|
}
|
|
1137
|
-
ae(
|
|
1141
|
+
ae(l, () => {
|
|
1138
1142
|
ne(() => {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
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
|
+
}), _(), Ce.value.forEach((Y) => {
|
|
1147
|
+
g(Y);
|
|
1148
|
+
}), f();
|
|
1144
1149
|
});
|
|
1145
1150
|
}, { deep: !0 });
|
|
1146
1151
|
let ce = null;
|
|
1147
1152
|
pe(() => {
|
|
1148
|
-
|
|
1153
|
+
u.defaultSayhello && (D.text1 = u.defaultSayhello.text1, D.text2 = u.defaultSayhello.text2), u.defaultRecommend && (P.value = gn(u.defaultRecommend));
|
|
1149
1154
|
}), pe(() => {
|
|
1150
|
-
|
|
1155
|
+
E.value && (ce = () => f(), E.value.addEventListener("scroll", ce), f());
|
|
1151
1156
|
});
|
|
1152
1157
|
const re = p(null);
|
|
1153
1158
|
let ve = !1, be = 0, Ee = 0;
|
|
1154
|
-
function de(
|
|
1155
|
-
var
|
|
1156
|
-
const V = (
|
|
1157
|
-
return parseFloat((V == null ? void 0 : V.style.getPropertyValue(
|
|
1159
|
+
function de(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;
|
|
1158
1163
|
}
|
|
1159
|
-
function
|
|
1160
|
-
return "touches" in
|
|
1164
|
+
function We(Y) {
|
|
1165
|
+
return "touches" in Y ? Y.touches[0].clientY : Y.clientY;
|
|
1161
1166
|
}
|
|
1162
|
-
function ie(
|
|
1163
|
-
const V =
|
|
1164
|
-
V && (
|
|
1167
|
+
function ie(Y) {
|
|
1168
|
+
const V = E.value;
|
|
1169
|
+
V && (Y.preventDefault(), ve = !0, be = We(Y), V.scrollTop, Ee = de("--ai-thumb-top"), window.addEventListener("mousemove", Q), window.addEventListener("mouseup", Ae), window.addEventListener("touchmove", Q, { passive: !1 }), window.addEventListener("touchend", Ae));
|
|
1165
1170
|
}
|
|
1166
|
-
function
|
|
1167
|
-
const V =
|
|
1171
|
+
function Q(Y) {
|
|
1172
|
+
const V = E.value;
|
|
1168
1173
|
if (!ve || !V) return;
|
|
1169
|
-
|
|
1170
|
-
const
|
|
1171
|
-
V.scrollTop =
|
|
1174
|
+
Y.preventDefault();
|
|
1175
|
+
const U = We(Y) - be, j = V.clientHeight, he = V.scrollHeight, ge = de("--ai-thumb-height"), Ie = j - ge, qe = Math.min(Math.max(Ee + U, 0), Ie);
|
|
1176
|
+
V.scrollTop = qe / Ie * (he - j);
|
|
1172
1177
|
}
|
|
1173
1178
|
function Ae() {
|
|
1174
|
-
ve = !1, window.removeEventListener("mousemove",
|
|
1179
|
+
ve = !1, window.removeEventListener("mousemove", Q), window.removeEventListener("mouseup", Ae), window.removeEventListener("touchmove", Q), window.removeEventListener("touchend", Ae);
|
|
1175
1180
|
}
|
|
1176
|
-
function
|
|
1177
|
-
const V =
|
|
1178
|
-
if (!V || !
|
|
1179
|
-
|
|
1180
|
-
const j =
|
|
1181
|
+
function Ke(Y) {
|
|
1182
|
+
const V = E.value, U = re.value;
|
|
1183
|
+
if (!V || !U) return;
|
|
1184
|
+
Y.preventDefault();
|
|
1185
|
+
const j = U.getBoundingClientRect(), ge = (We(Y) - j.top) / j.height;
|
|
1181
1186
|
V.scrollTop = ge * (V.scrollHeight - V.clientHeight);
|
|
1182
1187
|
}
|
|
1183
1188
|
return st(() => {
|
|
1184
|
-
|
|
1185
|
-
}), (
|
|
1186
|
-
var
|
|
1187
|
-
return m(),
|
|
1188
|
-
a("div",
|
|
1189
|
+
H(), E.value && ce && E.value.removeEventListener("scroll", ce), Ae();
|
|
1190
|
+
}), (Y, V) => {
|
|
1191
|
+
var U;
|
|
1192
|
+
return m(), x("div", wo, [
|
|
1193
|
+
a("div", ko, [
|
|
1189
1194
|
a("div", {
|
|
1190
1195
|
class: "chat-box scrollWrap",
|
|
1191
1196
|
ref_key: "chatBoxRef",
|
|
1192
|
-
ref:
|
|
1197
|
+
ref: E
|
|
1193
1198
|
}, [
|
|
1194
|
-
a("div",
|
|
1195
|
-
a("div",
|
|
1196
|
-
a("img", { src:
|
|
1197
|
-
a("h1", null,
|
|
1198
|
-
a("p", null,
|
|
1199
|
+
a("div", Co, [
|
|
1200
|
+
a("div", bo, [
|
|
1201
|
+
a("img", { src: $(Ot) }, null, 8, Ao),
|
|
1202
|
+
a("h1", null, G(D.text1), 1),
|
|
1203
|
+
a("p", null, G(D.text2), 1)
|
|
1199
1204
|
])
|
|
1200
1205
|
]),
|
|
1201
|
-
(
|
|
1202
|
-
a("div",
|
|
1203
|
-
a("div",
|
|
1206
|
+
(U = L.value) != null && U.length ? (m(), x("div", So, [
|
|
1207
|
+
a("div", xo, [
|
|
1208
|
+
a("div", To, [
|
|
1204
1209
|
V[2] || (V[2] = a("span", null, "你可以尝试这样问我:", -1)),
|
|
1205
1210
|
a("p", {
|
|
1206
1211
|
class: "refresh-btn",
|
|
1207
1212
|
onClick: n
|
|
1208
1213
|
}, [
|
|
1209
|
-
a("img", { src:
|
|
1214
|
+
a("img", { src: $(Rn) }, null, 8, Eo),
|
|
1210
1215
|
V[1] || (V[1] = a("span", null, "换一换", -1))
|
|
1211
1216
|
])
|
|
1212
1217
|
]),
|
|
1213
1218
|
a("ul", null, [
|
|
1214
|
-
(m(!0),
|
|
1219
|
+
(m(!0), x(Se, null, Oe(L.value, (j, he) => (m(), x("li", {
|
|
1215
1220
|
key: he,
|
|
1216
|
-
onClick: (ge) =>
|
|
1217
|
-
},
|
|
1221
|
+
onClick: (ge) => B(j)
|
|
1222
|
+
}, G(j), 9, Mo))), 128))
|
|
1218
1223
|
])
|
|
1219
1224
|
])
|
|
1220
|
-
])) :
|
|
1221
|
-
(m(!0),
|
|
1225
|
+
])) : X("", !0),
|
|
1226
|
+
(m(!0), x(Se, null, Oe(l.value, (j, he) => (m(), oe(Un, {
|
|
1222
1227
|
key: he,
|
|
1223
1228
|
msg: j,
|
|
1224
1229
|
index: he,
|
|
1225
|
-
STATUS:
|
|
1226
|
-
displayedContent:
|
|
1227
|
-
getSegmentDisplayContent:
|
|
1230
|
+
STATUS: h,
|
|
1231
|
+
displayedContent: $(A),
|
|
1232
|
+
getSegmentDisplayContent: $(N),
|
|
1228
1233
|
setMessageRef: Te,
|
|
1229
|
-
onRegenerate:
|
|
1234
|
+
onRegenerate: $(ye)
|
|
1230
1235
|
}, null, 8, ["msg", "index", "displayedContent", "getSegmentDisplayContent", "onRegenerate"]))), 128))
|
|
1231
1236
|
], 512),
|
|
1232
1237
|
a("div", {
|
|
1233
1238
|
ref_key: "scrollbarRef",
|
|
1234
1239
|
ref: re,
|
|
1235
1240
|
class: "chat-box__scrollbar",
|
|
1236
|
-
onMousedown: se(
|
|
1237
|
-
onTouchstart: se(
|
|
1241
|
+
onMousedown: se(Ke, ["prevent"]),
|
|
1242
|
+
onTouchstart: se(Ke, ["prevent"])
|
|
1238
1243
|
}, [
|
|
1239
1244
|
a("div", {
|
|
1240
1245
|
class: "chat-box__scrollbar-thumb",
|
|
@@ -1243,227 +1248,227 @@ const Co = { class: "container" }, bo = { class: "chat-wrap" }, Ao = { class: "m
|
|
|
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(ro, {
|
|
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: $(ye),
|
|
1260
|
+
onStop: $(we),
|
|
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
|
+
}), Ro = { class: "ai-history" }, Ho = { class: "content" }, _o = {
|
|
1263
1268
|
key: 0,
|
|
1264
1269
|
class: "ai-history-loading"
|
|
1265
|
-
},
|
|
1270
|
+
}, $o = { class: "ai-history-group-title" }, Po = ["onClick"], Lo = { class: "ai-history-item-title" }, Oo = ["onClick"], No = {
|
|
1266
1271
|
key: 2,
|
|
1267
1272
|
class: "ai-history-empty"
|
|
1268
|
-
},
|
|
1273
|
+
}, Wo = ["src"], Bo = { class: "ai-modal" }, Yo = { class: "ai-modal-footer" }, Vo = /* @__PURE__ */ xe({
|
|
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 = Qe().apis, u = p([]), k = p(!0), c = p(!1), l = p(""), r = O(() => mn(u.value));
|
|
1278
|
+
async function C() {
|
|
1274
1279
|
try {
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
} catch (
|
|
1278
|
-
Le((
|
|
1280
|
+
const E = await fn(h);
|
|
1281
|
+
E != null && E.conversationList && (u.value = E.conversationList.filter((D) => D !== null).map((D) => ({ ...D, selected: !1 })));
|
|
1282
|
+
} catch (E) {
|
|
1283
|
+
Le((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 pn(
|
|
1290
|
-
} catch (
|
|
1291
|
-
Le((
|
|
1294
|
+
await pn(h, l.value), await C();
|
|
1295
|
+
} catch (E) {
|
|
1296
|
+
Le((E == null ? void 0 : E.message) || "删除失败"), await C();
|
|
1292
1297
|
}
|
|
1293
1298
|
}
|
|
1294
1299
|
return pe(() => {
|
|
1295
|
-
|
|
1296
|
-
}), (
|
|
1297
|
-
a("div",
|
|
1298
|
-
k.value ? (m(),
|
|
1300
|
+
C();
|
|
1301
|
+
}), (E, D) => (m(), x("div", Ro, [
|
|
1302
|
+
a("div", Ho, [
|
|
1303
|
+
k.value ? (m(), x("div", _o, [...D[3] || (D[3] = [
|
|
1299
1304
|
a("div", { class: "ai-history-spinner" }, null, -1)
|
|
1300
|
-
])])) :
|
|
1301
|
-
key:
|
|
1305
|
+
])])) : r.value.length > 0 ? (m(!0), x(Se, { key: 1 }, Oe(r.value, (P) => (m(), x("div", {
|
|
1306
|
+
key: P.label,
|
|
1302
1307
|
class: "ai-history-group"
|
|
1303
1308
|
}, [
|
|
1304
|
-
a("div",
|
|
1305
|
-
(m(!0),
|
|
1306
|
-
key:
|
|
1309
|
+
a("div", $o, G(P.label), 1),
|
|
1310
|
+
(m(!0), x(Se, null, Oe(P.items, (R, L) => (m(), x("div", {
|
|
1311
|
+
key: R.appConversationID,
|
|
1307
1312
|
class: "ai-history-item",
|
|
1308
|
-
style: ot({ "--i":
|
|
1309
|
-
onClick: (n) =>
|
|
1313
|
+
style: ot({ "--i": L }),
|
|
1314
|
+
onClick: (n) => E.$emit("history-detail", R.appConversationID)
|
|
1310
1315
|
}, [
|
|
1311
|
-
a("div",
|
|
1316
|
+
a("div", Lo, G(R.conversationName), 1),
|
|
1312
1317
|
a("div", {
|
|
1313
1318
|
class: "ai-history-item-delete",
|
|
1314
|
-
onClick: se((n) =>
|
|
1315
|
-
}, "删除", 8,
|
|
1316
|
-
], 12,
|
|
1317
|
-
]))), 128)) : (m(),
|
|
1319
|
+
onClick: se((n) => w(R.appConversationID), ["stop"])
|
|
1320
|
+
}, "删除", 8, Oo)
|
|
1321
|
+
], 12, Po))), 128))
|
|
1322
|
+
]))), 128)) : (m(), x("div", No, "暂无历史记录"))
|
|
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: $(An) }, null, 8, Wo),
|
|
1329
|
+
D[4] || (D[4] = a("span", null, "新建AI对话", -1))
|
|
1325
1330
|
]),
|
|
1326
1331
|
(m(), oe(_t, { to: "#ai-assist-root" }, [
|
|
1327
|
-
|
|
1332
|
+
c.value ? (m(), x("div", {
|
|
1328
1333
|
key: 0,
|
|
1329
1334
|
class: "ai-modal-overlay",
|
|
1330
|
-
onClick:
|
|
1335
|
+
onClick: D[2] || (D[2] = se((P) => c.value = !1, ["self"]))
|
|
1331
1336
|
}, [
|
|
1332
|
-
a("div",
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
a("div",
|
|
1337
|
+
a("div", Bo, [
|
|
1338
|
+
D[5] || (D[5] = a("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
|
|
1339
|
+
D[6] || (D[6] = a("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
|
|
1340
|
+
a("div", Yo, [
|
|
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
|
+
}), Xo = { class: "container info" }, Fo = { class: "info-item" }, Go = { class: "basic-content" }, Qo = { class: "basic-content-text" }, Ko = { class: "basic-content" }, Io = { class: "basic-content-text" }, qo = { class: "info-item" }, Jo = { class: "permission-content" }, zo = { class: "info-item" }, Uo = { class: "basic-content" }, jo = { class: "basic-content-text" }, Zo = { class: "basic-content" }, es = { class: "basic-content-text" }, ts = /* @__PURE__ */ xe({
|
|
1351
1356
|
__name: "Info",
|
|
1352
1357
|
setup(e) {
|
|
1353
|
-
const y =
|
|
1358
|
+
const y = Qe(), d = p(null);
|
|
1354
1359
|
return pe(async () => {
|
|
1355
1360
|
try {
|
|
1356
|
-
|
|
1357
|
-
} catch (
|
|
1358
|
-
Le((
|
|
1361
|
+
d.value = await yn(y.apis);
|
|
1362
|
+
} catch (h) {
|
|
1363
|
+
Le((h == null ? void 0 : h.message) || "获取个人信息失败");
|
|
1359
1364
|
}
|
|
1360
|
-
}), (
|
|
1361
|
-
var k,
|
|
1362
|
-
return m(),
|
|
1363
|
-
a("div",
|
|
1364
|
-
|
|
1365
|
+
}), (h, u) => {
|
|
1366
|
+
var k, c, l, r, C;
|
|
1367
|
+
return m(), x("div", Xo, [
|
|
1368
|
+
a("div", Fo, [
|
|
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", Go, [
|
|
1374
|
+
u[0] || (u[0] = a("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
|
|
1375
|
+
a("div", Qo, G(((k = d.value) == null ? void 0 : k.name) || ""), 1)
|
|
1371
1376
|
]),
|
|
1372
|
-
a("div",
|
|
1373
|
-
|
|
1374
|
-
a("div",
|
|
1377
|
+
a("div", Ko, [
|
|
1378
|
+
u[1] || (u[1] = a("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
|
|
1379
|
+
a("div", Io, G(((c = d.value) == null ? void 0 : c.userName) || ""), 1)
|
|
1375
1380
|
])
|
|
1376
1381
|
]),
|
|
1377
|
-
a("div",
|
|
1378
|
-
|
|
1382
|
+
a("div", qo, [
|
|
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
|
-
(m(!0),
|
|
1384
|
-
key:
|
|
1387
|
+
a("div", Jo, [
|
|
1388
|
+
(m(!0), x(Se, null, Oe((l = d.value) == null ? void 0 : l.ptnameList, (w, S) => (m(), 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", zo, [
|
|
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
|
-
a("div",
|
|
1395
|
-
|
|
1396
|
-
a("div",
|
|
1399
|
+
a("div", Uo, [
|
|
1400
|
+
u[4] || (u[4] = a("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
|
|
1401
|
+
a("div", jo, G(((r = d.value) == null ? void 0 : r.dept) || ""), 1)
|
|
1397
1402
|
]),
|
|
1398
|
-
a("div",
|
|
1399
|
-
|
|
1400
|
-
a("div",
|
|
1403
|
+
a("div", Zo, [
|
|
1404
|
+
u[5] || (u[5] = a("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
|
|
1405
|
+
a("div", es, G(((C = d.value) == null ? void 0 : C.email) || ""), 1)
|
|
1401
1406
|
])
|
|
1402
1407
|
])
|
|
1403
1408
|
]);
|
|
1404
1409
|
};
|
|
1405
1410
|
}
|
|
1406
|
-
}),
|
|
1411
|
+
}), ns = { key: 1 }, os = ["src"], ss = { class: "header-title" }, as = ["title"], is = { class: "ai-history-drawer-panel" }, ls = { class: "ai-history-drawer-header" }, us = { class: "setTitle" }, cs = { class: "content" }, rs = { class: "main" }, vs = { class: "btn" }, ds = ["src"], hs = 78, Xe = 78, ee = 8, Fe = 26, Pe = 490, Mt = "aiPanelPosition", Dt = "aiPanelDocked", Rt = "aiDockWidth", gs = 60, ms = 150, Ht = 400, fs = 320, Nt = /* @__PURE__ */ xe({
|
|
1407
1412
|
__name: "AiAssist",
|
|
1408
1413
|
setup(e) {
|
|
1409
|
-
var
|
|
1410
|
-
const y =
|
|
1414
|
+
var bt;
|
|
1415
|
+
const y = hs / 2, d = Qe(), h = p(!1), u = p("idle"), k = p(!1), c = te({ 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 = te({
|
|
1411
1416
|
x: window.innerWidth - y,
|
|
1412
1417
|
y: window.innerHeight / 2 - Xe / 2
|
|
1413
|
-
}),
|
|
1418
|
+
}), B = p(!1), W = p(!1), T = p("right"), i = p("left"), f = p(null), g = te({ x: 0, y: 0 }), o = p(!1), s = p(!1), A = te({ x: 0, y: 0 }), b = p(!1), _ = te({ x: 0, y: 0 }), H = p(!1), N = p(!1), J = p(!1), ue = te({ x: 0, width: 0 }), Re = p(!1);
|
|
1414
1419
|
let ye = 0;
|
|
1415
|
-
const we = p("idle"),
|
|
1420
|
+
const we = p("idle"), Ne = p(!1), He = p("none"), I = te({ x: 0, y: 0, w: Pe, h: 0, radius: "14px" });
|
|
1416
1421
|
let ke = null, Ce = !1, Te = !1;
|
|
1417
1422
|
const ce = te({ x: 0, y: 0 }), re = p(!1), ve = p(null);
|
|
1418
1423
|
let be = null, Ee = null;
|
|
1419
1424
|
const de = O(() => {
|
|
1420
1425
|
const t = window.innerWidth / 2;
|
|
1421
1426
|
return n.x + y < t ? 5 : -5;
|
|
1422
|
-
}),
|
|
1427
|
+
}), We = O(() => C.value || H.value || we.value !== "idle" ? "" : `panel-${T.value}`), ie = O(() => {
|
|
1423
1428
|
var t;
|
|
1424
|
-
return !!((t =
|
|
1425
|
-
}),
|
|
1429
|
+
return !!((t = d.dock) != null && t.containerId) && !r.value;
|
|
1430
|
+
}), Q = p(((bt = d.dock) == null ? void 0 : bt.width) || Pe), Ae = O(() => d.panelDraggable !== !1), Ke = O(() => {
|
|
1426
1431
|
var t;
|
|
1427
1432
|
return !((t = ve.value) != null && t.isEmptyConversation);
|
|
1428
|
-
}),
|
|
1433
|
+
}), Y = O(() => ({
|
|
1429
1434
|
left: `${n.x}px`,
|
|
1430
1435
|
top: `${n.y}px`,
|
|
1431
|
-
transition:
|
|
1436
|
+
transition: B.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
|
|
1432
1437
|
"--direction": String(de.value)
|
|
1433
|
-
})), V = O(() =>
|
|
1434
|
-
left: `${
|
|
1435
|
-
top: `${
|
|
1436
|
-
width: `${
|
|
1437
|
-
height: `${
|
|
1438
|
-
borderRadius:
|
|
1438
|
+
})), V = O(() => d.characterImage || Sn), U = 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
|
|
1439
1444
|
}), j = O(() => {
|
|
1440
1445
|
const t = {};
|
|
1441
|
-
return
|
|
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;
|
|
1442
1447
|
}), he = O(() => we.value === "idle" ? {} : {
|
|
1443
|
-
left: `${
|
|
1444
|
-
top: `${
|
|
1445
|
-
width: `${
|
|
1446
|
-
height: `${
|
|
1447
|
-
borderRadius:
|
|
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
1454
|
function ge() {
|
|
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 Ie() {
|
|
1459
|
+
const t = window.innerWidth, v = Math.max(0, Math.min(n.y, window.innerHeight - Xe));
|
|
1460
|
+
return { x: n.x + y >= t / 2 ? t - y : -y, y: v };
|
|
1456
1461
|
}
|
|
1457
|
-
function
|
|
1458
|
-
|
|
1459
|
-
const t =
|
|
1462
|
+
function qe() {
|
|
1463
|
+
W.value = !0;
|
|
1464
|
+
const t = Ie();
|
|
1460
1465
|
n.x = t.x, n.y = t.y, setTimeout(() => {
|
|
1461
|
-
|
|
1466
|
+
W.value = !1, ge(), Wt();
|
|
1462
1467
|
}, 400);
|
|
1463
1468
|
}
|
|
1464
1469
|
function Wt() {
|
|
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
|
}
|
|
@@ -1474,111 +1479,111 @@ const Co = { class: "container" }, bo = { class: "chat-wrap" }, Ao = { class: "m
|
|
|
1474
1479
|
n.x = F.x, n.y = Math.min(Math.max(F.y, 0), window.innerHeight - Xe);
|
|
1475
1480
|
} else
|
|
1476
1481
|
n.x = window.innerWidth - y, n.y = window.innerHeight / 2 - Xe / 2;
|
|
1477
|
-
const
|
|
1478
|
-
|
|
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
|
|
1485
|
+
function Je(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 - ce.x, z = Math.max(0, Math.min(M - ce.y, window.innerHeight - Xe)), le = Math.abs(F - n.x), me = Math.abs(z - n.y);
|
|
1483
1488
|
le + me > 5 && (re.value = !0), n.x = F, n.y = z;
|
|
1484
1489
|
}
|
|
1485
1490
|
function ze() {
|
|
1486
|
-
|
|
1491
|
+
B.value && (B.value = !1, re.value && (qe(), re.value = !1));
|
|
1487
1492
|
}
|
|
1488
|
-
function
|
|
1489
|
-
|
|
1490
|
-
const
|
|
1491
|
-
ce.x =
|
|
1493
|
+
function dt(t) {
|
|
1494
|
+
W.value = !1, B.value = !0, re.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
|
+
ce.x = v - n.x, ce.y = M - n.y;
|
|
1492
1497
|
}
|
|
1493
|
-
function
|
|
1494
|
-
const t =
|
|
1498
|
+
function Yt() {
|
|
1499
|
+
const t = f.value, v = (t == null ? void 0 : t.offsetWidth) || Pe, M = (t == null ? void 0 : t.offsetHeight) || window.innerHeight - 78;
|
|
1495
1500
|
return {
|
|
1496
|
-
maxX: Math.max(
|
|
1497
|
-
maxY: Math.max(Fe, window.innerHeight -
|
|
1501
|
+
maxX: Math.max(ee, window.innerWidth - v - ee),
|
|
1502
|
+
maxY: Math.max(Fe, window.innerHeight - M - ee)
|
|
1498
1503
|
};
|
|
1499
1504
|
}
|
|
1500
|
-
function
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1505
|
+
function Ue(t, v) {
|
|
1506
|
+
const M = f.value, F = t ?? (M == null ? void 0 : M.offsetWidth) ?? Pe, z = v ?? (M == null ? void 0 : M.offsetHeight) ?? window.innerHeight - 78, le = Math.max(ee, window.innerWidth - F - ee), me = Math.max(Fe, window.innerHeight - z - ee);
|
|
1507
|
+
g.x = Math.min(Math.max(g.x, ee), le), g.y = Math.min(Math.max(g.y, Fe), me);
|
|
1503
1508
|
}
|
|
1504
|
-
function
|
|
1505
|
-
if (!Ae.value ||
|
|
1506
|
-
if (Te = !1,
|
|
1507
|
-
const F =
|
|
1509
|
+
function ht(t) {
|
|
1510
|
+
if (!Ae.value || C.value || r.value || H.value || u.value !== "idle") return;
|
|
1511
|
+
if (Te = !1, s.value = !0, b.value = !1, !o.value) {
|
|
1512
|
+
const F = f.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 fe,
|
|
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 je(t) {
|
|
1522
|
+
var fe, At;
|
|
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 nn = Math.abs(v - _.x), on = Math.abs(M - _.y);
|
|
1527
|
+
if (nn + on <= 5) return;
|
|
1528
|
+
b.value = !0;
|
|
1524
1529
|
}
|
|
1525
|
-
const { maxX: F, maxY: z } =
|
|
1526
|
-
Me !== Te && (Te = Me, (
|
|
1530
|
+
const { maxX: F, maxY: z } = Yt(), le = ie.value ? F + ms : F, me = Math.min(Math.max(v - A.x, ee), le), $e = Math.min(Math.max(M - A.y, Fe), z), Me = ie.value && me > F + gs;
|
|
1531
|
+
Me !== Te && (Te = Me, (At = (fe = d.dock) == null ? void 0 : fe.onDockChange) == null || At.call(fe, Me)), N.value = Me, g.x = me, g.y = $e;
|
|
1527
1532
|
}
|
|
1528
1533
|
function Ze() {
|
|
1529
|
-
var
|
|
1530
|
-
if (!
|
|
1531
|
-
|
|
1534
|
+
var v, M;
|
|
1535
|
+
if (!s.value) return;
|
|
1536
|
+
s.value = !1;
|
|
1532
1537
|
let t = !1;
|
|
1533
|
-
|
|
1538
|
+
b.value && (b.value = !1, Ce = !0, setTimeout(() => {
|
|
1534
1539
|
Ce = !1;
|
|
1535
|
-
}, 0),
|
|
1540
|
+
}, 0), N.value && ie.value ? (pt(), t = !0) : (Ue(), Vt())), Te && !t && (Te = !1, (M = (v = d.dock) == null ? void 0 : v.onDockChange) == null || M.call(v, !1)), N.value = !1;
|
|
1536
1541
|
}
|
|
1537
|
-
function
|
|
1542
|
+
function gt(t) {
|
|
1538
1543
|
Ce && (t.preventDefault(), t.stopPropagation(), Ce = !1);
|
|
1539
1544
|
}
|
|
1540
|
-
function
|
|
1545
|
+
function Vt() {
|
|
1541
1546
|
try {
|
|
1542
|
-
localStorage.setItem(
|
|
1547
|
+
localStorage.setItem(Mt, JSON.stringify({ x: g.x, y: g.y }));
|
|
1543
1548
|
} catch {
|
|
1544
1549
|
}
|
|
1545
1550
|
}
|
|
1546
|
-
function
|
|
1551
|
+
function Xt() {
|
|
1547
1552
|
try {
|
|
1548
|
-
const t = localStorage.getItem(
|
|
1553
|
+
const t = localStorage.getItem(Mt);
|
|
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 mt() {
|
|
1557
1562
|
try {
|
|
1558
|
-
localStorage.setItem(
|
|
1563
|
+
localStorage.setItem(Dt, H.value ? "1" : "0");
|
|
1559
1564
|
} catch {
|
|
1560
1565
|
}
|
|
1561
1566
|
}
|
|
1562
|
-
function
|
|
1567
|
+
function Ft() {
|
|
1563
1568
|
var t;
|
|
1564
1569
|
try {
|
|
1565
|
-
if (localStorage.getItem(
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1570
|
+
if (localStorage.getItem(Dt) === "1" && ie.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
1577
|
function et() {
|
|
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 Gt() {
|
|
1582
1587
|
return {
|
|
1583
1588
|
x: Math.max(0, Math.min(window.innerWidth - 53, n.x + de.value * 3)),
|
|
1584
1589
|
y: n.y,
|
|
@@ -1587,7 +1592,7 @@ const Co = { class: "container" }, bo = { class: "chat-wrap" }, Ao = { class: "m
|
|
|
1587
1592
|
radius: "50%"
|
|
1588
1593
|
};
|
|
1589
1594
|
}
|
|
1590
|
-
function
|
|
1595
|
+
function ft() {
|
|
1591
1596
|
const t = window.innerWidth * 0.8;
|
|
1592
1597
|
return {
|
|
1593
1598
|
x: (window.innerWidth - t) / 2,
|
|
@@ -1598,106 +1603,106 @@ const Co = { class: "container" }, bo = { class: "chat-wrap" }, Ao = { class: "m
|
|
|
1598
1603
|
};
|
|
1599
1604
|
}
|
|
1600
1605
|
function Qt() {
|
|
1601
|
-
|
|
1606
|
+
C.value ? (_e(ft(), kt()), C.value = !1) : (_e(Be(), ft()), C.value = !0);
|
|
1602
1607
|
}
|
|
1603
|
-
function
|
|
1604
|
-
ke && clearTimeout(ke), we.value = "switching",
|
|
1608
|
+
function _e(t, v, M, F = "none") {
|
|
1609
|
+
ke && clearTimeout(ke), we.value = "switching", Ne.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, ne(() => {
|
|
1605
1610
|
requestAnimationFrame(() => {
|
|
1606
|
-
|
|
1611
|
+
Ne.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
1613
|
}), ke = setTimeout(() => {
|
|
1609
|
-
we.value = "idle",
|
|
1614
|
+
we.value = "idle", He.value = "none", ke = null, M == null || M();
|
|
1610
1615
|
}, 400);
|
|
1611
1616
|
}
|
|
1612
|
-
function
|
|
1617
|
+
function pt() {
|
|
1613
1618
|
var z, le, me, $e, Me;
|
|
1614
|
-
if (!ie.value ||
|
|
1615
|
-
|
|
1616
|
-
const t = (z =
|
|
1619
|
+
if (!ie.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 fe =
|
|
1625
|
-
|
|
1626
|
+
const v = f.value;
|
|
1627
|
+
let M = Be();
|
|
1628
|
+
if (v) {
|
|
1629
|
+
const fe = v.getBoundingClientRect();
|
|
1630
|
+
M = { x: fe.left, y: fe.top, w: fe.width, h: fe.height, radius: getComputedStyle(v).borderRadius };
|
|
1626
1631
|
}
|
|
1627
1632
|
const F = et();
|
|
1628
|
-
|
|
1633
|
+
_e(M, F), H.value = !0, u.value = "idle", N.value = !1, mt(), (me = (le = d.dock) == null ? void 0 : le.onDockChange) == null || me.call(le, !0), (Me = ($e = d.dock) == null ? void 0 : $e.onDockWidthChange) == null || Me.call($e, Q.value);
|
|
1629
1634
|
}
|
|
1630
|
-
function
|
|
1631
|
-
return Math.max(
|
|
1635
|
+
function Kt() {
|
|
1636
|
+
return Math.max(Ht, window.innerWidth - fs);
|
|
1632
1637
|
}
|
|
1633
1638
|
function it(t) {
|
|
1634
|
-
return Math.min(Math.max(t,
|
|
1639
|
+
return Math.min(Math.max(t, Ht), Kt());
|
|
1635
1640
|
}
|
|
1636
|
-
function
|
|
1641
|
+
function It() {
|
|
1637
1642
|
try {
|
|
1638
|
-
localStorage.setItem(
|
|
1643
|
+
localStorage.setItem(Rt, String(Q.value));
|
|
1639
1644
|
} catch {
|
|
1640
1645
|
}
|
|
1641
1646
|
}
|
|
1642
1647
|
function qt() {
|
|
1643
1648
|
try {
|
|
1644
|
-
const t = localStorage.getItem(
|
|
1649
|
+
const t = localStorage.getItem(Rt);
|
|
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
|
-
ue.x =
|
|
1657
|
+
function yt(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
|
+
ue.x = v, ue.width = Q.value;
|
|
1657
1662
|
}
|
|
1658
1663
|
function tt(t) {
|
|
1659
|
-
if (!
|
|
1660
|
-
const
|
|
1661
|
-
Math.abs(
|
|
1664
|
+
if (!J.value) return;
|
|
1665
|
+
const v = "touches" in t ? t.touches[0].clientX : t.clientX, M = it(ue.width + (ue.x - v));
|
|
1666
|
+
Math.abs(M - ue.width) > 3 && (Re.value = !0), Q.value = M, ye || (ye = requestAnimationFrame(() => {
|
|
1662
1667
|
var F, z;
|
|
1663
|
-
ye = 0, (z = (F =
|
|
1668
|
+
ye = 0, (z = (F = d.dock) == null ? void 0 : F.onDockWidthChange) == null || z.call(F, Q.value);
|
|
1664
1669
|
}));
|
|
1665
1670
|
}
|
|
1666
1671
|
function nt() {
|
|
1667
|
-
var t,
|
|
1668
|
-
|
|
1672
|
+
var t, v;
|
|
1673
|
+
J.value && (J.value = !1, Re.value && (Re.value = !1, It(), (v = (t = d.dock) == null ? void 0 : t.onDockWidthChange) == null || v.call(t, Q.value)));
|
|
1669
1674
|
}
|
|
1670
|
-
function
|
|
1671
|
-
var t,
|
|
1672
|
-
|
|
1675
|
+
function wt() {
|
|
1676
|
+
var t, v;
|
|
1677
|
+
H.value && (o.value ? Ue(Pe, window.innerHeight - 78) : ge(), _e(et(), Be()), H.value = !1, mt(), (v = (t = d.dock) == null ? void 0 : t.onDockChange) == null || v.call(t, !1));
|
|
1673
1678
|
}
|
|
1674
1679
|
function Jt() {
|
|
1675
|
-
var t,
|
|
1676
|
-
if (!re.value && !
|
|
1677
|
-
if (
|
|
1678
|
-
|
|
1679
|
-
{ x: window.innerWidth, y: 0, w:
|
|
1680
|
+
var t, v;
|
|
1681
|
+
if (!re.value && !W.value) {
|
|
1682
|
+
if (H.value) {
|
|
1683
|
+
_e(
|
|
1684
|
+
{ x: window.innerWidth, y: 0, w: Q.value, h: window.innerHeight, radius: "0px" },
|
|
1680
1685
|
et(),
|
|
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
1691
|
ge();
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1692
|
+
const M = Be();
|
|
1693
|
+
c.x = Math.max(0, Math.min(window.innerWidth - 53, n.x + de.value * 3)), c.y = n.y - de.value * 2, c.w = 53, c.h = 53, c.radius = "50%", k.value = !0, u.value = "expanding", h.value = !0, ne(() => {
|
|
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
|
re.value = !1;
|
|
1697
1702
|
}
|
|
1698
|
-
function
|
|
1703
|
+
function Be() {
|
|
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,290 +1715,290 @@ 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 kt();
|
|
1726
1731
|
}
|
|
1727
|
-
function
|
|
1728
|
-
const t = Pe,
|
|
1729
|
-
let
|
|
1730
|
-
return
|
|
1731
|
-
}
|
|
1732
|
-
function
|
|
1733
|
-
var
|
|
1734
|
-
if (
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1732
|
+
function kt() {
|
|
1733
|
+
const t = Pe, 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, Fe), Math.max(ee, v - ee))) : F = T.value === "left" ? 24 : window.innerWidth - t - 24, { x: F, y: M, w: t, h: v, radius: "14px" };
|
|
1736
|
+
}
|
|
1737
|
+
function zt() {
|
|
1738
|
+
var v, M;
|
|
1739
|
+
if (H.value) {
|
|
1740
|
+
_e(et(), Gt(), () => {
|
|
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 = Be();
|
|
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", ne(() => {
|
|
1745
1750
|
requestAnimationFrame(() => {
|
|
1746
|
-
k.value = !1,
|
|
1751
|
+
k.value = !1, c.x = Math.max(0, Math.min(window.innerWidth - 53, n.x + de.value * 3)), c.y = n.y + Math.abs(de.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
|
-
Ye(),
|
|
1756
|
-
var
|
|
1757
|
-
(
|
|
1759
|
+
function Ut(t) {
|
|
1760
|
+
Ye(), w.value = "answer", ne(() => {
|
|
1761
|
+
var v;
|
|
1762
|
+
(v = ve.value) == null || v.goHistoryMessage(t);
|
|
1758
1763
|
});
|
|
1759
1764
|
}
|
|
1760
1765
|
function jt() {
|
|
1761
|
-
|
|
1766
|
+
P.value = "", w.value = "answer", ne(() => {
|
|
1762
1767
|
var t;
|
|
1763
1768
|
(t = ve.value) == null || t.createNewConversation();
|
|
1764
1769
|
});
|
|
1765
1770
|
}
|
|
1766
|
-
function
|
|
1767
|
-
Ye(),
|
|
1771
|
+
function Zt() {
|
|
1772
|
+
Ye(), P.value = "", ne(() => {
|
|
1768
1773
|
var t;
|
|
1769
1774
|
(t = ve.value) == null || t.createNewConversation();
|
|
1770
1775
|
});
|
|
1771
1776
|
}
|
|
1772
|
-
function
|
|
1773
|
-
|
|
1777
|
+
function en() {
|
|
1778
|
+
L.value = !1, R.value = !0;
|
|
1774
1779
|
}
|
|
1775
1780
|
function Ye() {
|
|
1776
|
-
|
|
1777
|
-
|
|
1781
|
+
L.value = !0, setTimeout(() => {
|
|
1782
|
+
R.value = !1, L.value = !1;
|
|
1778
1783
|
}, 300);
|
|
1779
1784
|
}
|
|
1780
|
-
function
|
|
1781
|
-
|
|
1785
|
+
function tn() {
|
|
1786
|
+
D.value = E.value, S.value = !1;
|
|
1782
1787
|
}
|
|
1783
|
-
ae(
|
|
1784
|
-
t ?
|
|
1785
|
-
}), ae(
|
|
1786
|
-
t &&
|
|
1788
|
+
ae(C, (t) => {
|
|
1789
|
+
t ? T.value = "center" : ge();
|
|
1790
|
+
}), ae(h, (t) => {
|
|
1791
|
+
t && o.value && ne(() => Ue());
|
|
1787
1792
|
}), pe(() => {
|
|
1788
|
-
Bt(),
|
|
1789
|
-
const t =
|
|
1790
|
-
|
|
1793
|
+
Bt(), Xt(), Ft(), qt();
|
|
1794
|
+
const t = d.theme || "light";
|
|
1795
|
+
vt(t), t === "auto" && (Ee = wn(() => vt("auto")));
|
|
1791
1796
|
});
|
|
1792
|
-
function
|
|
1797
|
+
function Ct() {
|
|
1793
1798
|
be && clearTimeout(be), be = setTimeout(() => {
|
|
1794
1799
|
const t = window.innerWidth < 768;
|
|
1795
|
-
|
|
1800
|
+
r.value = t, t && (C.value = !0, H.value && wt()), qe(), o.value && Ue(), H.value && (Q.value = it(Q.value));
|
|
1796
1801
|
}, 100);
|
|
1797
1802
|
}
|
|
1798
1803
|
return pe(() => {
|
|
1799
|
-
window.addEventListener("resize",
|
|
1804
|
+
window.addEventListener("resize", Ct);
|
|
1800
1805
|
}), st(() => {
|
|
1801
|
-
window.removeEventListener("resize",
|
|
1806
|
+
window.removeEventListener("resize", Ct), be && clearTimeout(be), Ee == null || Ee();
|
|
1802
1807
|
}), pe(() => {
|
|
1803
|
-
document.addEventListener("mousemove",
|
|
1808
|
+
document.addEventListener("mousemove", Je), document.addEventListener("touchmove", Je, { passive: !0 }), document.addEventListener("mouseup", ze), document.addEventListener("touchend", ze), document.addEventListener("mousemove", je), document.addEventListener("touchmove", je, { passive: !0 }), document.addEventListener("mouseup", Ze), document.addEventListener("touchend", Ze), document.addEventListener("click", gt, !0), document.addEventListener("mousemove", tt), document.addEventListener("touchmove", tt, { passive: !0 }), document.addEventListener("mouseup", nt), document.addEventListener("touchend", nt);
|
|
1804
1809
|
}), st(() => {
|
|
1805
|
-
document.removeEventListener("mousemove",
|
|
1806
|
-
}), (t,
|
|
1810
|
+
document.removeEventListener("mousemove", Je), document.removeEventListener("touchmove", Je), document.removeEventListener("mouseup", ze), document.removeEventListener("touchend", ze), document.removeEventListener("mousemove", je), document.removeEventListener("touchmove", je), document.removeEventListener("mouseup", Ze), document.removeEventListener("touchend", Ze), document.removeEventListener("click", gt, !0), document.removeEventListener("mousemove", tt), document.removeEventListener("touchmove", tt), document.removeEventListener("mouseup", nt), document.removeEventListener("touchend", nt), ke && clearTimeout(ke), ye && cancelAnimationFrame(ye);
|
|
1811
|
+
}), (t, v) => (m(), x("div", null, [
|
|
1807
1812
|
De(a("div", {
|
|
1808
1813
|
ref_key: "panelRef",
|
|
1809
|
-
ref:
|
|
1810
|
-
class:
|
|
1814
|
+
ref: f,
|
|
1815
|
+
class: q([
|
|
1811
1816
|
"ai-panel",
|
|
1812
|
-
|
|
1813
|
-
|
|
1817
|
+
C.value ? "maxWrap" : "minWrap",
|
|
1818
|
+
We.value,
|
|
1814
1819
|
{
|
|
1815
|
-
"panel-custom":
|
|
1816
|
-
dragging:
|
|
1817
|
-
"dock-preview":
|
|
1818
|
-
docked:
|
|
1819
|
-
"dock-resizing":
|
|
1820
|
+
"panel-custom": o.value && !C.value && !r.value && !H.value && we.value === "idle",
|
|
1821
|
+
dragging: s.value,
|
|
1822
|
+
"dock-preview": N.value,
|
|
1823
|
+
docked: H.value,
|
|
1824
|
+
"dock-resizing": J.value,
|
|
1820
1825
|
"dock-switching": we.value !== "idle",
|
|
1821
|
-
"dock-switch-instant":
|
|
1822
|
-
"dock-switch-fade-in":
|
|
1823
|
-
"dock-switch-fade-out":
|
|
1826
|
+
"dock-switch-instant": Ne.value,
|
|
1827
|
+
"dock-switch-fade-in": He.value === "in",
|
|
1828
|
+
"dock-switch-fade-out": He.value === "out",
|
|
1824
1829
|
"no-drag": !Ae.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: ot([j.value,
|
|
1834
|
+
style: ot([j.value, U.value, he.value])
|
|
1830
1835
|
}, [
|
|
1831
|
-
|
|
1836
|
+
H.value ? (m(), x("div", {
|
|
1832
1837
|
key: 0,
|
|
1833
1838
|
class: "ai-dock-resizer",
|
|
1834
|
-
onMousedown: se(
|
|
1835
|
-
onTouchstart: se(
|
|
1836
|
-
}, null, 32)) :
|
|
1839
|
+
onMousedown: se(yt, ["stop"]),
|
|
1840
|
+
onTouchstart: se(yt, ["stop"])
|
|
1841
|
+
}, null, 32)) : X("", !0),
|
|
1837
1842
|
a("div", {
|
|
1838
1843
|
class: "header",
|
|
1839
|
-
onMousedown:
|
|
1840
|
-
onTouchstart:
|
|
1844
|
+
onMousedown: ht,
|
|
1845
|
+
onTouchstart: ht
|
|
1841
1846
|
}, [
|
|
1842
|
-
|
|
1847
|
+
w.value === "info" ? (m(), 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)) : (m(),
|
|
1853
|
+
])], 2)) : (m(), x("p", ns, [
|
|
1849
1854
|
a("img", {
|
|
1850
|
-
src:
|
|
1855
|
+
src: $(Ot),
|
|
1851
1856
|
draggable: "false"
|
|
1852
|
-
}, null, 8,
|
|
1857
|
+
}, null, 8, os)
|
|
1853
1858
|
])),
|
|
1854
|
-
a("div",
|
|
1859
|
+
a("div", ss, [
|
|
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, as)
|
|
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
1868
|
onClick: jt
|
|
1864
1869
|
}, null, 512), [
|
|
1865
|
-
[Ve,
|
|
1870
|
+
[Ve, Ke.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 ? Ye() : en())
|
|
1871
1876
|
}, null, 8, ["class"]),
|
|
1872
|
-
!
|
|
1877
|
+
!r.value && !H.value ? (m(), oe($(Z), {
|
|
1873
1878
|
key: 0,
|
|
1874
1879
|
onClick: Qt,
|
|
1875
|
-
icon:
|
|
1876
|
-
}, null, 8, ["icon"])) :
|
|
1877
|
-
|
|
1880
|
+
icon: C.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
|
|
1881
|
+
}, null, 8, ["icon"])) : X("", !0),
|
|
1882
|
+
H.value ? (m(), oe($(Z), {
|
|
1878
1883
|
key: 1,
|
|
1879
1884
|
icon: "material-symbols:float-landscape-2-outline-rounded",
|
|
1880
|
-
onClick:
|
|
1881
|
-
})) :
|
|
1882
|
-
ie.value && !
|
|
1885
|
+
onClick: wt
|
|
1886
|
+
})) : X("", !0),
|
|
1887
|
+
ie.value && !H.value ? (m(), oe($(Z), {
|
|
1883
1888
|
key: 2,
|
|
1884
1889
|
icon: "boxicons:arrow-in-up-right-stroke-square",
|
|
1885
|
-
onClick:
|
|
1890
|
+
onClick: pt,
|
|
1886
1891
|
class: "__minimize"
|
|
1887
|
-
})) :
|
|
1888
|
-
|
|
1889
|
-
onClick:
|
|
1892
|
+
})) : X("", !0),
|
|
1893
|
+
K($(Z), {
|
|
1894
|
+
onClick: zt,
|
|
1890
1895
|
icon: "ic:round-close"
|
|
1891
1896
|
})
|
|
1892
1897
|
])
|
|
1893
1898
|
], 32),
|
|
1894
|
-
De(
|
|
1899
|
+
De(K(Do, {
|
|
1895
1900
|
ref_key: "answerRef",
|
|
1896
1901
|
ref: ve,
|
|
1897
|
-
defaultSayhello:
|
|
1898
|
-
defaultRecommend:
|
|
1899
|
-
onTitleGenerated:
|
|
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
|
-
[Ve,
|
|
1906
|
+
[Ve, w.value === "answer"]
|
|
1902
1907
|
]),
|
|
1903
|
-
|
|
1904
|
-
|
|
1908
|
+
w.value === "info" ? (m(), oe(ts, { key: 1 })) : X("", !0),
|
|
1909
|
+
R.value ? (m(), 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
1915
|
onClick: Ye
|
|
1911
1916
|
}),
|
|
1912
|
-
a("div",
|
|
1913
|
-
a("div",
|
|
1914
|
-
|
|
1915
|
-
|
|
1917
|
+
a("div", is, [
|
|
1918
|
+
a("div", ls, [
|
|
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
1923
|
onClick: Ye
|
|
1919
1924
|
})
|
|
1920
1925
|
]),
|
|
1921
|
-
|
|
1922
|
-
onHistoryDetail:
|
|
1923
|
-
onNewConversation:
|
|
1926
|
+
K(Vo, {
|
|
1927
|
+
onHistoryDetail: Ut,
|
|
1928
|
+
onNewConversation: Zt
|
|
1924
1929
|
})
|
|
1925
1930
|
])
|
|
1926
|
-
], 2)) :
|
|
1927
|
-
De(a("div",
|
|
1928
|
-
a("div",
|
|
1929
|
-
a("div",
|
|
1930
|
-
|
|
1931
|
+
], 2)) : X("", !0),
|
|
1932
|
+
De(a("div", us, [
|
|
1933
|
+
a("div", cs, [
|
|
1934
|
+
a("div", rs, [
|
|
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
|
+
[Pt, E.value]
|
|
1936
1941
|
]),
|
|
1937
|
-
a("p",
|
|
1942
|
+
a("p", vs, [
|
|
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: tn }, "确定")
|
|
1942
1947
|
])
|
|
1943
1948
|
])
|
|
1944
1949
|
])
|
|
1945
1950
|
], 512), [
|
|
1946
|
-
[Ve,
|
|
1951
|
+
[Ve, S.value]
|
|
1947
1952
|
])
|
|
1948
1953
|
], 6), [
|
|
1949
|
-
[Ve,
|
|
1954
|
+
[Ve, h.value || u.value !== "idle"]
|
|
1950
1955
|
]),
|
|
1951
|
-
|
|
1956
|
+
N.value && ie.value ? (m(), x("div", {
|
|
1952
1957
|
key: 0,
|
|
1953
1958
|
class: "ai-dock-preview",
|
|
1954
|
-
style: ot({ width:
|
|
1955
|
-
}, [...
|
|
1959
|
+
style: ot({ 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: ot(
|
|
1961
|
-
onMousedown:
|
|
1962
|
-
onTouchstart:
|
|
1964
|
+
class: q(["character", { dragging: B.value, recycling: W.value, "hover-preview": l.value }]),
|
|
1965
|
+
style: ot(Y.value),
|
|
1966
|
+
onMousedown: dt,
|
|
1967
|
+
onTouchstart: dt,
|
|
1963
1968
|
onClick: Jt
|
|
1964
1969
|
}, [
|
|
1965
|
-
a("img", { src: V.value }, null, 8,
|
|
1970
|
+
a("img", { src: V.value }, null, 8, ds)
|
|
1966
1971
|
], 38), [
|
|
1967
|
-
[Ve, !
|
|
1972
|
+
[Ve, !h.value]
|
|
1968
1973
|
])
|
|
1969
1974
|
]));
|
|
1970
1975
|
}
|
|
1971
|
-
}),
|
|
1976
|
+
}), ps = ["data-theme"], ys = {
|
|
1972
1977
|
key: 0,
|
|
1973
1978
|
class: "ai-voice-input-final"
|
|
1974
|
-
},
|
|
1979
|
+
}, ws = {
|
|
1975
1980
|
key: 1,
|
|
1976
1981
|
class: "ai-voice-input-interim"
|
|
1977
|
-
},
|
|
1982
|
+
}, ks = {
|
|
1978
1983
|
key: 2,
|
|
1979
1984
|
class: "ai-voice-input-cursor"
|
|
1980
|
-
},
|
|
1985
|
+
}, Cs = {
|
|
1981
1986
|
key: 3,
|
|
1982
1987
|
class: "ai-voice-input-placeholder"
|
|
1983
|
-
},
|
|
1988
|
+
}, bs = ["disabled"], As = {
|
|
1984
1989
|
key: 0,
|
|
1985
1990
|
class: "ai-voice-input-pulse"
|
|
1986
|
-
},
|
|
1991
|
+
}, Ss = {
|
|
1987
1992
|
key: 1,
|
|
1988
1993
|
class: "ai-voice-input-wave"
|
|
1989
|
-
},
|
|
1994
|
+
}, xs = {
|
|
1990
1995
|
key: 2,
|
|
1991
1996
|
class: "ai-voice-input-btn-icon",
|
|
1992
1997
|
viewBox: "0 0 24 24",
|
|
1993
1998
|
fill: "currentColor",
|
|
1994
1999
|
width: "16",
|
|
1995
2000
|
height: "16"
|
|
1996
|
-
},
|
|
2001
|
+
}, Ts = /* @__PURE__ */ xe({
|
|
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 = at.isSupported();
|
|
2024
|
+
let w = null;
|
|
2025
|
+
const S = O(() => kn(h.theme)), E = () => ({
|
|
2026
|
+
lang: h.lang,
|
|
2027
|
+
continuous: h.continuous,
|
|
2028
|
+
interimResults: h.interimResults
|
|
2029
|
+
}), D = () => {
|
|
2030
|
+
C && (w = new at(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, f) => {
|
|
2038
|
+
c.value += i, l.value = "", u("final", i, f);
|
|
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
|
-
pe(
|
|
2040
|
-
|
|
2044
|
+
pe(D), $t(() => {
|
|
2045
|
+
w == null || w.destroy(), w = null;
|
|
2041
2046
|
}), ae(
|
|
2042
|
-
() => [
|
|
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, f) => (m(), 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 ? (m(), x("span", ys, G(c.value), 1)) : X("", !0),
|
|
2089
|
+
l.value ? (m(), x("span", ws, G(l.value), 1)) : X("", !0),
|
|
2090
|
+
r.value === "recording" && !l.value ? (m(), x("span", ks)) : X("", !0),
|
|
2091
|
+
L.value ? (m(), x("span", Cs, 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" ? (m(), x("span", As)) : r.value === "connecting" || r.value === "stopping" ? (m(), x("span", Ss, [...f[0] || (f[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
|
-
])])) : (m(),
|
|
2105
|
+
])])) : (m(), x("svg", xs, [...f[1] || (f[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,
|
|
2105
|
-
], 10,
|
|
2106
|
-
|
|
2109
|
+
a("span", null, G(B.value), 1)
|
|
2110
|
+
], 10, bs),
|
|
2111
|
+
L.value ? X("", !0) : (m(), 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
|
-
], 10,
|
|
2118
|
+
], 10, ps));
|
|
2114
2119
|
}
|
|
2115
|
-
}),
|
|
2116
|
-
const
|
|
2117
|
-
for (const [
|
|
2118
|
-
h
|
|
2119
|
-
return
|
|
2120
|
-
},
|
|
2121
|
-
let
|
|
2122
|
-
const
|
|
2123
|
-
|
|
2124
|
-
},
|
|
2125
|
-
const y = e || document.body,
|
|
2126
|
-
|
|
2127
|
-
const
|
|
2128
|
-
|
|
2129
|
-
},
|
|
2130
|
-
|
|
2120
|
+
}), Es = (e, y) => {
|
|
2121
|
+
const d = e.__vccOpts || e;
|
|
2122
|
+
for (const [h, u] of y)
|
|
2123
|
+
d[h] = u;
|
|
2124
|
+
return d;
|
|
2125
|
+
}, Ms = /* @__PURE__ */ Es(Ts, [["__scopeId", "data-v-53d3cc6e"]]);
|
|
2126
|
+
let Ge = null;
|
|
2127
|
+
const Ps = (e) => {
|
|
2128
|
+
Lt(e);
|
|
2129
|
+
}, Ls = (e) => {
|
|
2130
|
+
const y = e || document.body, d = document.createElement("div");
|
|
2131
|
+
d.id = "ai-assist-root";
|
|
2132
|
+
const h = Qe();
|
|
2133
|
+
vt(h.theme), Cn(), y.appendChild(d), Ge = un(Nt), Ge.mount(d);
|
|
2134
|
+
}, Os = () => {
|
|
2135
|
+
Ge && (Ge.unmount(), Ge = null);
|
|
2131
2136
|
const e = document.getElementById("ai-assist-root");
|
|
2132
2137
|
e && e.remove();
|
|
2133
2138
|
}, Ns = {
|
|
2134
2139
|
install(e, y) {
|
|
2135
|
-
|
|
2140
|
+
Lt(y), e.component("AiAssist", Nt), e.component("VoiceInput", Ms);
|
|
2136
2141
|
}
|
|
2137
2142
|
};
|
|
2138
2143
|
export {
|
|
2139
|
-
|
|
2140
|
-
|
|
2144
|
+
Nt as AiAssist,
|
|
2145
|
+
Ms as VoiceInput,
|
|
2141
2146
|
Ns as default,
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2147
|
+
Ps as initAiAssist,
|
|
2148
|
+
Ls as mountAiAssist,
|
|
2149
|
+
Os as unmountAiAssist
|
|
2145
2150
|
};
|