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