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