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