@szjy/ai-coms 0.1.12 → 0.1.13
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/README.md +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +1598 -1120
- package/dist/index.umd.js +3 -2
- package/dist/packages/api/mock.d.ts +16 -0
- package/dist/packages/components/AiChat/src/custom-ui/actions/postMessage.d.ts +12 -0
- package/dist/packages/components/AiChat/src/custom-ui/components/button.d.ts +9 -0
- package/dist/packages/components/AiChat/src/custom-ui/components/list.d.ts +8 -0
- package/dist/packages/components/AiChat/src/custom-ui/events.d.ts +27 -0
- package/dist/packages/components/AiChat/src/custom-ui/index.d.ts +7 -0
- package/dist/packages/components/AiChat/src/custom-ui/parse.d.ts +11 -0
- package/dist/packages/components/AiChat/src/custom-ui/registry.d.ts +8 -0
- package/dist/packages/components/AiChat/src/custom-ui/render.d.ts +18 -0
- package/dist/packages/components/AiChat/src/custom-ui/types.d.ts +84 -0
- package/dist/packages/components/AiChat/src/index.vue.d.ts +56 -3
- package/dist/packages/components/AiChat/src/transform/index.d.ts +2 -1
- package/dist/packages/components/AiChatPlain/src/index.vue.d.ts +52 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { computed as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
return
|
|
1
|
+
var yt = Object.defineProperty;
|
|
2
|
+
var vt = (e, t, s) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var M = (e, t, s) => vt(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import { computed as N, openBlock as S, createElementBlock as x, normalizeStyle as ue, createElementVNode as d, normalizeClass as re, getCurrentInstance as Je, ref as T, watch as Pe, onUnmounted as wt, createBlock as ge, Transition as ye, withCtx as J, toDisplayString as W, withDirectives as Ke, vShow as Xe, createCommentVNode as $, createVNode as D, nextTick as Ye, onBeforeUnmount as bt, resolveComponent as Me, createTextVNode as pe, Fragment as me, renderList as Be, withKeys as kt, defineComponent as Ze, withModifiers as St } from "vue";
|
|
5
|
+
const Ct = "/images/ai-round.png", At = "/images/ai-sqrt.png", xt = "/images/bars-loading.svg";
|
|
6
|
+
function Qe(e) {
|
|
7
|
+
return e.startsWith("http://") || e.startsWith("https://") ? e : `${location.protocol}//${location.host}${e}`;
|
|
8
8
|
}
|
|
9
|
-
async function
|
|
10
|
-
const { projectId: n } = o,
|
|
9
|
+
async function Tt(e, t, s, r = "", o = {}) {
|
|
10
|
+
const { projectId: n } = o, a = Qe(r), i = new URL(`${a}/v1/chat/completions`), l = (o == null ? void 0 : o.authToken) || "app-oLZVFFdYyJX2QK3rdOLWsC2u";
|
|
11
11
|
o != null && o.authToken || console.error("缺少 authToken!现在默认使用内网的 authToken");
|
|
12
|
-
const
|
|
12
|
+
const c = new Request(i, {
|
|
13
13
|
method: "post",
|
|
14
14
|
headers: {
|
|
15
15
|
"Content-Type": "application/json",
|
|
@@ -19,8 +19,8 @@ async function gt(r, e, a, t = "", o = {}) {
|
|
|
19
19
|
model: "dify",
|
|
20
20
|
stream: !0,
|
|
21
21
|
inputs: {
|
|
22
|
-
token:
|
|
23
|
-
projectCode:
|
|
22
|
+
token: t,
|
|
23
|
+
projectCode: s,
|
|
24
24
|
...n ? { projectId: n } : {}
|
|
25
25
|
},
|
|
26
26
|
messages: [
|
|
@@ -30,17 +30,17 @@ async function gt(r, e, a, t = "", o = {}) {
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
role: "user",
|
|
33
|
-
content:
|
|
33
|
+
content: e
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
})
|
|
37
37
|
});
|
|
38
|
-
return fetch(
|
|
38
|
+
return fetch(c);
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
41
|
-
const n = new URL("http://localhost:11434/api/chat"),
|
|
42
|
-
Object.keys(
|
|
43
|
-
n.searchParams.append(l,
|
|
40
|
+
async function Rt(e, t, s, r = "", o = {}) {
|
|
41
|
+
const n = new URL("http://localhost:11434/api/chat"), a = {};
|
|
42
|
+
Object.keys(a).forEach((l) => {
|
|
43
|
+
n.searchParams.append(l, a[l]);
|
|
44
44
|
});
|
|
45
45
|
const i = new Request(n, {
|
|
46
46
|
mode: "cors",
|
|
@@ -58,23 +58,23 @@ async function vt(r, e, a, t = "", o = {}) {
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
role: "user",
|
|
61
|
-
content:
|
|
61
|
+
content: e
|
|
62
62
|
}
|
|
63
63
|
]
|
|
64
64
|
})
|
|
65
65
|
});
|
|
66
66
|
return fetch(i);
|
|
67
67
|
}
|
|
68
|
-
async function
|
|
69
|
-
const n = new URL(`${location.origin}/spark/v1/chat/completions`),
|
|
70
|
-
Object.keys(
|
|
71
|
-
n.searchParams.append(l,
|
|
68
|
+
async function Ut(e, t, s, r = "", o = {}) {
|
|
69
|
+
const n = new URL(`${location.origin}/spark/v1/chat/completions`), a = {};
|
|
70
|
+
Object.keys(a).forEach((l) => {
|
|
71
|
+
n.searchParams.append(l, a[l]);
|
|
72
72
|
});
|
|
73
73
|
const i = new Request(n, {
|
|
74
74
|
method: "post",
|
|
75
75
|
headers: {
|
|
76
76
|
"Content-Type": "application/json",
|
|
77
|
-
Authorization: `Bearer ${
|
|
77
|
+
Authorization: `Bearer ${t}`
|
|
78
78
|
},
|
|
79
79
|
body: JSON.stringify({
|
|
80
80
|
model: "generalv4.0Ultra",
|
|
@@ -82,23 +82,23 @@ async function yt(r, e, a, t = "", o = {}) {
|
|
|
82
82
|
messages: [
|
|
83
83
|
{
|
|
84
84
|
role: "user",
|
|
85
|
-
content:
|
|
85
|
+
content: e
|
|
86
86
|
}
|
|
87
87
|
]
|
|
88
88
|
})
|
|
89
89
|
});
|
|
90
90
|
return fetch(i);
|
|
91
91
|
}
|
|
92
|
-
async function
|
|
93
|
-
const n = new URL(`${location.origin}/siliconflow/v1/chat/completions`),
|
|
94
|
-
Object.keys(
|
|
95
|
-
n.searchParams.append(l,
|
|
92
|
+
async function _t(e, t, s, r = "", o = {}) {
|
|
93
|
+
const n = new URL(`${location.origin}/siliconflow/v1/chat/completions`), a = {};
|
|
94
|
+
Object.keys(a).forEach((l) => {
|
|
95
|
+
n.searchParams.append(l, a[l]);
|
|
96
96
|
});
|
|
97
97
|
const i = new Request(n, {
|
|
98
98
|
method: "post",
|
|
99
99
|
headers: {
|
|
100
100
|
"Content-Type": "application/json",
|
|
101
|
-
Authorization: `Bearer ${
|
|
101
|
+
Authorization: `Bearer ${t}`
|
|
102
102
|
},
|
|
103
103
|
body: JSON.stringify({
|
|
104
104
|
// 集成了大部分模型,可以免费使用
|
|
@@ -107,23 +107,23 @@ async function wt(r, e, a, t = "", o = {}) {
|
|
|
107
107
|
messages: [
|
|
108
108
|
{
|
|
109
109
|
role: "user",
|
|
110
|
-
content:
|
|
110
|
+
content: e
|
|
111
111
|
}
|
|
112
112
|
]
|
|
113
113
|
})
|
|
114
114
|
});
|
|
115
115
|
return fetch(i);
|
|
116
116
|
}
|
|
117
|
-
async function
|
|
118
|
-
const n = new URL(`${location.origin}/moonshot/v1/chat/completions`),
|
|
119
|
-
Object.keys(
|
|
120
|
-
n.searchParams.append(l,
|
|
117
|
+
async function Pt(e, t, s, r = "", o = {}) {
|
|
118
|
+
const n = new URL(`${location.origin}/moonshot/v1/chat/completions`), a = {};
|
|
119
|
+
Object.keys(a).forEach((l) => {
|
|
120
|
+
n.searchParams.append(l, a[l]);
|
|
121
121
|
});
|
|
122
122
|
const i = new Request(n, {
|
|
123
123
|
method: "post",
|
|
124
124
|
headers: {
|
|
125
125
|
"Content-Type": "application/json",
|
|
126
|
-
Authorization: `Bearer ${
|
|
126
|
+
Authorization: `Bearer ${t}`
|
|
127
127
|
},
|
|
128
128
|
body: JSON.stringify({
|
|
129
129
|
model: "moonshot-v1-8k",
|
|
@@ -135,23 +135,23 @@ async function kt(r, e, a, t = "", o = {}) {
|
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
role: "user",
|
|
138
|
-
content:
|
|
138
|
+
content: e
|
|
139
139
|
}
|
|
140
140
|
]
|
|
141
141
|
})
|
|
142
142
|
});
|
|
143
143
|
return fetch(i);
|
|
144
144
|
}
|
|
145
|
-
async function
|
|
146
|
-
const n = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`),
|
|
147
|
-
Object.keys(
|
|
148
|
-
n.searchParams.append(l,
|
|
145
|
+
async function Mt(e, t, s, r = "", o = {}) {
|
|
146
|
+
const n = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), a = {};
|
|
147
|
+
Object.keys(a).forEach((l) => {
|
|
148
|
+
n.searchParams.append(l, a[l]);
|
|
149
149
|
});
|
|
150
150
|
const i = new Request(n, {
|
|
151
151
|
method: "post",
|
|
152
152
|
headers: {
|
|
153
153
|
"Content-Type": "application/json",
|
|
154
|
-
Authorization: `Bearer ${
|
|
154
|
+
Authorization: `Bearer ${t}`
|
|
155
155
|
},
|
|
156
156
|
body: JSON.stringify({
|
|
157
157
|
model: "qwq-32b-preview",
|
|
@@ -163,197 +163,268 @@ async function bt(r, e, a, t = "", o = {}) {
|
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
165
|
role: "user",
|
|
166
|
-
content:
|
|
166
|
+
content: e
|
|
167
167
|
}
|
|
168
168
|
]
|
|
169
169
|
})
|
|
170
170
|
});
|
|
171
171
|
return fetch(i);
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
const n =
|
|
175
|
-
Object.keys(i).forEach((
|
|
176
|
-
|
|
173
|
+
async function It(e, t, s, r = "", o = {}) {
|
|
174
|
+
const n = Qe(r), a = new URL(`${n}/support/${s}/a`), i = {};
|
|
175
|
+
Object.keys(i).forEach((c) => {
|
|
176
|
+
a.searchParams.append(c, i[c]);
|
|
177
177
|
});
|
|
178
|
-
const l = new Request(
|
|
178
|
+
const l = new Request(a, {
|
|
179
179
|
method: "post",
|
|
180
180
|
headers: {
|
|
181
181
|
"Content-Type": "application/json",
|
|
182
|
-
Authorization: `Bearer ${
|
|
182
|
+
Authorization: `Bearer ${t}`
|
|
183
183
|
},
|
|
184
184
|
body: JSON.stringify({
|
|
185
|
-
content:
|
|
185
|
+
content: e
|
|
186
186
|
})
|
|
187
187
|
});
|
|
188
188
|
return fetch(l);
|
|
189
189
|
}
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
const Et = [
|
|
191
|
+
"根据您的问题,我为您整理了以下构件:",
|
|
192
|
+
"",
|
|
193
|
+
"```szjy-ui",
|
|
194
|
+
JSON.stringify(
|
|
195
|
+
{
|
|
196
|
+
title: "构件列表",
|
|
197
|
+
type: "list",
|
|
198
|
+
gap: 12,
|
|
199
|
+
items: [
|
|
200
|
+
{
|
|
201
|
+
type: "button",
|
|
202
|
+
props: { type: "primary", content: "查看构件1(CHKS-TJ01-02-01-01-01-01)" },
|
|
203
|
+
action: "postMessage",
|
|
204
|
+
actionParams: {
|
|
205
|
+
type: "BIM_SANDBOX",
|
|
206
|
+
action: "locateComponent",
|
|
207
|
+
payload: { wbsCode: "CHKS-TJ01-02-01-01-01-01" }
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
props: { type: "primary", content: "查看构件2(CHKS-TJ01-02-01-01-04-02)" },
|
|
213
|
+
action: "postMessage",
|
|
214
|
+
actionParams: {
|
|
215
|
+
type: "BIM_SANDBOX",
|
|
216
|
+
action: "locateComponent",
|
|
217
|
+
payload: { wbsCode: "CHKS-TJ01-02-01-01-04-02" }
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
type: "button",
|
|
222
|
+
props: { type: "default", content: "查看构件3(不存在的编码,演示失败反馈)" },
|
|
223
|
+
action: "postMessage",
|
|
224
|
+
actionParams: {
|
|
225
|
+
type: "BIM_SANDBOX",
|
|
226
|
+
action: "locateComponent",
|
|
227
|
+
payload: { wbsCode: "CHKS-NOT-EXIST" }
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
null,
|
|
233
|
+
2
|
|
234
|
+
),
|
|
235
|
+
"```",
|
|
236
|
+
"",
|
|
237
|
+
"点击上方按钮即可在 BIM 沙盘中定位对应构件。"
|
|
238
|
+
].join(`
|
|
239
|
+
`), jt = 8, zt = 80, Lt = (e) => new Promise((t) => setTimeout(t, e));
|
|
240
|
+
function $t(e, t) {
|
|
241
|
+
const s = Math.ceil(e.length / t), r = [];
|
|
242
|
+
for (let o = 0; o < e.length; o += s)
|
|
243
|
+
r.push(e.slice(o, o + s));
|
|
244
|
+
return r.length ? r : [""];
|
|
245
|
+
}
|
|
246
|
+
async function Ot(e, t, s, r = "", o = {}) {
|
|
247
|
+
const a = (o && typeof o.mockResponse == "string" ? o.mockResponse.trim() : "") || Et, i = new TextEncoder(), l = new ReadableStream({
|
|
248
|
+
async start(c) {
|
|
249
|
+
for (const b of $t(a, jt))
|
|
250
|
+
c.enqueue(i.encode(b)), await Lt(zt);
|
|
251
|
+
c.close();
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
return new Response(l, {
|
|
255
|
+
status: 200,
|
|
256
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const Nt = (e) => {
|
|
260
|
+
if (e.startsWith("data:")) {
|
|
261
|
+
const t = e.substring(5).trim();
|
|
262
|
+
if (t === "[DONE]")
|
|
194
263
|
return {
|
|
195
264
|
done: !0
|
|
196
265
|
};
|
|
197
266
|
try {
|
|
198
|
-
return JSON.parse(
|
|
199
|
-
} catch (
|
|
200
|
-
console.error("JSON parsing error:",
|
|
267
|
+
return JSON.parse(t);
|
|
268
|
+
} catch (s) {
|
|
269
|
+
console.error("JSON parsing error:", s);
|
|
201
270
|
}
|
|
202
271
|
}
|
|
203
272
|
return null;
|
|
204
|
-
},
|
|
205
|
-
const
|
|
206
|
-
for (let
|
|
207
|
-
if (
|
|
208
|
-
return
|
|
273
|
+
}, Ie = "<think>", Se = "</think>", Ee = (e, t) => {
|
|
274
|
+
const s = Math.max(0, e.length - (t.length - 1));
|
|
275
|
+
for (let r = s; r < e.length; r++)
|
|
276
|
+
if (t.startsWith(e.slice(r)))
|
|
277
|
+
return e.length - r;
|
|
209
278
|
return 0;
|
|
210
|
-
},
|
|
211
|
-
let
|
|
212
|
-
for (;
|
|
213
|
-
const n =
|
|
214
|
-
if (n >= 0 && (
|
|
215
|
-
|
|
216
|
-
else if (
|
|
217
|
-
|
|
279
|
+
}, Ft = (e) => {
|
|
280
|
+
let t = "", s = "", r = e || "", o = !1;
|
|
281
|
+
for (; r; ) {
|
|
282
|
+
const n = r.indexOf(Ie), a = r.indexOf(Se);
|
|
283
|
+
if (n >= 0 && (a < 0 || n < a))
|
|
284
|
+
s += r.slice(0, n), r = r.slice(n + Ie.length), o = !0;
|
|
285
|
+
else if (a >= 0 && (n < 0 || a < n))
|
|
286
|
+
t += r.slice(0, a), r = r.slice(a + Se.length), o = !1;
|
|
218
287
|
else if (o) {
|
|
219
|
-
const i =
|
|
220
|
-
|
|
288
|
+
const i = Ee(r, Se);
|
|
289
|
+
t += r.slice(0, r.length - i), r = "";
|
|
221
290
|
} else {
|
|
222
291
|
const i = Math.max(
|
|
223
|
-
|
|
224
|
-
|
|
292
|
+
Ee(r, Ie),
|
|
293
|
+
Ee(r, Se)
|
|
225
294
|
);
|
|
226
|
-
|
|
295
|
+
s += r.slice(0, r.length - i), r = "";
|
|
227
296
|
}
|
|
228
297
|
}
|
|
229
298
|
return {
|
|
230
|
-
thinking:
|
|
231
|
-
content:
|
|
299
|
+
thinking: t.trim(),
|
|
300
|
+
content: s.trim(),
|
|
232
301
|
isThinkingStreaming: o
|
|
233
302
|
};
|
|
234
|
-
},
|
|
303
|
+
}, Ve = [
|
|
235
304
|
{
|
|
236
305
|
label: "模拟数据模型",
|
|
237
306
|
modelName: "standard",
|
|
238
|
-
|
|
307
|
+
// 不请求真实后端:流式输出 extraConfig.mockResponse(或内置样例),
|
|
308
|
+
// 配合 sz-ai-chat 的 mockResponse prop 用于本地联调
|
|
309
|
+
api: Ot
|
|
239
310
|
},
|
|
240
311
|
{
|
|
241
312
|
label: "Spark 星火大模型",
|
|
242
313
|
modelName: "spark",
|
|
243
|
-
api:
|
|
314
|
+
api: Ut
|
|
244
315
|
},
|
|
245
316
|
{
|
|
246
317
|
label: "Ollama 3 大模型",
|
|
247
318
|
modelName: "ollama3",
|
|
248
|
-
api:
|
|
319
|
+
api: Rt
|
|
249
320
|
},
|
|
250
321
|
{
|
|
251
322
|
label: "SiliconFlow 硅基流动大模型",
|
|
252
323
|
modelName: "siliconflow",
|
|
253
|
-
api:
|
|
324
|
+
api: _t
|
|
254
325
|
},
|
|
255
326
|
{
|
|
256
327
|
label: "Kimi Moonshot 月之暗面大模型",
|
|
257
328
|
modelName: "moonshot",
|
|
258
|
-
api:
|
|
329
|
+
api: Pt
|
|
259
330
|
},
|
|
260
331
|
{
|
|
261
332
|
label: "通义千问大模型",
|
|
262
333
|
modelName: "dashscope",
|
|
263
|
-
api:
|
|
334
|
+
api: Mt
|
|
264
335
|
},
|
|
265
336
|
{
|
|
266
337
|
label: "数智建管大模型",
|
|
267
338
|
modelName: "szjy",
|
|
268
|
-
api:
|
|
339
|
+
api: It
|
|
269
340
|
},
|
|
270
341
|
{
|
|
271
342
|
label: "Dify (OpenAI 兼容)",
|
|
272
343
|
modelName: "dify-openai",
|
|
273
|
-
api:
|
|
344
|
+
api: Tt
|
|
274
345
|
}
|
|
275
|
-
],
|
|
276
|
-
standard(
|
|
277
|
-
let
|
|
278
|
-
return
|
|
346
|
+
], He = {
|
|
347
|
+
standard(e, t) {
|
|
348
|
+
let s = "";
|
|
349
|
+
return e instanceof Uint8Array ? s = t.decode(e, {
|
|
279
350
|
stream: !0
|
|
280
|
-
}) :
|
|
281
|
-
content:
|
|
351
|
+
}) : s = e, {
|
|
352
|
+
content: s
|
|
282
353
|
};
|
|
283
354
|
},
|
|
284
|
-
spark(
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
355
|
+
spark(e) {
|
|
356
|
+
const t = Nt(e);
|
|
357
|
+
if (t.done)
|
|
287
358
|
return {
|
|
288
359
|
done: !0
|
|
289
360
|
};
|
|
290
|
-
const
|
|
291
|
-
let o =
|
|
292
|
-
return
|
|
361
|
+
const s = t.choices[0].delta, r = s.reasoning_content || s.reasoning;
|
|
362
|
+
let o = s.content || "";
|
|
363
|
+
return r && (o = `<think>${r}</think>${o}`), {
|
|
293
364
|
content: o
|
|
294
365
|
};
|
|
295
366
|
},
|
|
296
|
-
siliconflow(
|
|
297
|
-
return this.spark(
|
|
367
|
+
siliconflow(e) {
|
|
368
|
+
return this.spark(e);
|
|
298
369
|
},
|
|
299
|
-
moonshot(
|
|
300
|
-
return this.spark(
|
|
370
|
+
moonshot(e) {
|
|
371
|
+
return this.spark(e);
|
|
301
372
|
},
|
|
302
|
-
dashscope(
|
|
303
|
-
return this.spark(
|
|
373
|
+
dashscope(e) {
|
|
374
|
+
return this.spark(e);
|
|
304
375
|
},
|
|
305
|
-
szjy(
|
|
306
|
-
return this.spark(
|
|
376
|
+
szjy(e) {
|
|
377
|
+
return this.spark(e);
|
|
307
378
|
},
|
|
308
|
-
"dify-openai"(
|
|
309
|
-
return this.spark(
|
|
379
|
+
"dify-openai"(e) {
|
|
380
|
+
return this.spark(e);
|
|
310
381
|
},
|
|
311
|
-
ollama3(
|
|
382
|
+
ollama3(e) {
|
|
312
383
|
return {
|
|
313
|
-
content: JSON.parse(
|
|
384
|
+
content: JSON.parse(e).message.content
|
|
314
385
|
};
|
|
315
386
|
}
|
|
316
|
-
},
|
|
317
|
-
const
|
|
318
|
-
return
|
|
319
|
-
o.trim() !== "" &&
|
|
320
|
-
}),
|
|
321
|
-
},
|
|
322
|
-
let
|
|
387
|
+
}, De = (e, t, s) => {
|
|
388
|
+
const r = e.split(s);
|
|
389
|
+
return r.slice(0, -1).forEach((o) => {
|
|
390
|
+
o.trim() !== "" && t.enqueue(o);
|
|
391
|
+
}), r[r.length - 1];
|
|
392
|
+
}, Bt = (e) => {
|
|
393
|
+
let t = "";
|
|
323
394
|
return new TransformStream({
|
|
324
|
-
transform(
|
|
325
|
-
if (
|
|
326
|
-
|
|
395
|
+
transform(s, r) {
|
|
396
|
+
if (t += s, t.trim().startsWith("data:"))
|
|
397
|
+
t = De(t, r, e);
|
|
327
398
|
else
|
|
328
399
|
try {
|
|
329
|
-
JSON.parse(
|
|
400
|
+
JSON.parse(t), t = De(t, r, e);
|
|
330
401
|
} catch {
|
|
331
|
-
|
|
402
|
+
r.enqueue(s), t = "";
|
|
332
403
|
}
|
|
333
404
|
},
|
|
334
|
-
flush(
|
|
335
|
-
|
|
405
|
+
flush(s) {
|
|
406
|
+
t.trim() !== "" && s.enqueue(t);
|
|
336
407
|
}
|
|
337
408
|
});
|
|
338
409
|
};
|
|
339
|
-
async function
|
|
340
|
-
const
|
|
341
|
-
return
|
|
342
|
-
|
|
410
|
+
async function Vt(e, t) {
|
|
411
|
+
const s = e.api;
|
|
412
|
+
return s ? new Promise((r) => {
|
|
413
|
+
s(t.text, t.token, t.identifier, t.baseUrl, t.extraConfig).then((o) => {
|
|
343
414
|
if (o.body) {
|
|
344
|
-
const n = o.body.pipeThrough(new TextDecoderStream()).pipeThrough(
|
|
415
|
+
const n = o.body.pipeThrough(new TextDecoderStream()).pipeThrough(Bt(`
|
|
345
416
|
`)).getReader();
|
|
346
|
-
console.log("reader from response:", n),
|
|
417
|
+
console.log("reader from response:", n), r({
|
|
347
418
|
error: 0,
|
|
348
419
|
reader: n
|
|
349
420
|
});
|
|
350
421
|
} else
|
|
351
|
-
|
|
422
|
+
r({
|
|
352
423
|
error: 1,
|
|
353
424
|
reader: null
|
|
354
425
|
});
|
|
355
426
|
}).catch(() => {
|
|
356
|
-
|
|
427
|
+
r({
|
|
357
428
|
error: 1,
|
|
358
429
|
reader: null
|
|
359
430
|
});
|
|
@@ -363,30 +434,315 @@ async function Tt(r, e) {
|
|
|
363
434
|
reader: null
|
|
364
435
|
};
|
|
365
436
|
}
|
|
366
|
-
|
|
367
|
-
function
|
|
368
|
-
|
|
437
|
+
const Le = /* @__PURE__ */ new Map(), $e = /* @__PURE__ */ new Map();
|
|
438
|
+
function et(e, t) {
|
|
439
|
+
Le.set(e, t);
|
|
440
|
+
}
|
|
441
|
+
function Ht(e, t) {
|
|
442
|
+
$e.set(e, t);
|
|
443
|
+
}
|
|
444
|
+
function Dt(e) {
|
|
445
|
+
return Le.get(e);
|
|
446
|
+
}
|
|
447
|
+
function qt(e) {
|
|
448
|
+
return Le.has(e);
|
|
449
|
+
}
|
|
450
|
+
function Wt(e) {
|
|
451
|
+
return $e.get(e);
|
|
452
|
+
}
|
|
453
|
+
function Gt(e) {
|
|
454
|
+
return $e.has(e);
|
|
455
|
+
}
|
|
456
|
+
const Jt = {
|
|
457
|
+
"&": "&",
|
|
458
|
+
"<": "<",
|
|
459
|
+
">": ">",
|
|
460
|
+
'"': """,
|
|
461
|
+
"'": "'"
|
|
462
|
+
};
|
|
463
|
+
function ve(e) {
|
|
464
|
+
return String(e ?? "").replace(/[&<>"']/g, (t) => Jt[t]);
|
|
465
|
+
}
|
|
466
|
+
function Kt(e) {
|
|
467
|
+
const s = tt(e, { block: e });
|
|
468
|
+
return s ? `<div class="szjy-ui" data-szjy-ui="1">${s}</div>` : "";
|
|
469
|
+
}
|
|
470
|
+
function tt(e, t) {
|
|
471
|
+
if (!e || typeof e != "object" || typeof e.type != "string") return "";
|
|
472
|
+
const s = Dt(e.type);
|
|
473
|
+
return s ? s(e, t) : "";
|
|
474
|
+
}
|
|
475
|
+
function Xt(e) {
|
|
476
|
+
const t = e.action;
|
|
477
|
+
if (!t || typeof t != "string") return "";
|
|
478
|
+
if (!Gt(t))
|
|
479
|
+
return ` disabled title="未知动作:${ve(t)}"`;
|
|
480
|
+
const s = e.actionParams === void 0 ? "" : encodeURIComponent(JSON.stringify(e.actionParams ?? null));
|
|
481
|
+
return ` data-szjy-ui-action="${ve(t)}" data-szjy-ui-params="${s}"`;
|
|
482
|
+
}
|
|
483
|
+
function Yt(e) {
|
|
484
|
+
return typeof e == "number" && Number.isFinite(e) && e >= 0 ? `${e}px` : typeof e == "string" && /^\d+(\.\d+)?(px|rem|em|%)?$/.test(e.trim()) ? /^\d+(\.\d+)?$/.test(e.trim()) ? `${e.trim()}px` : e.trim() : "12px";
|
|
485
|
+
}
|
|
486
|
+
function Zt(e, t) {
|
|
487
|
+
const s = typeof e.title == "string" && e.title ? `<div class="szjy-ui-list__title">${ve(e.title)}</div>` : "", o = (Array.isArray(e.items) ? e.items : []).map((a) => tt(a, t)).filter(Boolean).map((a) => `<div class="szjy-ui-list__item">${a}</div>`).join(""), n = ve(Yt(e.gap));
|
|
488
|
+
return '<div class="szjy-ui-list">' + s + `<div class="szjy-ui-list__items" style="gap:${n}">${o}</div></div>`;
|
|
489
|
+
}
|
|
490
|
+
et("list", Zt);
|
|
491
|
+
const Qt = ["default", "primary", "success", "warning", "danger", "info", "text"], en = ["small", "default", "large"];
|
|
492
|
+
function tn(e, t) {
|
|
493
|
+
const s = e.props, r = s && typeof s == "object" ? s : {}, o = Qt.includes(r.type) ? r.type : "default", n = en.includes(r.size) ? r.size : "default", a = ve(r.content ?? r.text ?? "按钮"), i = Xt(e);
|
|
494
|
+
return `<button type="button" class="${["szjy-ui-btn", `szjy-ui-btn--${o}`, `szjy-ui-btn--${n}`].join(" ")}"${i}><span class="szjy-ui-btn__text">${a}</span><span class="szjy-ui-btn__status" aria-live="polite"></span></button>`;
|
|
495
|
+
}
|
|
496
|
+
et("button", tn);
|
|
497
|
+
const nn = 15e3, nt = /未就绪|未加载/, rn = "BIM_SANDBOX", sn = {
|
|
498
|
+
locateComponent: (e) => [e == null ? void 0 : e.wbsCode],
|
|
499
|
+
openPDFSearch: () => []
|
|
500
|
+
};
|
|
501
|
+
let on = 0;
|
|
502
|
+
function an(e, t) {
|
|
503
|
+
let s;
|
|
504
|
+
if (!e || e === "self")
|
|
505
|
+
s = [window];
|
|
506
|
+
else if (e === "parent")
|
|
507
|
+
s = [window.parent];
|
|
508
|
+
else if (e === "top")
|
|
509
|
+
s = [window.top];
|
|
510
|
+
else if (typeof e == "function")
|
|
511
|
+
try {
|
|
512
|
+
s = e(t);
|
|
513
|
+
} catch (n) {
|
|
514
|
+
console.error("[szjy-ui] 解析 postMessage 目标窗口失败:", n), s = [];
|
|
515
|
+
}
|
|
516
|
+
else Array.isArray(e) ? s = e : s = [e];
|
|
517
|
+
const r = [], o = (n) => {
|
|
518
|
+
if (n) {
|
|
519
|
+
if (Array.isArray(n)) {
|
|
520
|
+
n.forEach(o);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
typeof n.postMessage == "function" && !r.includes(n) && r.push(n);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
return o(s), r;
|
|
527
|
+
}
|
|
528
|
+
function de(e) {
|
|
529
|
+
if (e === window) return `self (${location.origin})`;
|
|
530
|
+
if (e === window.parent) return "parent";
|
|
531
|
+
if (e === window.top) return "top";
|
|
532
|
+
try {
|
|
533
|
+
return `window (${e.location.href.slice(0, 60)})`;
|
|
534
|
+
} catch {
|
|
535
|
+
return "window (cross-origin)";
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function ln(e) {
|
|
539
|
+
try {
|
|
540
|
+
const t = e.$bimSandbox;
|
|
541
|
+
return t && typeof t == "object" ? t : null;
|
|
542
|
+
} catch {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function cn(e, t, s) {
|
|
547
|
+
if (t.type !== rn) return { handled: !1 };
|
|
548
|
+
const r = sn[t.action];
|
|
549
|
+
if (!r) return { handled: !1 };
|
|
550
|
+
const o = ln(e);
|
|
551
|
+
if (!o || typeof o[t.action] != "function") return { handled: !1 };
|
|
552
|
+
const n = r(t.payload);
|
|
553
|
+
let a;
|
|
554
|
+
try {
|
|
555
|
+
a = o[t.action](...n);
|
|
556
|
+
} catch (i) {
|
|
557
|
+
return console.error("[szjy-ui] $bimSandbox 方法调用异常,回退 postMessage:", i), { handled: !1 };
|
|
558
|
+
}
|
|
559
|
+
return s && console.log("[szjy-ui] $bimSandbox 直调", {
|
|
560
|
+
method: t.action,
|
|
561
|
+
args: n,
|
|
562
|
+
result: a,
|
|
563
|
+
target: de(e)
|
|
564
|
+
}), { handled: !0, result: a };
|
|
565
|
+
}
|
|
566
|
+
function rt(e, t, s, r, o, n, a) {
|
|
567
|
+
return (() => {
|
|
568
|
+
const { handled: l, result: c } = cn(e, t, a);
|
|
569
|
+
return l ? (c && c.success ? n && K(s, "success", c.message || "执行成功") : c && nt.test(String(c.message || "")) && r > 0 ? (a && console.warn(
|
|
570
|
+
`[szjy-ui] $bimSandbox 直调失败(${c.message}),${o}ms 后自动重试,剩余 ${r - 1} 次`
|
|
571
|
+
), n && K(s, "retrying", `${c.message},${Math.round(o / 1e3)}s 后自动重试`), setTimeout(() => {
|
|
572
|
+
rt(e, t, s, r - 1, o, n, a);
|
|
573
|
+
}, o)) : n && K(s, "error", c && c.message || "执行失败"), !0) : !1;
|
|
574
|
+
})();
|
|
575
|
+
}
|
|
576
|
+
function un(e) {
|
|
577
|
+
const t = dn(e.config), s = !e.config || e.config.debug !== !1, r = t.feedback !== !1, o = t.retry === !1 ? { retries: 0, delay: 2e3 } : { retries: 2, delay: 2e3, ...t.retry || {} };
|
|
578
|
+
if (!e.params || typeof e.params != "object" || Array.isArray(e.params)) {
|
|
579
|
+
console.warn("[szjy-ui] postMessage 动作的 actionParams 必须是对象:", e.params), K(e.triggerEl, "error", "参数无效");
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const n = { ...e.params }, a = an(t.target, n);
|
|
583
|
+
if (!a.length) {
|
|
584
|
+
console.warn("[szjy-ui] postMessage 无可用目标窗口,target 配置:", t.target), K(e.triggerEl, "error", "无目标窗口");
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
const i = t.targetOrigin || "*", l = t.transport || "auto";
|
|
588
|
+
if (l !== "postMessage") {
|
|
589
|
+
let c = !1;
|
|
590
|
+
for (const b of a)
|
|
591
|
+
if (rt(b, n, e.triggerEl, o.retries, o.delay, r, s)) {
|
|
592
|
+
c = !0;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
if (c)
|
|
596
|
+
return;
|
|
597
|
+
if (l === "global") {
|
|
598
|
+
console.warn("[szjy-ui] transport=global 但 $bimSandbox 全局方法不可用:", {
|
|
599
|
+
targets: a.map(de),
|
|
600
|
+
message: n
|
|
601
|
+
}), K(e.triggerEl, "error", "全局方法不可用");
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
s && console.log("[szjy-ui] $bimSandbox 不可用,回退 postMessage 通道");
|
|
605
|
+
}
|
|
606
|
+
n.requestId === void 0 && (n.requestId = `szjy-ui-${Date.now()}-${++on}`), st(a, n, i), s && console.log("[szjy-ui] postMessage 已发送", {
|
|
607
|
+
message: n,
|
|
608
|
+
targets: a.map(de),
|
|
609
|
+
targetOrigin: i,
|
|
610
|
+
feedback: r
|
|
611
|
+
}), r && (K(e.triggerEl, "loading", "已发送"), fn(n, a, e.triggerEl, i, o, s));
|
|
612
|
+
}
|
|
613
|
+
function dn(e) {
|
|
614
|
+
return e && e.postMessage || {};
|
|
615
|
+
}
|
|
616
|
+
function st(e, t, s) {
|
|
617
|
+
e.forEach((r) => {
|
|
618
|
+
try {
|
|
619
|
+
r.postMessage(t, s);
|
|
620
|
+
} catch (o) {
|
|
621
|
+
console.error("[szjy-ui] postMessage 发送失败:", o);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
function fn(e, t, s, r, o, n) {
|
|
626
|
+
let a = o.retries;
|
|
627
|
+
const i = o.delay;
|
|
628
|
+
let l = null;
|
|
629
|
+
const c = () => {
|
|
630
|
+
window.removeEventListener("message", P), l && (clearTimeout(l), l = null);
|
|
631
|
+
}, b = () => {
|
|
632
|
+
l && clearTimeout(l), l = setTimeout(() => {
|
|
633
|
+
c(), n && console.warn("[szjy-ui] postMessage 超时未收到回执", { message: e, targets: t.map(de), targetOrigin: r }), K(s, "none", "未收到回执");
|
|
634
|
+
}, nn);
|
|
635
|
+
}, P = (A) => {
|
|
636
|
+
const p = A.data;
|
|
637
|
+
!p || typeof p != "object" || e.type !== void 0 && p.type !== e.type || p.success !== void 0 && (e.requestId !== void 0 && p.requestId !== void 0 && String(p.requestId) !== String(e.requestId) || A.source && !t.includes(A.source) || (n && console.log("[szjy-ui] postMessage 收到回执", {
|
|
638
|
+
requestId: p.requestId,
|
|
639
|
+
success: p.success,
|
|
640
|
+
message: p.message,
|
|
641
|
+
data: p.data,
|
|
642
|
+
from: de(A.source)
|
|
643
|
+
}), p.success ? (c(), K(s, "success", p.message || "执行成功")) : nt.test(String(p.message || "")) && a > 0 ? (a -= 1, n && console.warn(`[szjy-ui] postMessage 回执失败(${p.message}),${i}ms 后自动重试,剩余 ${a} 次`), K(s, "retrying", `${p.message},${Math.round(i / 1e3)}s 后自动重试`), l && clearTimeout(l), setTimeout(() => {
|
|
644
|
+
st(t, e, r), n && console.log("[szjy-ui] postMessage 重试已发送", { message: e, targets: t.map(de), targetOrigin: r }), K(s, "loading", "已发送"), b();
|
|
645
|
+
}, i)) : (c(), K(s, "error", p.message || "执行失败"))));
|
|
646
|
+
};
|
|
647
|
+
window.addEventListener("message", P), b();
|
|
648
|
+
}
|
|
649
|
+
function K(e, t, s) {
|
|
650
|
+
if (!e || !e.isConnected) return;
|
|
651
|
+
const r = e.querySelector(":scope > .szjy-ui-btn__status");
|
|
652
|
+
e.classList.remove("is-loading", "is-success", "is-error", "is-retrying"), t && t !== "none" && e.classList.add(`is-${t}`), r && (r.textContent = s || "");
|
|
653
|
+
}
|
|
654
|
+
Ht("postMessage", un);
|
|
655
|
+
const hn = "szjy-ui";
|
|
656
|
+
function pn(e) {
|
|
657
|
+
if (!e || typeof e != "string") return null;
|
|
658
|
+
const t = e.trim();
|
|
659
|
+
if (!t.startsWith("{")) return null;
|
|
660
|
+
let s;
|
|
661
|
+
try {
|
|
662
|
+
s = JSON.parse(t);
|
|
663
|
+
} catch {
|
|
664
|
+
return null;
|
|
665
|
+
}
|
|
666
|
+
return mn(s);
|
|
667
|
+
}
|
|
668
|
+
function mn(e) {
|
|
669
|
+
return !e || typeof e != "object" || Array.isArray(e) || typeof e.type != "string" || !qt(e.type) || e.items !== void 0 && !Array.isArray(e.items) ? null : e;
|
|
670
|
+
}
|
|
671
|
+
function gn(e, t = {}) {
|
|
672
|
+
if (!e) return () => {
|
|
673
|
+
};
|
|
674
|
+
const s = (r) => {
|
|
675
|
+
var A;
|
|
676
|
+
const o = r.target, n = o && typeof o.closest == "function" ? o.closest("[data-szjy-ui-action]") : null;
|
|
677
|
+
if (!n || !e.contains(n)) return;
|
|
678
|
+
const a = n.getAttribute("data-szjy-ui-action") || "", i = Wt(a);
|
|
679
|
+
if (!i) {
|
|
680
|
+
console.warn(`[szjy-ui] 未注册的动作: ${a}`);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
const l = n.getAttribute("data-szjy-ui-params");
|
|
684
|
+
let c = null;
|
|
685
|
+
if (l)
|
|
686
|
+
try {
|
|
687
|
+
c = JSON.parse(decodeURIComponent(l));
|
|
688
|
+
} catch (p) {
|
|
689
|
+
console.error("[szjy-ui] actionParams 解析失败:", p);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const b = t.getConfig ? t.getConfig() : null;
|
|
693
|
+
if (!b || b.debug !== !1) {
|
|
694
|
+
const p = (A = n.querySelector(":scope > .szjy-ui-btn__text")) == null ? void 0 : A.textContent;
|
|
695
|
+
console.log("[szjy-ui] 动作触发", {
|
|
696
|
+
action: a,
|
|
697
|
+
params: c,
|
|
698
|
+
text: (p || n.textContent || "").trim().slice(0, 40),
|
|
699
|
+
trigger: n
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
const P = t.getInterceptor ? t.getInterceptor() : null;
|
|
703
|
+
if (!(P && P(a, c, n) === !1)) {
|
|
704
|
+
if (t.onAction)
|
|
705
|
+
try {
|
|
706
|
+
t.onAction({ action: a, params: c, triggerEl: n });
|
|
707
|
+
} catch (p) {
|
|
708
|
+
console.error("[szjy-ui] onAction 回调执行失败:", p);
|
|
709
|
+
}
|
|
710
|
+
i({ params: c, config: b, triggerEl: n });
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
return e.addEventListener("click", s), () => {
|
|
714
|
+
e.removeEventListener("click", s);
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
let ee = null;
|
|
718
|
+
function yn() {
|
|
719
|
+
return ee || (window.markdownit ? (ee = new window.markdownit({
|
|
369
720
|
html: !0,
|
|
370
721
|
linkify: !0,
|
|
371
722
|
typographer: !0
|
|
372
|
-
}),
|
|
373
|
-
const
|
|
723
|
+
}), ee.renderer.rules.fence = (e, t) => {
|
|
724
|
+
const s = e[t], r = (s.info || "").trim().split(/\s+/)[0];
|
|
725
|
+
if (r === hn) {
|
|
726
|
+
const n = pn(s.content), a = n ? Kt(n) : "";
|
|
727
|
+
if (a)
|
|
728
|
+
return a;
|
|
729
|
+
}
|
|
374
730
|
let o = "";
|
|
375
|
-
if (
|
|
731
|
+
if (r && window.hljs && window.hljs.getLanguage(r))
|
|
376
732
|
try {
|
|
377
|
-
o = window.hljs.highlight(
|
|
733
|
+
o = window.hljs.highlight(s.content, { language: r }).value;
|
|
378
734
|
} catch {
|
|
379
735
|
o = "";
|
|
380
736
|
}
|
|
381
|
-
return o || (o =
|
|
382
|
-
}) : console.log("markdownit is not loaded"),
|
|
737
|
+
return o || (o = ee.utils.escapeHtml(s.content)), `<pre class="md-code-block"><code class="hljs${r ? " language-" + r : ""}">${o}</code></pre>`;
|
|
738
|
+
}) : console.log("markdownit is not loaded"), ee);
|
|
383
739
|
}
|
|
384
|
-
const
|
|
385
|
-
const
|
|
386
|
-
for (const [
|
|
387
|
-
|
|
388
|
-
return
|
|
389
|
-
},
|
|
740
|
+
const vn = (e, t) => {
|
|
741
|
+
const s = e.__vccOpts || e;
|
|
742
|
+
for (const [r, o] of t)
|
|
743
|
+
s[r] = o;
|
|
744
|
+
return s;
|
|
745
|
+
}, wn = ["src", "alt"], bn = {
|
|
390
746
|
__name: "SvgIcon",
|
|
391
747
|
props: {
|
|
392
748
|
// 图标名称或完整URL
|
|
@@ -415,14 +771,14 @@ const _t = (r, e) => {
|
|
|
415
771
|
default: "/icons/"
|
|
416
772
|
}
|
|
417
773
|
},
|
|
418
|
-
setup(
|
|
419
|
-
const
|
|
420
|
-
if (
|
|
421
|
-
return
|
|
422
|
-
const n =
|
|
423
|
-
return `${
|
|
424
|
-
}),
|
|
425
|
-
const n = typeof
|
|
774
|
+
setup(e) {
|
|
775
|
+
const t = e, s = N(() => {
|
|
776
|
+
if (t.name.startsWith("http://") || t.name.startsWith("https://") || t.name.startsWith("/"))
|
|
777
|
+
return t.name;
|
|
778
|
+
const n = t.name.endsWith(".svg") ? t.name : `${t.name}.svg`;
|
|
779
|
+
return `${t.basePath}${n}`;
|
|
780
|
+
}), r = N(() => {
|
|
781
|
+
const n = typeof t.size == "number" ? `${t.size}px` : t.size;
|
|
426
782
|
return {
|
|
427
783
|
width: n,
|
|
428
784
|
height: n,
|
|
@@ -430,33 +786,33 @@ const _t = (r, e) => {
|
|
|
430
786
|
justifyContent: "center",
|
|
431
787
|
alignItems: "center"
|
|
432
788
|
};
|
|
433
|
-
}), o =
|
|
789
|
+
}), o = N(() => {
|
|
434
790
|
const n = {
|
|
435
791
|
width: "100%",
|
|
436
792
|
height: "100%"
|
|
437
793
|
};
|
|
438
|
-
return
|
|
794
|
+
return t.color && (n.filter = `drop-shadow(0 0 0 ${t.color})`), n;
|
|
439
795
|
});
|
|
440
|
-
return (n,
|
|
796
|
+
return (n, a) => (S(), x("div", {
|
|
441
797
|
class: "svg-icon-wrapper",
|
|
442
|
-
style: ue(
|
|
798
|
+
style: ue(r.value)
|
|
443
799
|
}, [
|
|
444
|
-
|
|
445
|
-
src:
|
|
446
|
-
alt:
|
|
447
|
-
class:
|
|
800
|
+
d("img", {
|
|
801
|
+
src: s.value,
|
|
802
|
+
alt: e.name,
|
|
803
|
+
class: re(["svg-icon", e.className]),
|
|
448
804
|
style: ue(o.value)
|
|
449
|
-
}, null, 14,
|
|
805
|
+
}, null, 14, wn)
|
|
450
806
|
], 4));
|
|
451
807
|
}
|
|
452
|
-
},
|
|
808
|
+
}, Ce = /* @__PURE__ */ vn(bn, [["__scopeId", "data-v-490b11c1"]]), kn = async (e) => {
|
|
453
809
|
if (navigator.clipboard && navigator.permissions)
|
|
454
|
-
await navigator.clipboard.writeText(
|
|
810
|
+
await navigator.clipboard.writeText(e);
|
|
455
811
|
else {
|
|
456
|
-
const
|
|
457
|
-
|
|
812
|
+
const t = document.createElement("textArea");
|
|
813
|
+
t.value = e, t.style.width = 0, t.style.position = "fixed", t.style.left = "-999px", t.style.top = "10px", t.setAttribute("readonly", "readonly"), document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
458
814
|
}
|
|
459
|
-
},
|
|
815
|
+
}, Sn = { class: "thinking-title" }, Cn = { class: "thinking-toggle-hint" }, An = ["innerHTML"], xn = ["innerHTML"], Tn = 10, Rn = {
|
|
460
816
|
__name: "Previewer",
|
|
461
817
|
props: {
|
|
462
818
|
reader: null,
|
|
@@ -466,96 +822,121 @@ const _t = (r, e) => {
|
|
|
466
822
|
messagePostRender: {
|
|
467
823
|
type: Function,
|
|
468
824
|
default: null
|
|
825
|
+
},
|
|
826
|
+
/**
|
|
827
|
+
* szjy-ui fence 自定义 UI 配置(透传给动作处理器)
|
|
828
|
+
* 例如:{ postMessage: { target: () => iframe.contentWindow, targetOrigin: 'http://...' } }
|
|
829
|
+
*/
|
|
830
|
+
customUi: {
|
|
831
|
+
type: Object,
|
|
832
|
+
default: null
|
|
833
|
+
},
|
|
834
|
+
/**
|
|
835
|
+
* szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
|
|
836
|
+
*/
|
|
837
|
+
uiActionHandler: {
|
|
838
|
+
type: Function,
|
|
839
|
+
default: null
|
|
469
840
|
}
|
|
470
841
|
},
|
|
471
842
|
emits: [
|
|
472
843
|
"failed",
|
|
473
844
|
"completed",
|
|
474
|
-
"updating"
|
|
845
|
+
"updating",
|
|
846
|
+
"ui-action"
|
|
475
847
|
],
|
|
476
|
-
setup(
|
|
477
|
-
const { appContext:
|
|
478
|
-
let
|
|
479
|
-
|
|
480
|
-
|
|
848
|
+
setup(e, { expose: t, emit: s }) {
|
|
849
|
+
const { appContext: r } = Je(), { $message: o } = r.config.globalProperties, n = e, a = T(n.displayText || ""), i = T(!0), l = T(!1), c = T(!!n.displayText), b = s, P = T(null);
|
|
850
|
+
let A = null;
|
|
851
|
+
Pe(P, (j) => {
|
|
852
|
+
A && (A(), A = null), j && (A = gn(j, {
|
|
853
|
+
// 点击时才读取最新 props,宿主更新 customUi/uiActionHandler 后立即生效
|
|
854
|
+
getConfig: () => n.customUi,
|
|
855
|
+
getInterceptor: () => n.uiActionHandler,
|
|
856
|
+
onAction: (_) => b("ui-action", _)
|
|
857
|
+
}));
|
|
858
|
+
});
|
|
859
|
+
let p = null;
|
|
860
|
+
const F = N(() => Ft(a.value)), U = N(() => F.value.thinking.length > 0), z = T(n.displayText ? F.value.content.length : 0), y = N(() => F.value.isThinkingStreaming && !c.value), m = T(!1), v = () => {
|
|
861
|
+
m.value = !m.value;
|
|
481
862
|
};
|
|
482
|
-
let
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
863
|
+
let f = null, u = null;
|
|
864
|
+
const k = T(0);
|
|
865
|
+
Pe(() => F.value.thinking, (j) => {
|
|
866
|
+
!j || k.value > 0 || (u === null && (u = f ?? Date.now()), F.value.content && C());
|
|
486
867
|
});
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
},
|
|
492
|
-
n.reader && n.reader.cancel(), l.value = !0,
|
|
493
|
-
},
|
|
494
|
-
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
},
|
|
868
|
+
const C = () => {
|
|
869
|
+
if (k.value > 0 || !U.value) return;
|
|
870
|
+
const j = u ?? f;
|
|
871
|
+
j && (k.value = Math.max(1, Math.round((Date.now() - j) / 1e3)));
|
|
872
|
+
}, L = N(() => y.value ? "正在思考..." : k.value > 0 ? `已深度思考(用时 ${k.value} 秒)` : "思考过程"), R = N(() => U.value ? ee ? ee.render(F.value.thinking) : F.value.thinking : ""), I = N(() => F.value.content.slice(0, z.value)), w = N(() => ee ? ee.render(I.value) : I.value), O = () => {
|
|
873
|
+
n.reader && n.reader.cancel(), l.value = !0, q.value = !1, ne(), c.value = !0, C(), b("completed", a.value), i.value = !1, p && (cancelAnimationFrame(p), p = null);
|
|
874
|
+
}, X = N(() => `${w.value}`), Y = T(!1), Z = () => {
|
|
875
|
+
Y.value = !0;
|
|
876
|
+
}, ne = () => {
|
|
877
|
+
Y.value = !1;
|
|
878
|
+
}, q = T(!1), oe = async () => {
|
|
498
879
|
if (!n.reader) return;
|
|
499
|
-
const
|
|
880
|
+
const j = new TextDecoder("utf-8");
|
|
500
881
|
for (i.value = !0; !l.value; )
|
|
501
882
|
try {
|
|
502
883
|
if (!n.reader) {
|
|
503
|
-
|
|
884
|
+
q.value = !0;
|
|
504
885
|
break;
|
|
505
886
|
}
|
|
506
|
-
const { value:
|
|
887
|
+
const { value: _, done: V } = await n.reader.read();
|
|
507
888
|
if (!n.reader) {
|
|
508
|
-
|
|
889
|
+
q.value = !0;
|
|
509
890
|
break;
|
|
510
891
|
}
|
|
511
|
-
if (
|
|
512
|
-
|
|
892
|
+
if (V) {
|
|
893
|
+
q.value = !0;
|
|
513
894
|
break;
|
|
514
895
|
}
|
|
515
|
-
const
|
|
516
|
-
if (!
|
|
896
|
+
const ie = He[n.model];
|
|
897
|
+
if (!ie)
|
|
517
898
|
break;
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
|
|
899
|
+
const G = ie.call(He, _, j);
|
|
900
|
+
if (G.done) {
|
|
901
|
+
q.value = !0;
|
|
521
902
|
break;
|
|
522
903
|
}
|
|
523
|
-
!
|
|
524
|
-
} catch (
|
|
525
|
-
|
|
904
|
+
!f && G.content && (f = Date.now()), a.value += G.content, p === null && ae();
|
|
905
|
+
} catch (_) {
|
|
906
|
+
q.value = !0, console.log(3333, _), b("failed", _), O();
|
|
526
907
|
break;
|
|
527
908
|
} finally {
|
|
528
|
-
|
|
909
|
+
ne();
|
|
529
910
|
}
|
|
530
|
-
},
|
|
911
|
+
}, fe = async () => {
|
|
531
912
|
n.scrollToBottomFn && n.scrollToBottomFn();
|
|
532
|
-
},
|
|
533
|
-
},
|
|
913
|
+
}, ke = (j = () => {
|
|
914
|
+
}, _ = () => {
|
|
534
915
|
}) => {
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
},
|
|
538
|
-
if (l.value &&
|
|
539
|
-
cancelAnimationFrame(
|
|
916
|
+
const V = F.value.content.length;
|
|
917
|
+
z.value > V && (z.value = V), z.value < V ? (z.value = Math.min(V, z.value + Tn), j()) : _();
|
|
918
|
+
}, ae = () => {
|
|
919
|
+
if (l.value && p) {
|
|
920
|
+
cancelAnimationFrame(p), p = null, i.value = !1;
|
|
540
921
|
return;
|
|
541
922
|
}
|
|
542
|
-
|
|
923
|
+
q.value ? ke(
|
|
543
924
|
() => {
|
|
544
|
-
|
|
925
|
+
p = requestAnimationFrame(ae), b("updating", null);
|
|
545
926
|
},
|
|
546
927
|
() => {
|
|
547
|
-
|
|
548
|
-
if (
|
|
928
|
+
C(), b("completed", a.value), i.value = !1, c.value = !0, Ye(() => {
|
|
929
|
+
if (q.value = !1, n.messagePostRender && P.value)
|
|
549
930
|
try {
|
|
550
|
-
n.messagePostRender(
|
|
551
|
-
} catch (
|
|
552
|
-
console.error("messagePostRender 执行失败:",
|
|
931
|
+
n.messagePostRender(P.value, F.value.content);
|
|
932
|
+
} catch (j) {
|
|
933
|
+
console.error("messagePostRender 执行失败:", j);
|
|
553
934
|
}
|
|
554
|
-
}),
|
|
935
|
+
}), p = null;
|
|
555
936
|
}
|
|
556
|
-
) : (
|
|
937
|
+
) : (ke(), p = requestAnimationFrame(ae)), fe();
|
|
557
938
|
};
|
|
558
|
-
|
|
939
|
+
Pe(
|
|
559
940
|
() => n.reader,
|
|
560
941
|
() => {
|
|
561
942
|
n.reader && oe();
|
|
@@ -564,124 +945,124 @@ const _t = (r, e) => {
|
|
|
564
945
|
immediate: !0,
|
|
565
946
|
deep: !0
|
|
566
947
|
}
|
|
567
|
-
),
|
|
568
|
-
|
|
569
|
-
}),
|
|
570
|
-
abortReader:
|
|
571
|
-
initializeStart:
|
|
572
|
-
initializeEnd:
|
|
573
|
-
}),
|
|
574
|
-
const
|
|
948
|
+
), wt(() => {
|
|
949
|
+
A && (A(), A = null), O();
|
|
950
|
+
}), t({
|
|
951
|
+
abortReader: O,
|
|
952
|
+
initializeStart: Z,
|
|
953
|
+
initializeEnd: ne
|
|
954
|
+
}), N(() => Y.value ? !0 : (!n.reader || !i || a.value, !1));
|
|
955
|
+
const xe = async () => {
|
|
575
956
|
try {
|
|
576
|
-
const
|
|
577
|
-
await
|
|
578
|
-
} catch (
|
|
579
|
-
console.error("复制失败:",
|
|
957
|
+
const j = F.value.content || a.value;
|
|
958
|
+
await kn(j), o.success("复制成功");
|
|
959
|
+
} catch (j) {
|
|
960
|
+
console.error("复制失败:", j), o.error("复制失败");
|
|
580
961
|
}
|
|
581
962
|
};
|
|
582
|
-
return (
|
|
963
|
+
return (j, _) => (S(), ge(ye, { name: "fade" }, {
|
|
583
964
|
default: J(() => [
|
|
584
|
-
|
|
965
|
+
X.value || U.value ? (S(), x("div", {
|
|
585
966
|
key: 0,
|
|
586
967
|
ref_key: "refWrapperContent",
|
|
587
|
-
ref:
|
|
968
|
+
ref: P,
|
|
588
969
|
"text-16": "",
|
|
589
970
|
class: "w-full h-full overflow-y-auto relative",
|
|
590
971
|
"p-24px": ""
|
|
591
972
|
}, [
|
|
592
|
-
|
|
973
|
+
U.value ? (S(), x("div", {
|
|
593
974
|
key: 0,
|
|
594
|
-
class:
|
|
595
|
-
"is-expanded":
|
|
596
|
-
"is-streaming":
|
|
975
|
+
class: re(["ai-thinking-block", {
|
|
976
|
+
"is-expanded": m.value || y.value,
|
|
977
|
+
"is-streaming": y.value
|
|
597
978
|
}])
|
|
598
979
|
}, [
|
|
599
|
-
|
|
980
|
+
d("div", {
|
|
600
981
|
class: "thinking-header",
|
|
601
|
-
onClick:
|
|
982
|
+
onClick: v
|
|
602
983
|
}, [
|
|
603
|
-
|
|
984
|
+
_[0] || (_[0] = d("svg", {
|
|
604
985
|
class: "thinking-arrow",
|
|
605
986
|
viewBox: "0 0 1024 1024",
|
|
606
987
|
width: "10",
|
|
607
988
|
height: "10"
|
|
608
989
|
}, [
|
|
609
|
-
|
|
990
|
+
d("path", {
|
|
610
991
|
d: "M704 512 320 256v512z",
|
|
611
992
|
fill: "currentColor"
|
|
612
993
|
})
|
|
613
994
|
], -1)),
|
|
614
|
-
|
|
615
|
-
|
|
995
|
+
d("span", Sn, W(L.value), 1),
|
|
996
|
+
d("span", Cn, W(m.value || y.value ? "收起" : "展开"), 1)
|
|
616
997
|
]),
|
|
617
|
-
|
|
998
|
+
Ke(d("div", {
|
|
618
999
|
class: "thinking-body",
|
|
619
|
-
innerHTML:
|
|
620
|
-
}, null, 8,
|
|
621
|
-
[
|
|
1000
|
+
innerHTML: R.value
|
|
1001
|
+
}, null, 8, An), [
|
|
1002
|
+
[Xe, m.value || y.value]
|
|
622
1003
|
])
|
|
623
|
-
], 2)) :
|
|
624
|
-
|
|
1004
|
+
], 2)) : $("", !0),
|
|
1005
|
+
d("div", {
|
|
625
1006
|
class: "markdown-wrapper",
|
|
626
|
-
innerHTML:
|
|
627
|
-
}, null, 8,
|
|
628
|
-
|
|
1007
|
+
innerHTML: X.value
|
|
1008
|
+
}, null, 8, xn),
|
|
1009
|
+
c.value ? (S(), x("div", {
|
|
629
1010
|
key: 1,
|
|
630
1011
|
class: "ai-copy-btn-wrapper",
|
|
631
|
-
onClick:
|
|
1012
|
+
onClick: xe
|
|
632
1013
|
}, [
|
|
633
|
-
|
|
1014
|
+
D(Ce, {
|
|
634
1015
|
name: "/images/svg/copy.svg",
|
|
635
1016
|
color: "#666666"
|
|
636
1017
|
}),
|
|
637
|
-
|
|
638
|
-
])) :
|
|
639
|
-
], 512)) :
|
|
1018
|
+
_[1] || (_[1] = d("span", { class: "copy-text" }, "复制", -1))
|
|
1019
|
+
])) : $("", !0)
|
|
1020
|
+
], 512)) : $("", !0)
|
|
640
1021
|
]),
|
|
641
1022
|
_: 1
|
|
642
1023
|
}));
|
|
643
1024
|
}
|
|
644
1025
|
};
|
|
645
|
-
class
|
|
646
|
-
constructor(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
this.ratio =
|
|
1026
|
+
class Un {
|
|
1027
|
+
constructor(t, s) {
|
|
1028
|
+
M(this, "ratio");
|
|
1029
|
+
M(this, "leftover", new Float32Array(0));
|
|
1030
|
+
M(this, "fracOffset", 0);
|
|
1031
|
+
this.ratio = t / s;
|
|
651
1032
|
}
|
|
652
1033
|
reset() {
|
|
653
1034
|
this.leftover = new Float32Array(0), this.fracOffset = 0;
|
|
654
1035
|
}
|
|
655
|
-
process(
|
|
1036
|
+
process(t) {
|
|
656
1037
|
if (this.ratio === 1)
|
|
657
|
-
return new Float32Array(
|
|
658
|
-
const
|
|
659
|
-
if (
|
|
660
|
-
return this.leftover =
|
|
661
|
-
const
|
|
1038
|
+
return new Float32Array(t);
|
|
1039
|
+
const s = new Float32Array(this.leftover.length + t.length);
|
|
1040
|
+
if (s.set(this.leftover), s.set(t, this.leftover.length), s.length < 2)
|
|
1041
|
+
return this.leftover = s, new Float32Array(0);
|
|
1042
|
+
const r = [];
|
|
662
1043
|
let o = this.fracOffset;
|
|
663
|
-
for (; o <
|
|
664
|
-
const
|
|
665
|
-
|
|
1044
|
+
for (; o < s.length - 1; ) {
|
|
1045
|
+
const a = Math.floor(o), i = o - a, l = s[a], c = s[a + 1];
|
|
1046
|
+
r.push(l + i * (c - l)), o += this.ratio;
|
|
666
1047
|
}
|
|
667
|
-
const n = Math.min(
|
|
668
|
-
return this.leftover =
|
|
1048
|
+
const n = Math.min(s.length, Math.floor(o));
|
|
1049
|
+
return this.leftover = s.slice(n), this.fracOffset = o - n, Float32Array.from(r);
|
|
669
1050
|
}
|
|
670
1051
|
}
|
|
671
|
-
class
|
|
672
|
-
constructor(
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
this.targetSampleRate =
|
|
1052
|
+
class _n {
|
|
1053
|
+
constructor(t = {}) {
|
|
1054
|
+
M(this, "targetSampleRate");
|
|
1055
|
+
M(this, "audioContext", null);
|
|
1056
|
+
M(this, "mediaStream", null);
|
|
1057
|
+
M(this, "sourceNode", null);
|
|
1058
|
+
M(this, "processorNode", null);
|
|
1059
|
+
M(this, "muteGain", null);
|
|
1060
|
+
M(this, "resampler", null);
|
|
1061
|
+
M(this, "audioChunks", []);
|
|
1062
|
+
M(this, "onVolumeChange");
|
|
1063
|
+
M(this, "onAudioChunk");
|
|
1064
|
+
M(this, "_isRecording", !1);
|
|
1065
|
+
this.targetSampleRate = t.sampleRate || 16e3, this.onVolumeChange = t.onVolumeChange, this.onAudioChunk = t.onAudioChunk;
|
|
685
1066
|
}
|
|
686
1067
|
get isRecording() {
|
|
687
1068
|
return this._isRecording;
|
|
@@ -703,30 +1084,30 @@ class $t {
|
|
|
703
1084
|
autoGainControl: !0
|
|
704
1085
|
}
|
|
705
1086
|
});
|
|
706
|
-
} catch (
|
|
707
|
-
throw
|
|
1087
|
+
} catch (r) {
|
|
1088
|
+
throw r.name === "NotAllowedError" || r.name === "PermissionDeniedError" ? new Error("麦克风权限被拒绝,请在浏览器地址栏允许麦克风访问权限。") : r.name === "NotFoundError" || r.name === "DevicesNotFoundError" ? new Error("未检测到可用的麦克风输入设备。") : new Error(`无法启动麦克风: ${r.message || r}`);
|
|
708
1089
|
}
|
|
709
|
-
const
|
|
1090
|
+
const t = window.AudioContext || window.webkitAudioContext;
|
|
710
1091
|
try {
|
|
711
|
-
this.audioContext = new
|
|
1092
|
+
this.audioContext = new t({ sampleRate: this.targetSampleRate });
|
|
712
1093
|
} catch {
|
|
713
|
-
this.audioContext = new
|
|
1094
|
+
this.audioContext = new t();
|
|
714
1095
|
}
|
|
715
|
-
this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioChunks = [], this.resampler = this.audioContext.sampleRate === this.targetSampleRate ? null : new
|
|
716
|
-
const
|
|
717
|
-
this.processorNode = this.audioContext.createScriptProcessor(
|
|
718
|
-
var
|
|
1096
|
+
this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioChunks = [], this.resampler = this.audioContext.sampleRate === this.targetSampleRate ? null : new Un(this.audioContext.sampleRate, this.targetSampleRate), this.sourceNode = this.audioContext.createMediaStreamSource(this.mediaStream);
|
|
1097
|
+
const s = 4096;
|
|
1098
|
+
this.processorNode = this.audioContext.createScriptProcessor(s, 1, 1), this.processorNode.onaudioprocess = (r) => {
|
|
1099
|
+
var a;
|
|
719
1100
|
if (!this._isRecording) return;
|
|
720
|
-
const o = new Float32Array(
|
|
1101
|
+
const o = new Float32Array(r.inputBuffer.getChannelData(0));
|
|
721
1102
|
if (this.onVolumeChange) {
|
|
722
1103
|
let i = 0;
|
|
723
|
-
for (let
|
|
724
|
-
i += o[
|
|
725
|
-
const l = Math.sqrt(i / o.length),
|
|
726
|
-
this.onVolumeChange(
|
|
1104
|
+
for (let b = 0; b < o.length; b++)
|
|
1105
|
+
i += o[b] * o[b];
|
|
1106
|
+
const l = Math.sqrt(i / o.length), c = Math.min(100, Math.round(l * 100 * 5));
|
|
1107
|
+
this.onVolumeChange(c);
|
|
727
1108
|
}
|
|
728
1109
|
const n = this.resampler ? this.resampler.process(o) : o;
|
|
729
|
-
n.length && (this.audioChunks.push(n), (
|
|
1110
|
+
n.length && (this.audioChunks.push(n), (a = this.onAudioChunk) == null || a.call(this, n));
|
|
730
1111
|
}, this.muteGain = this.audioContext.createGain(), this.muteGain.gain.value = 0, this.sourceNode.connect(this.processorNode), this.processorNode.connect(this.muteGain), this.muteGain.connect(this.audioContext.destination), this._isRecording = !0;
|
|
731
1112
|
}
|
|
732
1113
|
/**
|
|
@@ -736,11 +1117,11 @@ class $t {
|
|
|
736
1117
|
if (!this._isRecording)
|
|
737
1118
|
return new Float32Array(0);
|
|
738
1119
|
this._isRecording = !1, this.cleanup();
|
|
739
|
-
const
|
|
740
|
-
let
|
|
1120
|
+
const t = this.audioChunks.reduce((o, n) => o + n.length, 0), s = new Float32Array(t);
|
|
1121
|
+
let r = 0;
|
|
741
1122
|
for (const o of this.audioChunks)
|
|
742
|
-
|
|
743
|
-
return this.audioChunks = [],
|
|
1123
|
+
s.set(o, r), r += o.length;
|
|
1124
|
+
return this.audioChunks = [], s;
|
|
744
1125
|
}
|
|
745
1126
|
/**
|
|
746
1127
|
* 取消录音并丢弃采集的数据
|
|
@@ -749,109 +1130,109 @@ class $t {
|
|
|
749
1130
|
this._isRecording = !1, this.audioChunks = [], this.cleanup();
|
|
750
1131
|
}
|
|
751
1132
|
cleanup() {
|
|
752
|
-
this.processorNode && (this.processorNode.disconnect(), this.processorNode.onaudioprocess = null, this.processorNode = null), this.muteGain && (this.muteGain.disconnect(), this.muteGain = null), this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.resampler = null, this.mediaStream && (this.mediaStream.getTracks().forEach((
|
|
1133
|
+
this.processorNode && (this.processorNode.disconnect(), this.processorNode.onaudioprocess = null, this.processorNode = null), this.muteGain && (this.muteGain.disconnect(), this.muteGain = null), this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.resampler = null, this.mediaStream && (this.mediaStream.getTracks().forEach((t) => t.stop()), this.mediaStream = null), this.audioContext && this.audioContext.state !== "closed" && (this.audioContext.close().catch(() => {
|
|
753
1134
|
}), this.audioContext = null);
|
|
754
1135
|
}
|
|
755
1136
|
}
|
|
756
|
-
function
|
|
757
|
-
if (
|
|
758
|
-
return new Float32Array(
|
|
759
|
-
const
|
|
760
|
-
for (let
|
|
761
|
-
const i =
|
|
762
|
-
n[
|
|
1137
|
+
function Pn(e, t, s) {
|
|
1138
|
+
if (t === s)
|
|
1139
|
+
return new Float32Array(e);
|
|
1140
|
+
const r = t / s, o = Math.round(e.length / r), n = new Float32Array(o);
|
|
1141
|
+
for (let a = 0; a < o; a++) {
|
|
1142
|
+
const i = a * r, l = Math.floor(i), c = i - l, b = e[l] ?? 0, P = e[l + 1] ?? b;
|
|
1143
|
+
n[a] = b + c * (P - b);
|
|
763
1144
|
}
|
|
764
1145
|
return n;
|
|
765
1146
|
}
|
|
766
|
-
async function
|
|
767
|
-
const
|
|
1147
|
+
async function Mn(e, t = 16e3) {
|
|
1148
|
+
const s = await e.arrayBuffer(), r = window.AudioContext || window.webkitAudioContext, o = new r();
|
|
768
1149
|
try {
|
|
769
|
-
const n = await o.decodeAudioData(
|
|
770
|
-
let
|
|
1150
|
+
const n = await o.decodeAudioData(s);
|
|
1151
|
+
let a;
|
|
771
1152
|
if (n.numberOfChannels > 1) {
|
|
772
|
-
|
|
1153
|
+
a = new Float32Array(n.length);
|
|
773
1154
|
for (let i = 0; i < n.numberOfChannels; i++) {
|
|
774
1155
|
const l = n.getChannelData(i);
|
|
775
|
-
for (let
|
|
776
|
-
|
|
1156
|
+
for (let c = 0; c < n.length; c++)
|
|
1157
|
+
a[c] += l[c] / n.numberOfChannels;
|
|
777
1158
|
}
|
|
778
1159
|
} else
|
|
779
|
-
|
|
780
|
-
return
|
|
1160
|
+
a = n.getChannelData(0);
|
|
1161
|
+
return Pn(a, n.sampleRate, t);
|
|
781
1162
|
} finally {
|
|
782
1163
|
o.state !== "closed" && await o.close().catch(() => {
|
|
783
1164
|
});
|
|
784
1165
|
}
|
|
785
1166
|
}
|
|
786
|
-
function
|
|
787
|
-
const
|
|
1167
|
+
function qe(e, t = 16e3) {
|
|
1168
|
+
const s = new ArrayBuffer(44 + e.length * 2), r = new DataView(s), o = (a, i) => {
|
|
788
1169
|
for (let l = 0; l < i.length; l++)
|
|
789
|
-
|
|
1170
|
+
r.setUint8(a + l, i.charCodeAt(l));
|
|
790
1171
|
};
|
|
791
|
-
o(0, "RIFF"),
|
|
1172
|
+
o(0, "RIFF"), r.setUint32(4, 36 + e.length * 2, !0), o(8, "WAVE"), o(12, "fmt "), r.setUint32(16, 16, !0), r.setUint16(20, 1, !0), r.setUint16(22, 1, !0), r.setUint32(24, t, !0), r.setUint32(28, t * 2, !0), r.setUint16(32, 2, !0), r.setUint16(34, 16, !0), o(36, "data"), r.setUint32(40, e.length * 2, !0);
|
|
792
1173
|
let n = 44;
|
|
793
|
-
for (let
|
|
794
|
-
const i = Math.max(-1, Math.min(1,
|
|
795
|
-
|
|
1174
|
+
for (let a = 0; a < e.length; a++, n += 2) {
|
|
1175
|
+
const i = Math.max(-1, Math.min(1, e[a]));
|
|
1176
|
+
r.setInt16(n, i < 0 ? i * 32768 : i * 32767, !0);
|
|
796
1177
|
}
|
|
797
|
-
return new Blob([
|
|
1178
|
+
return new Blob([r], { type: "audio/wav" });
|
|
798
1179
|
}
|
|
799
|
-
const
|
|
800
|
-
function
|
|
801
|
-
return new Worker(
|
|
1180
|
+
const ot = 16e3, In = Math.round(ot * 0.35), at = "/scripts/ai/whisper.worker.js";
|
|
1181
|
+
function En() {
|
|
1182
|
+
return new Worker(je(at), { type: "module" });
|
|
802
1183
|
}
|
|
803
|
-
function
|
|
804
|
-
return /^https?:\/\//i.test(
|
|
1184
|
+
function je(e) {
|
|
1185
|
+
return /^https?:\/\//i.test(e) ? e : typeof location < "u" ? new URL(e, location.origin).href : e;
|
|
805
1186
|
}
|
|
806
|
-
function
|
|
807
|
-
if (!
|
|
808
|
-
const
|
|
809
|
-
return !(
|
|
1187
|
+
function We(e) {
|
|
1188
|
+
if (!e.ok) return !1;
|
|
1189
|
+
const t = (e.headers.get("content-type") || "").toLowerCase();
|
|
1190
|
+
return !(t.includes("text/html") || t.includes("application/xhtml+xml"));
|
|
810
1191
|
}
|
|
811
|
-
async function
|
|
1192
|
+
async function jn(e) {
|
|
812
1193
|
try {
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
1194
|
+
const t = await fetch(e, { method: "HEAD" });
|
|
1195
|
+
if (We(t)) return !0;
|
|
815
1196
|
} catch {
|
|
816
1197
|
}
|
|
817
1198
|
try {
|
|
818
|
-
const
|
|
819
|
-
if (
|
|
1199
|
+
const t = await fetch(e, { headers: { Range: "bytes=0-64" } });
|
|
1200
|
+
if (We(t)) return !0;
|
|
820
1201
|
} catch {
|
|
821
1202
|
}
|
|
822
1203
|
return !1;
|
|
823
1204
|
}
|
|
824
|
-
async function
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
const
|
|
828
|
-
for (const
|
|
829
|
-
if (await
|
|
830
|
-
return console.log("[VoiceInputManager] 使用语音 Worker:",
|
|
1205
|
+
async function zn(e) {
|
|
1206
|
+
const t = [];
|
|
1207
|
+
e && t.push(je(e)), t.push(je(at));
|
|
1208
|
+
const s = [...new Set(t.filter(Boolean))];
|
|
1209
|
+
for (const r of s)
|
|
1210
|
+
if (await jn(r))
|
|
1211
|
+
return console.log("[VoiceInputManager] 使用语音 Worker:", r), r;
|
|
831
1212
|
return console.warn(
|
|
832
1213
|
"[VoiceInputManager] 未探测到可访问的 Worker 脚本,将回退到 Vite 打包注入地址。已尝试:",
|
|
833
|
-
|
|
1214
|
+
s.join(" , ")
|
|
834
1215
|
), null;
|
|
835
1216
|
}
|
|
836
|
-
class
|
|
837
|
-
constructor(
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1217
|
+
class Ln {
|
|
1218
|
+
constructor(t = {}) {
|
|
1219
|
+
M(this, "recorder", null);
|
|
1220
|
+
M(this, "worker", null);
|
|
1221
|
+
M(this, "status", "idle");
|
|
1222
|
+
M(this, "options");
|
|
1223
|
+
M(this, "isReady", !1);
|
|
1224
|
+
M(this, "initPromise", null);
|
|
1225
|
+
M(this, "currentTaskId", 0);
|
|
1226
|
+
M(this, "pcmParts", []);
|
|
1227
|
+
M(this, "pcmLength", 0);
|
|
1228
|
+
M(this, "streamChunkIndex", 0);
|
|
1229
|
+
M(this, "committedText", "");
|
|
849
1230
|
this.options = {
|
|
850
1231
|
soundBaseUrl: "/sounds/",
|
|
851
1232
|
remoteHost: "https://hf-mirror.com",
|
|
852
1233
|
modelId: "onnx-community/whisper-base",
|
|
853
1234
|
language: "chinese",
|
|
854
|
-
...
|
|
1235
|
+
...t
|
|
855
1236
|
};
|
|
856
1237
|
}
|
|
857
1238
|
get currentStatus() {
|
|
@@ -863,19 +1244,19 @@ class Wt {
|
|
|
863
1244
|
/**
|
|
864
1245
|
* 初始化语音引擎(延迟加载,仅在首次使用或调用时触发)
|
|
865
1246
|
*/
|
|
866
|
-
async init(
|
|
1247
|
+
async init(t) {
|
|
867
1248
|
if (!this.isReady)
|
|
868
|
-
return this.initPromise ? this.initPromise : (
|
|
1249
|
+
return this.initPromise ? this.initPromise : (t && (this.options.soundBaseUrl = t), this.initPromise = new Promise((s, r) => {
|
|
869
1250
|
this.setStatus("loading", "正在准备语音识别引擎..."), (async () => {
|
|
870
|
-
var n,
|
|
1251
|
+
var n, a;
|
|
871
1252
|
try {
|
|
872
|
-
const i = await
|
|
873
|
-
this.worker = i ? new Worker(i, { type: "module" }) :
|
|
874
|
-
this.handleWorkerMessage(l,
|
|
1253
|
+
const i = await zn(this.options.workerUrl);
|
|
1254
|
+
this.worker = i ? new Worker(i, { type: "module" }) : En(), this.worker.onmessage = (l) => {
|
|
1255
|
+
this.handleWorkerMessage(l, s, r);
|
|
875
1256
|
}, this.worker.onerror = (l) => {
|
|
876
|
-
var
|
|
877
|
-
const
|
|
878
|
-
this.initPromise = null, this.setStatus("error",
|
|
1257
|
+
var P, A;
|
|
1258
|
+
const b = `语音后台线程异常: ${l.message || l.filename || i || "未知错误"}`;
|
|
1259
|
+
this.initPromise = null, this.setStatus("error", b), (A = (P = this.options).onError) == null || A.call(P, b), r(l);
|
|
879
1260
|
}, this.worker.postMessage({
|
|
880
1261
|
type: "INIT",
|
|
881
1262
|
data: {
|
|
@@ -886,7 +1267,7 @@ class Wt {
|
|
|
886
1267
|
});
|
|
887
1268
|
} catch (i) {
|
|
888
1269
|
const l = `创建语音 Worker 失败: ${i.message || i}`;
|
|
889
|
-
this.initPromise = null, this.setStatus("error", l), (
|
|
1270
|
+
this.initPromise = null, this.setStatus("error", l), (a = (n = this.options).onError) == null || a.call(n, l), r(i);
|
|
890
1271
|
}
|
|
891
1272
|
})();
|
|
892
1273
|
}), this.initPromise);
|
|
@@ -895,15 +1276,15 @@ class Wt {
|
|
|
895
1276
|
* 开始语音录入(只采集,点「完成」后再转写)
|
|
896
1277
|
*/
|
|
897
1278
|
async startRecording() {
|
|
898
|
-
var
|
|
1279
|
+
var t, s, r, o;
|
|
899
1280
|
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
|
900
1281
|
const n = window.isSecureContext ? "当前浏览器环境不支持获取麦克风音频,请使用现代浏览器。" : "当前页面不是安全上下文,浏览器禁止调用麦克风。请使用 https:// 或 http://localhost / http://127.0.0.1 访问(通过局域网 IP 的 http 地址无法录音)。";
|
|
901
|
-
throw this.setStatus("error", n), (
|
|
1282
|
+
throw this.setStatus("error", n), (s = (t = this.options).onError) == null || s.call(t, n), new Error(n);
|
|
902
1283
|
}
|
|
903
|
-
this.isReady || await this.init(), this.recorder || (this.recorder = new
|
|
1284
|
+
this.isReady || await this.init(), this.recorder || (this.recorder = new _n({
|
|
904
1285
|
onVolumeChange: (n) => {
|
|
905
|
-
var
|
|
906
|
-
(i = (
|
|
1286
|
+
var a, i;
|
|
1287
|
+
(i = (a = this.options).onVolumeChange) == null || i.call(a, n);
|
|
907
1288
|
},
|
|
908
1289
|
onAudioChunk: (n) => {
|
|
909
1290
|
this.appendPcm(n);
|
|
@@ -912,14 +1293,14 @@ class Wt {
|
|
|
912
1293
|
try {
|
|
913
1294
|
this.currentTaskId++, this.resetStreamState(), await this.recorder.start(), this.setStatus("recording", "正在录音...");
|
|
914
1295
|
} catch (n) {
|
|
915
|
-
throw this.setStatus("error", n.message || "启动录音失败"), (o = (
|
|
1296
|
+
throw this.setStatus("error", n.message || "启动录音失败"), (o = (r = this.options).onError) == null || o.call(r, n.message || "启动录音失败"), n;
|
|
916
1297
|
}
|
|
917
1298
|
}
|
|
918
1299
|
/**
|
|
919
1300
|
* 停止录音并触发模型端侧推理
|
|
920
1301
|
*/
|
|
921
1302
|
async stopAndTranscribe() {
|
|
922
|
-
var
|
|
1303
|
+
var t, s, r, o;
|
|
923
1304
|
if (!(!this.recorder || !this.recorder.isRecording))
|
|
924
1305
|
try {
|
|
925
1306
|
await this.recorder.stop();
|
|
@@ -930,59 +1311,59 @@ class Wt {
|
|
|
930
1311
|
}
|
|
931
1312
|
this.setStatus("transcribing", "正在识别语音...");
|
|
932
1313
|
try {
|
|
933
|
-
const
|
|
934
|
-
(
|
|
935
|
-
} catch (
|
|
936
|
-
console.warn("生成录音回放音频失败:",
|
|
1314
|
+
const a = qe(n), i = URL.createObjectURL(a);
|
|
1315
|
+
(s = (t = this.options).onAudioRecorded) == null || s.call(t, i, a);
|
|
1316
|
+
} catch (a) {
|
|
1317
|
+
console.warn("生成录音回放音频失败:", a);
|
|
937
1318
|
}
|
|
938
1319
|
await this.transcribeAudioData(n);
|
|
939
1320
|
} catch (n) {
|
|
940
|
-
this.setStatus("error", n.message || "音频处理失败"), (o = (
|
|
1321
|
+
this.setStatus("error", n.message || "音频处理失败"), (o = (r = this.options).onError) == null || o.call(r, n.message || "音频处理失败");
|
|
941
1322
|
}
|
|
942
1323
|
}
|
|
943
1324
|
/**
|
|
944
1325
|
* 直接对外部传入的 16kHz Float32Array 音频进行端侧推理(例如文件上传)
|
|
945
1326
|
*/
|
|
946
|
-
async transcribeAudioData(
|
|
947
|
-
var
|
|
1327
|
+
async transcribeAudioData(t, s) {
|
|
1328
|
+
var r, o, n, a;
|
|
948
1329
|
this.isReady || await this.init(), this.setStatus("transcribing", "正在流式识别音频...");
|
|
949
1330
|
try {
|
|
950
|
-
|
|
1331
|
+
s && ((o = (r = this.options).onAudioRecorded) == null || o.call(r, s, qe(t))), this.currentTaskId++, this.resetStreamState(), this.appendPcm(t), this.dispatchFullAudio();
|
|
951
1332
|
} catch (i) {
|
|
952
|
-
this.setStatus("error", i.message || "音频处理失败"), (
|
|
1333
|
+
this.setStatus("error", i.message || "音频处理失败"), (a = (n = this.options).onError) == null || a.call(n, i.message || "音频处理失败");
|
|
953
1334
|
}
|
|
954
1335
|
}
|
|
955
1336
|
/**
|
|
956
1337
|
* 上传音频/视频文件(支持 mp4, wav, mp3, m4a 等)并在浏览器端解析识别
|
|
957
1338
|
*/
|
|
958
|
-
async transcribeFile(
|
|
959
|
-
var
|
|
1339
|
+
async transcribeFile(t) {
|
|
1340
|
+
var s, r;
|
|
960
1341
|
this.isReady || await this.init(), this.setStatus("loading", "正在解析音频文件...");
|
|
961
1342
|
try {
|
|
962
|
-
const o = await
|
|
1343
|
+
const o = await Mn(t);
|
|
963
1344
|
if (o.length === 0)
|
|
964
1345
|
throw new Error("未能从该文件中提取出有效音频");
|
|
965
|
-
const n = URL.createObjectURL(
|
|
1346
|
+
const n = URL.createObjectURL(t);
|
|
966
1347
|
await this.transcribeAudioData(o, n);
|
|
967
1348
|
} catch (o) {
|
|
968
|
-
this.setStatus("error", o.message || "音频文件解析失败"), (
|
|
1349
|
+
this.setStatus("error", o.message || "音频文件解析失败"), (r = (s = this.options).onError) == null || r.call(s, o.message || "音频文件解析失败");
|
|
969
1350
|
}
|
|
970
1351
|
}
|
|
971
1352
|
/**
|
|
972
1353
|
* 取消当前录音并丢弃
|
|
973
1354
|
*/
|
|
974
1355
|
cancelRecording() {
|
|
975
|
-
var
|
|
976
|
-
const
|
|
977
|
-
this.currentTaskId++, (
|
|
1356
|
+
var s;
|
|
1357
|
+
const t = this.currentTaskId;
|
|
1358
|
+
this.currentTaskId++, (s = this.worker) == null || s.postMessage({ type: "CANCEL", taskId: t }), this.resetStreamState(), this.recorder && this.recorder.cancel(), this.setStatus("idle");
|
|
978
1359
|
}
|
|
979
1360
|
/**
|
|
980
1361
|
* 取消当前的语音识别推理任务
|
|
981
1362
|
*/
|
|
982
1363
|
cancelTranscribe() {
|
|
983
|
-
var
|
|
984
|
-
const
|
|
985
|
-
this.currentTaskId++, (
|
|
1364
|
+
var s;
|
|
1365
|
+
const t = this.currentTaskId;
|
|
1366
|
+
this.currentTaskId++, (s = this.worker) == null || s.postMessage({ type: "CANCEL", taskId: t }), this.resetStreamState(), (this.status === "transcribing" || this.status === "recording") && this.setStatus("idle");
|
|
986
1367
|
}
|
|
987
1368
|
/**
|
|
988
1369
|
* 清除本地模型缓存
|
|
@@ -994,31 +1375,31 @@ class Wt {
|
|
|
994
1375
|
* 销毁并释放所有资源
|
|
995
1376
|
*/
|
|
996
1377
|
destroy() {
|
|
997
|
-
var
|
|
998
|
-
const
|
|
999
|
-
this.currentTaskId++, (
|
|
1378
|
+
var s;
|
|
1379
|
+
const t = this.currentTaskId;
|
|
1380
|
+
this.currentTaskId++, (s = this.worker) == null || s.postMessage({ type: "CANCEL", taskId: t }), this.resetStreamState(), this.recorder && (this.recorder.cancel(), this.recorder = null), this.worker && (this.worker.terminate(), this.worker = null), this.isReady = !1, this.initPromise = null, this.setStatus("idle");
|
|
1000
1381
|
}
|
|
1001
1382
|
resetStreamState() {
|
|
1002
1383
|
this.pcmParts = [], this.pcmLength = 0, this.streamChunkIndex = 0, this.committedText = "";
|
|
1003
1384
|
}
|
|
1004
|
-
appendPcm(
|
|
1005
|
-
!
|
|
1385
|
+
appendPcm(t) {
|
|
1386
|
+
!t || t.length === 0 || (this.pcmParts.push(new Float32Array(t)), this.pcmLength += t.length);
|
|
1006
1387
|
}
|
|
1007
1388
|
mergePcm() {
|
|
1008
|
-
const
|
|
1009
|
-
let
|
|
1010
|
-
for (const
|
|
1011
|
-
|
|
1012
|
-
return
|
|
1389
|
+
const t = new Float32Array(this.pcmLength);
|
|
1390
|
+
let s = 0;
|
|
1391
|
+
for (const r of this.pcmParts)
|
|
1392
|
+
t.set(r, s), s += r.length;
|
|
1393
|
+
return t;
|
|
1013
1394
|
}
|
|
1014
|
-
emitPartial(
|
|
1015
|
-
var
|
|
1016
|
-
(
|
|
1395
|
+
emitPartial(t) {
|
|
1396
|
+
var s, r;
|
|
1397
|
+
(r = (s = this.options).onPartial) == null || r.call(s, (t || "").trim());
|
|
1017
1398
|
}
|
|
1018
|
-
finishStream(
|
|
1019
|
-
var
|
|
1020
|
-
const
|
|
1021
|
-
this.setStatus("idle"), (o = (
|
|
1399
|
+
finishStream(t) {
|
|
1400
|
+
var r, o;
|
|
1401
|
+
const s = (t ?? this.committedText).trim();
|
|
1402
|
+
this.setStatus("idle"), (o = (r = this.options).onResult) == null || o.call(r, s);
|
|
1022
1403
|
}
|
|
1023
1404
|
/**
|
|
1024
1405
|
* 录音结束或上传:整段一次送入 Worker。超过 30s 由 Worker 按重叠窗口切分。
|
|
@@ -1028,41 +1409,41 @@ class Wt {
|
|
|
1028
1409
|
this.finishStream();
|
|
1029
1410
|
return;
|
|
1030
1411
|
}
|
|
1031
|
-
if (this.pcmLength <
|
|
1412
|
+
if (this.pcmLength < In) {
|
|
1032
1413
|
this.finishStream();
|
|
1033
1414
|
return;
|
|
1034
1415
|
}
|
|
1035
|
-
const
|
|
1416
|
+
const t = this.mergePcm(), s = t.length > ot * 30;
|
|
1036
1417
|
this.committedText = "", this.worker.postMessage(
|
|
1037
1418
|
{
|
|
1038
1419
|
type: "TRANSCRIBE",
|
|
1039
1420
|
data: {
|
|
1040
1421
|
taskId: this.currentTaskId,
|
|
1041
|
-
audio:
|
|
1422
|
+
audio: t,
|
|
1042
1423
|
language: this.options.language,
|
|
1043
1424
|
stream: !0,
|
|
1044
1425
|
chunkIndex: this.streamChunkIndex++,
|
|
1045
1426
|
isFinal: !0,
|
|
1046
1427
|
mode: "append",
|
|
1047
|
-
nativeChunking:
|
|
1428
|
+
nativeChunking: s
|
|
1048
1429
|
}
|
|
1049
1430
|
},
|
|
1050
|
-
[
|
|
1431
|
+
[t.buffer]
|
|
1051
1432
|
);
|
|
1052
1433
|
}
|
|
1053
|
-
handleWorkerMessage(
|
|
1054
|
-
var
|
|
1055
|
-
const { type: o, data: n, taskId:
|
|
1434
|
+
handleWorkerMessage(t, s, r) {
|
|
1435
|
+
var c, b, P, A;
|
|
1436
|
+
const { type: o, data: n, taskId: a, text: i, error: l } = t.data;
|
|
1056
1437
|
switch (o) {
|
|
1057
1438
|
case "READY":
|
|
1058
|
-
this.isReady = !0, this.setStatus("ready", "语音引擎就绪"),
|
|
1439
|
+
this.isReady = !0, this.setStatus("ready", "语音引擎就绪"), s == null || s();
|
|
1059
1440
|
break;
|
|
1060
1441
|
case "PROGRESS":
|
|
1061
1442
|
if (n) {
|
|
1062
|
-
const
|
|
1063
|
-
this.setStatus("downloading", `正在下载语音模型... ${
|
|
1443
|
+
const p = typeof n.progress == "number" ? Math.round(n.progress) : 0;
|
|
1444
|
+
this.setStatus("downloading", `正在下载语音模型... ${p}%`), (b = (c = this.options).onProgress) == null || b.call(c, {
|
|
1064
1445
|
status: n.status || "progress",
|
|
1065
|
-
progress:
|
|
1446
|
+
progress: p,
|
|
1066
1447
|
file: n.file,
|
|
1067
1448
|
loaded: n.loaded,
|
|
1068
1449
|
total: n.total
|
|
@@ -1070,15 +1451,15 @@ class Wt {
|
|
|
1070
1451
|
}
|
|
1071
1452
|
break;
|
|
1072
1453
|
case "TRANSCRIBING":
|
|
1073
|
-
if (
|
|
1454
|
+
if (a && a !== this.currentTaskId) return;
|
|
1074
1455
|
this.status !== "recording" && this.setStatus("transcribing", "正在流式转写文字...");
|
|
1075
1456
|
break;
|
|
1076
1457
|
case "PARTIAL":
|
|
1077
|
-
if (
|
|
1458
|
+
if (a && a !== this.currentTaskId) return;
|
|
1078
1459
|
this.committedText = i || "", this.emitPartial(this.committedText);
|
|
1079
1460
|
break;
|
|
1080
1461
|
case "RESULT":
|
|
1081
|
-
if (
|
|
1462
|
+
if (a && a !== this.currentTaskId)
|
|
1082
1463
|
return;
|
|
1083
1464
|
this.committedText = (i || "").trim() || this.committedText, this.emitPartial(this.committedText), this.finishStream(this.committedText);
|
|
1084
1465
|
break;
|
|
@@ -1086,64 +1467,64 @@ class Wt {
|
|
|
1086
1467
|
this.setStatus("idle", "语音模型缓存已清空");
|
|
1087
1468
|
break;
|
|
1088
1469
|
case "ERROR":
|
|
1089
|
-
if (
|
|
1090
|
-
this.setStatus("error", l || "语音服务异常"), (
|
|
1470
|
+
if (a && a !== this.currentTaskId) return;
|
|
1471
|
+
this.setStatus("error", l || "语音服务异常"), (A = (P = this.options).onError) == null || A.call(P, l || "语音服务异常"), r == null || r(new Error(l));
|
|
1091
1472
|
break;
|
|
1092
1473
|
}
|
|
1093
1474
|
}
|
|
1094
|
-
setStatus(
|
|
1095
|
-
var
|
|
1096
|
-
this.status =
|
|
1475
|
+
setStatus(t, s) {
|
|
1476
|
+
var r, o;
|
|
1477
|
+
this.status = t, (o = (r = this.options).onStatusChange) == null || o.call(r, t, s);
|
|
1097
1478
|
}
|
|
1098
1479
|
}
|
|
1099
|
-
const
|
|
1480
|
+
const $n = { class: "panel-header" }, On = { class: "header-actions" }, Nn = { class: "header-title" }, Fn = { class: "action-icons" }, Bn = { class: "body-content" }, Vn = {
|
|
1100
1481
|
key: 0,
|
|
1101
1482
|
class: "welcome-content"
|
|
1102
|
-
},
|
|
1483
|
+
}, Hn = { class: "subtitle" }, Dn = { class: "highlight" }, qn = { class: "quick-questions" }, Wn = ["onClick"], Gn = {
|
|
1103
1484
|
key: 1,
|
|
1104
1485
|
class: "message-content user-content"
|
|
1105
|
-
},
|
|
1486
|
+
}, Jn = { class: "panel-footer" }, Kn = {
|
|
1106
1487
|
key: 0,
|
|
1107
|
-
src:
|
|
1488
|
+
src: xt,
|
|
1108
1489
|
alt: "加载中",
|
|
1109
1490
|
class: "loading-icon"
|
|
1110
|
-
},
|
|
1491
|
+
}, Xn = {
|
|
1111
1492
|
key: 0,
|
|
1112
1493
|
class: "voice-progress-banner"
|
|
1113
|
-
},
|
|
1494
|
+
}, Yn = { class: "progress-info" }, Zn = { class: "progress-text" }, Qn = {
|
|
1114
1495
|
key: 0,
|
|
1115
1496
|
class: "progress-percent"
|
|
1116
|
-
},
|
|
1497
|
+
}, er = {
|
|
1117
1498
|
key: 0,
|
|
1118
1499
|
class: "progress-track"
|
|
1119
|
-
},
|
|
1500
|
+
}, tr = { class: "recording-main" }, nr = { class: "recording-status" }, rr = {
|
|
1120
1501
|
key: 0,
|
|
1121
1502
|
class: "recording-time"
|
|
1122
|
-
},
|
|
1503
|
+
}, sr = { class: "recording-hint" }, or = {
|
|
1123
1504
|
key: 1,
|
|
1124
1505
|
class: "volume-waves"
|
|
1125
|
-
},
|
|
1506
|
+
}, ar = { class: "recording-actions" }, ir = ["title"], lr = {
|
|
1126
1507
|
key: 0,
|
|
1127
1508
|
class: "voice-playback-bar"
|
|
1128
|
-
},
|
|
1509
|
+
}, cr = ["title"], ur = { class: "playback-play-icon" }, dr = {
|
|
1129
1510
|
key: 0,
|
|
1130
1511
|
viewBox: "0 0 24 24",
|
|
1131
1512
|
width: "14",
|
|
1132
1513
|
height: "14",
|
|
1133
1514
|
fill: "currentColor"
|
|
1134
|
-
},
|
|
1515
|
+
}, fr = {
|
|
1135
1516
|
key: 1,
|
|
1136
1517
|
viewBox: "0 0 24 24",
|
|
1137
1518
|
width: "14",
|
|
1138
1519
|
height: "14",
|
|
1139
1520
|
fill: "currentColor"
|
|
1140
|
-
},
|
|
1521
|
+
}, hr = { class: "playback-title" }, pr = {
|
|
1141
1522
|
key: 0,
|
|
1142
1523
|
class: "playback-time"
|
|
1143
|
-
},
|
|
1524
|
+
}, mr = {
|
|
1144
1525
|
key: 1,
|
|
1145
1526
|
class: "playback-waves"
|
|
1146
|
-
},
|
|
1527
|
+
}, gr = { class: "input-box" }, yr = { class: "input-actions-box" }, vr = ["src"], it = {
|
|
1147
1528
|
__name: "ChatPanel",
|
|
1148
1529
|
props: {
|
|
1149
1530
|
modelValue: {
|
|
@@ -1221,213 +1602,237 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
|
|
|
1221
1602
|
embedded: {
|
|
1222
1603
|
type: Boolean,
|
|
1223
1604
|
default: !1
|
|
1605
|
+
},
|
|
1606
|
+
/**
|
|
1607
|
+
* szjy-ui fence 自定义 UI 配置,透传给动作处理器。
|
|
1608
|
+
* 例如:{ postMessage: { target: () => sandboxIframe.contentWindow, targetOrigin: 'http://...' } }
|
|
1609
|
+
*/
|
|
1610
|
+
customUi: {
|
|
1611
|
+
type: Object,
|
|
1612
|
+
default: null
|
|
1613
|
+
},
|
|
1614
|
+
/**
|
|
1615
|
+
* szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
|
|
1616
|
+
*/
|
|
1617
|
+
uiActionHandler: {
|
|
1618
|
+
type: Function,
|
|
1619
|
+
default: null
|
|
1620
|
+
},
|
|
1621
|
+
/**
|
|
1622
|
+
* Mock 响应内容:llmName 为 standard(模拟数据模型)时不请求真实后端,
|
|
1623
|
+
* 将该内容流式输出,用于联调 szjy-ui fence / postMessage 动作
|
|
1624
|
+
*/
|
|
1625
|
+
mockResponse: {
|
|
1626
|
+
type: String,
|
|
1627
|
+
default: ""
|
|
1224
1628
|
}
|
|
1225
1629
|
},
|
|
1226
|
-
emits: ["update:modelValue", "submit"],
|
|
1227
|
-
setup(
|
|
1228
|
-
const { appContext:
|
|
1630
|
+
emits: ["update:modelValue", "submit", "ui-action"],
|
|
1631
|
+
setup(e, { emit: t }) {
|
|
1632
|
+
const { appContext: s } = Je(), { $message: r } = s.config.globalProperties, o = e;
|
|
1229
1633
|
let n = null;
|
|
1230
|
-
const
|
|
1231
|
-
let
|
|
1232
|
-
const
|
|
1233
|
-
let
|
|
1234
|
-
const
|
|
1235
|
-
const
|
|
1236
|
-
return B ?
|
|
1237
|
-
},
|
|
1238
|
-
const h = Math.floor(
|
|
1239
|
-
return `${h.toString().padStart(2, "0")}:${
|
|
1240
|
-
}, I = () => (n || (n = new
|
|
1634
|
+
const a = T("idle"), i = T(""), l = T(0), c = T(0), b = T(0);
|
|
1635
|
+
let P = null;
|
|
1636
|
+
const A = T(""), p = T(!1), F = T(0);
|
|
1637
|
+
let U = null;
|
|
1638
|
+
const z = T(""), y = T(""), m = N(() => a.value === "downloading"), v = N(() => a.value === "loading"), f = N(() => a.value === "recording"), u = N(() => a.value === "transcribing"), k = N(() => f.value ? "正在录音,点击完成后开始识别" : z.value ? "正在流式转写..." : "正在识别语音中..."), C = N(() => o.enableVoiceInput ? "请输入您的问题或点击麦克风语音输入" : o.enableVoiceUpload ? "请输入您的问题或上传音频识别" : "请输入您的问题"), L = (g, h) => {
|
|
1639
|
+
const E = (g || "").trim(), B = (h || "").trim();
|
|
1640
|
+
return B ? E ? /[A-Za-z0-9]$/.test(E) && /[A-Za-z0-9]/.test(B.charAt(0)) ? `${E} ${B}` : `${E}${B}` : B : E;
|
|
1641
|
+
}, R = (g) => {
|
|
1642
|
+
const h = Math.floor(g / 60), E = g % 60;
|
|
1643
|
+
return `${h.toString().padStart(2, "0")}:${E.toString().padStart(2, "0")}`;
|
|
1644
|
+
}, I = () => (n || (n = new Ln({
|
|
1241
1645
|
soundBaseUrl: o.soundBaseUrl || "/sounds/",
|
|
1242
1646
|
workerUrl: o.workerUrl || void 0,
|
|
1243
|
-
onStatusChange: (
|
|
1244
|
-
|
|
1647
|
+
onStatusChange: (g, h) => {
|
|
1648
|
+
a.value = g, h && (i.value = h);
|
|
1245
1649
|
},
|
|
1246
|
-
onProgress: (
|
|
1247
|
-
typeof
|
|
1650
|
+
onProgress: (g) => {
|
|
1651
|
+
typeof g.progress == "number" && (l.value = g.progress);
|
|
1248
1652
|
},
|
|
1249
|
-
onVolumeChange: (
|
|
1250
|
-
|
|
1653
|
+
onVolumeChange: (g) => {
|
|
1654
|
+
c.value = g;
|
|
1251
1655
|
},
|
|
1252
|
-
onAudioRecorded: (
|
|
1253
|
-
|
|
1656
|
+
onAudioRecorded: (g) => {
|
|
1657
|
+
A.value && URL.revokeObjectURL(A.value), A.value = g, F.value = b.value;
|
|
1254
1658
|
},
|
|
1255
|
-
onPartial: (
|
|
1256
|
-
|
|
1659
|
+
onPartial: (g) => {
|
|
1660
|
+
z.value = g || "", _.value = L(y.value, g);
|
|
1257
1661
|
},
|
|
1258
|
-
onResult: (
|
|
1259
|
-
|
|
1260
|
-
|
|
1662
|
+
onResult: (g) => {
|
|
1663
|
+
z.value = g || "", _.value = L(y.value, g), g ? r.success("语音识别完成") : r.warning("未能识别出有效语音,请重试"), setTimeout(() => {
|
|
1664
|
+
z.value = "", V.value && V.value.focus();
|
|
1261
1665
|
}, 100);
|
|
1262
1666
|
},
|
|
1263
|
-
onError: (
|
|
1264
|
-
|
|
1667
|
+
onError: (g) => {
|
|
1668
|
+
r.error(g || "语音输入服务出错"), O();
|
|
1265
1669
|
}
|
|
1266
|
-
})), n),
|
|
1267
|
-
|
|
1268
|
-
|
|
1670
|
+
})), n), w = () => {
|
|
1671
|
+
O(), b.value = 0, P = setInterval(() => {
|
|
1672
|
+
b.value += 1;
|
|
1269
1673
|
}, 1e3);
|
|
1270
|
-
},
|
|
1271
|
-
|
|
1272
|
-
},
|
|
1674
|
+
}, O = () => {
|
|
1675
|
+
P && (clearInterval(P), P = null);
|
|
1676
|
+
}, X = async () => {
|
|
1273
1677
|
if (!o.enableVoiceInput) return;
|
|
1274
|
-
if (
|
|
1275
|
-
await
|
|
1678
|
+
if (f.value) {
|
|
1679
|
+
await Y();
|
|
1276
1680
|
return;
|
|
1277
1681
|
}
|
|
1278
|
-
|
|
1279
|
-
const
|
|
1682
|
+
p.value && U && (U.pause(), p.value = !1);
|
|
1683
|
+
const g = I();
|
|
1280
1684
|
try {
|
|
1281
|
-
|
|
1685
|
+
y.value = _.value, z.value = "", w(), await g.startRecording();
|
|
1282
1686
|
} catch (h) {
|
|
1283
|
-
|
|
1687
|
+
O(), console.error("启动录音失败:", h);
|
|
1284
1688
|
}
|
|
1285
|
-
},
|
|
1286
|
-
|
|
1287
|
-
},
|
|
1288
|
-
o.enableVoiceUpload &&
|
|
1289
|
-
},
|
|
1290
|
-
var
|
|
1689
|
+
}, Y = async () => {
|
|
1690
|
+
O(), n && await n.stopAndTranscribe();
|
|
1691
|
+
}, Z = T(null), ne = () => {
|
|
1692
|
+
o.enableVoiceUpload && Z.value && (Z.value.value = "", Z.value.click());
|
|
1693
|
+
}, q = async (g) => {
|
|
1694
|
+
var te;
|
|
1291
1695
|
if (!o.enableVoiceUpload) return;
|
|
1292
|
-
const h =
|
|
1293
|
-
if (!
|
|
1294
|
-
|
|
1696
|
+
const h = g.target, E = (te = h == null ? void 0 : h.files) == null ? void 0 : te[0];
|
|
1697
|
+
if (!E) return;
|
|
1698
|
+
p.value && U && (U.pause(), p.value = !1);
|
|
1295
1699
|
const B = I();
|
|
1296
1700
|
try {
|
|
1297
|
-
|
|
1298
|
-
} catch (
|
|
1299
|
-
|
|
1701
|
+
y.value = _.value, z.value = "", r.info(`正在流式识别文件: ${E.name}`), await B.transcribeFile(E);
|
|
1702
|
+
} catch (H) {
|
|
1703
|
+
r.error(`文件识别失败: ${H.message || H}`);
|
|
1300
1704
|
}
|
|
1301
|
-
},
|
|
1302
|
-
|
|
1303
|
-
},
|
|
1304
|
-
|
|
1305
|
-
},
|
|
1306
|
-
if (
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1705
|
+
}, oe = () => {
|
|
1706
|
+
O(), z.value = "", _.value = y.value, n && n.cancelRecording();
|
|
1707
|
+
}, fe = () => {
|
|
1708
|
+
z.value = "", _.value = y.value, n && n.cancelTranscribe(), r.info("已取消本次语音识别");
|
|
1709
|
+
}, ke = () => {
|
|
1710
|
+
if (A.value) {
|
|
1711
|
+
if (p.value && U) {
|
|
1712
|
+
U.pause(), p.value = !1;
|
|
1309
1713
|
return;
|
|
1310
1714
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
},
|
|
1314
|
-
|
|
1315
|
-
},
|
|
1316
|
-
|
|
1317
|
-
},
|
|
1318
|
-
|
|
1319
|
-
}).catch((
|
|
1320
|
-
console.error("音频播放出错:",
|
|
1715
|
+
U && (U.pause(), U = null), U = new Audio(A.value), U.onloadedmetadata = () => {
|
|
1716
|
+
U && !isNaN(U.duration) && (F.value = Math.round(U.duration));
|
|
1717
|
+
}, U.onended = () => {
|
|
1718
|
+
p.value = !1;
|
|
1719
|
+
}, U.onerror = () => {
|
|
1720
|
+
p.value = !1, r.error("音频试听播放失败");
|
|
1721
|
+
}, U.play().then(() => {
|
|
1722
|
+
p.value = !0;
|
|
1723
|
+
}).catch((g) => {
|
|
1724
|
+
console.error("音频播放出错:", g), p.value = !1;
|
|
1321
1725
|
});
|
|
1322
1726
|
}
|
|
1323
|
-
},
|
|
1324
|
-
|
|
1727
|
+
}, ae = () => {
|
|
1728
|
+
U && (U.pause(), U = null), p.value = !1, A.value && (URL.revokeObjectURL(A.value), A.value = "");
|
|
1325
1729
|
};
|
|
1326
|
-
|
|
1327
|
-
|
|
1730
|
+
bt(() => {
|
|
1731
|
+
O(), ae(), n && (n.destroy(), n = null);
|
|
1328
1732
|
});
|
|
1329
|
-
const
|
|
1733
|
+
const xe = N(() => Ve.find((g) => g.modelName === o.llmName) ?? Ve.find((g) => g.modelName === "szjy")), j = t, _ = T(""), V = T(null), ie = T(!1), G = T([]), ut = T([
|
|
1330
1734
|
"什么是AI助理,能做什么?",
|
|
1331
1735
|
"当前项目的基本情况?",
|
|
1332
1736
|
"当前项目的进度情况?",
|
|
1333
1737
|
"当前项目的参建方有哪些?",
|
|
1334
1738
|
"数智建管平台有哪些功能?能做什么?"
|
|
1335
|
-
]), le =
|
|
1336
|
-
|
|
1337
|
-
if (
|
|
1338
|
-
const
|
|
1339
|
-
h -
|
|
1739
|
+
]), le = T([]), he = T(!1), Te = T(null), Re = () => {
|
|
1740
|
+
Ye(() => {
|
|
1741
|
+
if (Te.value) {
|
|
1742
|
+
const g = Te.value, h = g.scrollHeight, E = g.scrollTop, B = g.clientHeight;
|
|
1743
|
+
h - E - B < 100 ? g.scrollTop = h : g.scrollTo({
|
|
1340
1744
|
top: h
|
|
1341
1745
|
});
|
|
1342
1746
|
}
|
|
1343
1747
|
});
|
|
1344
|
-
},
|
|
1345
|
-
console.log("onFailedReader",
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1748
|
+
}, se = T(!1), dt = N(() => se.value ? "/images/ai-stop.png" : "/images/ai-send.png"), Ne = (g, h) => {
|
|
1749
|
+
console.log("onFailedReader", g, h), he.value = !1;
|
|
1750
|
+
const E = Fe();
|
|
1751
|
+
E && E.initializeEnd(), r.error("转换失败,请重试"), se.value = !1, setTimeout(() => {
|
|
1752
|
+
V.value && V.value.focus();
|
|
1349
1753
|
});
|
|
1350
|
-
},
|
|
1351
|
-
he.value = !1,
|
|
1352
|
-
|
|
1754
|
+
}, ft = (g, h) => {
|
|
1755
|
+
he.value = !1, se.value = !1, Re(), h && G.value[g] && (G.value[g].displayText = h), setTimeout(() => {
|
|
1756
|
+
V.value && V.value.focus();
|
|
1353
1757
|
});
|
|
1354
|
-
},
|
|
1355
|
-
|
|
1356
|
-
},
|
|
1357
|
-
|
|
1358
|
-
},
|
|
1359
|
-
|
|
1360
|
-
},
|
|
1361
|
-
|
|
1362
|
-
},
|
|
1363
|
-
for (let
|
|
1364
|
-
if (le.value[
|
|
1365
|
-
return le.value[
|
|
1758
|
+
}, ht = (g) => {
|
|
1759
|
+
se.value = !0;
|
|
1760
|
+
}, pt = () => {
|
|
1761
|
+
se.value = !1, j("update:modelValue", !1), ie.value = !1, G.value = [];
|
|
1762
|
+
}, Ue = T(!1), mt = () => {
|
|
1763
|
+
Ue.value = !Ue.value;
|
|
1764
|
+
}, gt = (g) => {
|
|
1765
|
+
_.value = g, _e();
|
|
1766
|
+
}, Fe = () => {
|
|
1767
|
+
for (let g = le.value.length - 1; g >= 0; g--)
|
|
1768
|
+
if (le.value[g])
|
|
1769
|
+
return le.value[g];
|
|
1366
1770
|
return null;
|
|
1367
|
-
},
|
|
1771
|
+
}, _e = async () => {
|
|
1368
1772
|
if (console.log("stylizingLoading:", he.value), he.value) {
|
|
1369
|
-
const
|
|
1370
|
-
console.log("lastPreviewer:",
|
|
1773
|
+
const te = Fe();
|
|
1774
|
+
console.log("lastPreviewer:", te), te && (console.log("abortReader"), te.abortReader());
|
|
1371
1775
|
return;
|
|
1372
1776
|
}
|
|
1373
|
-
if (!
|
|
1374
|
-
console.log("no input, return"),
|
|
1777
|
+
if (!_.value.trim()) {
|
|
1778
|
+
console.log("no input, return"), V.value.focus();
|
|
1375
1779
|
return;
|
|
1376
1780
|
}
|
|
1377
|
-
|
|
1781
|
+
G.value.push({
|
|
1378
1782
|
type: "user",
|
|
1379
|
-
content:
|
|
1380
|
-
}),
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
const h =
|
|
1384
|
-
le.value[h] && le.value[h].initializeStart(), he.value = !0,
|
|
1783
|
+
content: _.value
|
|
1784
|
+
}), se.value = !0, ie.value = !0, j("submit", _.value), Re();
|
|
1785
|
+
const g = _.value;
|
|
1786
|
+
_.value = "";
|
|
1787
|
+
const h = G.value.length;
|
|
1788
|
+
le.value[h] && le.value[h].initializeStart(), he.value = !0, G.value.push({
|
|
1385
1789
|
type: "ai"
|
|
1386
1790
|
});
|
|
1387
|
-
const { error:
|
|
1388
|
-
text:
|
|
1791
|
+
const { error: E, reader: B } = await Vt(xe.value, {
|
|
1792
|
+
text: g,
|
|
1389
1793
|
token: o.token,
|
|
1390
1794
|
identifier: o.identifier,
|
|
1391
1795
|
baseUrl: o.baseUrl,
|
|
1392
|
-
extraConfig
|
|
1796
|
+
// mock 模式(llmName=standard)经 extraConfig 读取 mockResponse,不侵入 API 签名
|
|
1797
|
+
extraConfig: o.mockResponse ? Object.assign({}, o.extraConfig, { mockResponse: o.mockResponse }) : o.extraConfig
|
|
1393
1798
|
});
|
|
1394
|
-
if (
|
|
1395
|
-
console.log(45455,
|
|
1799
|
+
if (E) {
|
|
1800
|
+
console.log(45455, E), Ne(h, E);
|
|
1396
1801
|
return;
|
|
1397
1802
|
}
|
|
1398
|
-
B && (
|
|
1803
|
+
B && (G.value[h].reader = B);
|
|
1399
1804
|
};
|
|
1400
|
-
return (
|
|
1401
|
-
const
|
|
1402
|
-
return
|
|
1805
|
+
return (g, h) => {
|
|
1806
|
+
const E = Me("el-icon"), B = Me("el-button"), te = Me("el-input");
|
|
1807
|
+
return S(), ge(ye, { name: "slide" }, {
|
|
1403
1808
|
default: J(() => [
|
|
1404
|
-
|
|
1809
|
+
e.modelValue ? (S(), x("div", {
|
|
1405
1810
|
key: 0,
|
|
1406
|
-
class:
|
|
1811
|
+
class: re(["ai-panel", { "drawer-mode": Ue.value, "embedded-mode": e.embedded }])
|
|
1407
1812
|
}, [
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1813
|
+
d("div", $n, [
|
|
1814
|
+
d("div", On, [
|
|
1815
|
+
d("div", Nn, W(e.title), 1),
|
|
1816
|
+
d("div", Fn, [
|
|
1817
|
+
e.embedded ? $("", !0) : (S(), ge(E, {
|
|
1413
1818
|
key: 0,
|
|
1414
1819
|
class: "action-icon",
|
|
1415
|
-
onClick:
|
|
1820
|
+
onClick: mt
|
|
1416
1821
|
}, {
|
|
1417
1822
|
default: J(() => [
|
|
1418
|
-
|
|
1823
|
+
D(Ce, {
|
|
1419
1824
|
name: "/images/svg/drawer-layout.svg",
|
|
1420
1825
|
color: "#999999"
|
|
1421
1826
|
})
|
|
1422
1827
|
]),
|
|
1423
1828
|
_: 1
|
|
1424
1829
|
})),
|
|
1425
|
-
|
|
1830
|
+
D(E, {
|
|
1426
1831
|
class: "action-icon",
|
|
1427
|
-
onClick:
|
|
1832
|
+
onClick: pt
|
|
1428
1833
|
}, {
|
|
1429
1834
|
default: J(() => [
|
|
1430
|
-
|
|
1835
|
+
D(Ce, {
|
|
1431
1836
|
name: "/images/svg/close.svg",
|
|
1432
1837
|
color: "#999999"
|
|
1433
1838
|
})
|
|
@@ -1437,129 +1842,132 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
|
|
|
1437
1842
|
])
|
|
1438
1843
|
])
|
|
1439
1844
|
]),
|
|
1440
|
-
|
|
1441
|
-
|
|
1845
|
+
d("div", Bn, [
|
|
1846
|
+
ie.value ? (S(), x("div", {
|
|
1442
1847
|
key: 1,
|
|
1443
1848
|
class: "chat-messages",
|
|
1444
1849
|
ref_key: "messageContainerRef",
|
|
1445
|
-
ref:
|
|
1850
|
+
ref: Te
|
|
1446
1851
|
}, [
|
|
1447
|
-
(
|
|
1852
|
+
(S(!0), x(me, null, Be(G.value, (H, ce) => (S(), x("div", {
|
|
1448
1853
|
key: ce,
|
|
1449
|
-
class:
|
|
1854
|
+
class: re(["message-item", H.type === "user" ? "user-message" : "ai-message"])
|
|
1450
1855
|
}, [
|
|
1451
|
-
|
|
1856
|
+
H.type === "ai" ? (S(), ge(Rn, {
|
|
1452
1857
|
key: 0,
|
|
1453
1858
|
ref_for: !0,
|
|
1454
|
-
ref: (
|
|
1455
|
-
reader:
|
|
1456
|
-
"onUpdate:reader": (
|
|
1859
|
+
ref: (Q) => le.value[ce] = Q,
|
|
1860
|
+
reader: H.reader,
|
|
1861
|
+
"onUpdate:reader": (Q) => H.reader = Q,
|
|
1457
1862
|
model: o.llmName,
|
|
1458
|
-
displayText:
|
|
1459
|
-
scrollToBottomFn:
|
|
1460
|
-
messagePostRender:
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1863
|
+
displayText: H.displayText,
|
|
1864
|
+
scrollToBottomFn: Re,
|
|
1865
|
+
messagePostRender: e.messagePostRender,
|
|
1866
|
+
customUi: e.customUi,
|
|
1867
|
+
uiActionHandler: e.uiActionHandler,
|
|
1868
|
+
onFailed: (Q) => Ne(ce, Q),
|
|
1869
|
+
onCompleted: (Q) => ft(ce, Q),
|
|
1870
|
+
onUpdating: () => ht(),
|
|
1871
|
+
onUiAction: h[0] || (h[0] = (Q) => j("ui-action", Q))
|
|
1872
|
+
}, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "customUi", "uiActionHandler", "onFailed", "onCompleted", "onUpdating"])) : (S(), x("div", Gn, W(H.content), 1))
|
|
1465
1873
|
], 2))), 128))
|
|
1466
|
-
], 512)) : (
|
|
1467
|
-
h[
|
|
1468
|
-
|
|
1469
|
-
src:
|
|
1874
|
+
], 512)) : (S(), x("div", Vn, [
|
|
1875
|
+
h[3] || (h[3] = d("div", { class: "title" }, [
|
|
1876
|
+
d("img", {
|
|
1877
|
+
src: At,
|
|
1470
1878
|
alt: "AI助手",
|
|
1471
1879
|
class: "panel-icon"
|
|
1472
1880
|
}),
|
|
1473
|
-
|
|
1881
|
+
d("h3", { class: "title-text" }, "Hi, 您好")
|
|
1474
1882
|
], -1)),
|
|
1475
|
-
|
|
1476
|
-
h[
|
|
1477
|
-
|
|
1883
|
+
d("div", Hn, [
|
|
1884
|
+
h[2] || (h[2] = pe(" 我是", -1)),
|
|
1885
|
+
d("span", Dn, W(e.title), 1)
|
|
1478
1886
|
]),
|
|
1479
|
-
|
|
1480
|
-
(
|
|
1887
|
+
d("div", qn, [
|
|
1888
|
+
(S(!0), x(me, null, Be(ut.value, (H, ce) => (S(), x("div", {
|
|
1481
1889
|
key: ce,
|
|
1482
1890
|
class: "question-item",
|
|
1483
|
-
onClick: (
|
|
1891
|
+
onClick: (Q) => gt(H)
|
|
1484
1892
|
}, [
|
|
1485
|
-
|
|
1486
|
-
|
|
1893
|
+
d("span", null, W(H), 1),
|
|
1894
|
+
D(E, null, {
|
|
1487
1895
|
default: J(() => [
|
|
1488
|
-
|
|
1896
|
+
D(Ce, {
|
|
1489
1897
|
name: "/images/svg/arrow-right.svg",
|
|
1490
1898
|
color: "#999999"
|
|
1491
1899
|
})
|
|
1492
1900
|
]),
|
|
1493
1901
|
_: 1
|
|
1494
1902
|
})
|
|
1495
|
-
], 8,
|
|
1903
|
+
], 8, Wn))), 128))
|
|
1496
1904
|
])
|
|
1497
1905
|
]))
|
|
1498
1906
|
]),
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1907
|
+
d("div", Jn, [
|
|
1908
|
+
se.value ? (S(), x("img", Kn)) : $("", !0),
|
|
1909
|
+
D(ye, { name: "fade" }, {
|
|
1502
1910
|
default: J(() => [
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
h[
|
|
1506
|
-
|
|
1507
|
-
l.value > 0 ? (
|
|
1911
|
+
m.value || v.value ? (S(), x("div", Xn, [
|
|
1912
|
+
d("div", Yn, [
|
|
1913
|
+
h[4] || (h[4] = d("span", { class: "progress-icon" }, "⏳", -1)),
|
|
1914
|
+
d("span", Zn, W(i.value), 1),
|
|
1915
|
+
l.value > 0 ? (S(), x("span", Qn, W(l.value) + "%", 1)) : $("", !0)
|
|
1508
1916
|
]),
|
|
1509
|
-
l.value > 0 ? (
|
|
1510
|
-
|
|
1917
|
+
l.value > 0 ? (S(), x("div", er, [
|
|
1918
|
+
d("div", {
|
|
1511
1919
|
class: "progress-bar",
|
|
1512
1920
|
style: ue({ width: l.value + "%" })
|
|
1513
1921
|
}, null, 4)
|
|
1514
|
-
])) :
|
|
1515
|
-
])) :
|
|
1922
|
+
])) : $("", !0)
|
|
1923
|
+
])) : $("", !0)
|
|
1516
1924
|
]),
|
|
1517
1925
|
_: 1
|
|
1518
1926
|
}),
|
|
1519
|
-
|
|
1927
|
+
D(ye, { name: "fade" }, {
|
|
1520
1928
|
default: J(() => [
|
|
1521
|
-
|
|
1929
|
+
f.value || u.value ? (S(), x("div", {
|
|
1522
1930
|
key: 0,
|
|
1523
|
-
class:
|
|
1931
|
+
class: re(["voice-recording-panel", { "has-transcript": u.value }])
|
|
1524
1932
|
}, [
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
class:
|
|
1933
|
+
d("div", tr, [
|
|
1934
|
+
d("div", nr, [
|
|
1935
|
+
d("span", {
|
|
1936
|
+
class: re(["recording-pulse", { transcribing: u.value }])
|
|
1529
1937
|
}, null, 2),
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1938
|
+
f.value ? (S(), x("span", rr, W(R(b.value)), 1)) : $("", !0),
|
|
1939
|
+
d("span", sr, W(k.value), 1),
|
|
1940
|
+
f.value ? (S(), x("div", or, [
|
|
1941
|
+
d("span", {
|
|
1534
1942
|
class: "wave",
|
|
1535
|
-
style: ue({ height: Math.max(4, Math.min(22,
|
|
1943
|
+
style: ue({ height: Math.max(4, Math.min(22, c.value * 0.3)) + "px" })
|
|
1536
1944
|
}, null, 4),
|
|
1537
|
-
|
|
1945
|
+
d("span", {
|
|
1538
1946
|
class: "wave",
|
|
1539
|
-
style: ue({ height: Math.max(4, Math.min(30,
|
|
1947
|
+
style: ue({ height: Math.max(4, Math.min(30, c.value * 0.5)) + "px" })
|
|
1540
1948
|
}, null, 4),
|
|
1541
|
-
|
|
1949
|
+
d("span", {
|
|
1542
1950
|
class: "wave",
|
|
1543
|
-
style: ue({ height: Math.max(4, Math.min(18,
|
|
1951
|
+
style: ue({ height: Math.max(4, Math.min(18, c.value * 0.25)) + "px" })
|
|
1544
1952
|
}, null, 4)
|
|
1545
|
-
])) :
|
|
1953
|
+
])) : $("", !0)
|
|
1546
1954
|
]),
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1955
|
+
d("div", ar, [
|
|
1956
|
+
f.value ? (S(), x(me, { key: 0 }, [
|
|
1957
|
+
D(B, {
|
|
1550
1958
|
size: "small",
|
|
1551
1959
|
circle: "",
|
|
1552
|
-
onClick:
|
|
1960
|
+
onClick: oe,
|
|
1553
1961
|
title: "取消录音",
|
|
1554
1962
|
class: "voice-cancel-btn"
|
|
1555
1963
|
}, {
|
|
1556
|
-
default: J(() => [...h[
|
|
1557
|
-
|
|
1964
|
+
default: J(() => [...h[5] || (h[5] = [
|
|
1965
|
+
d("svg", {
|
|
1558
1966
|
viewBox: "0 0 1024 1024",
|
|
1559
1967
|
width: "12",
|
|
1560
1968
|
height: "12"
|
|
1561
1969
|
}, [
|
|
1562
|
-
|
|
1970
|
+
d("path", {
|
|
1563
1971
|
d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
|
|
1564
1972
|
fill: "currentColor"
|
|
1565
1973
|
})
|
|
@@ -1567,111 +1975,111 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
|
|
|
1567
1975
|
])]),
|
|
1568
1976
|
_: 1
|
|
1569
1977
|
}),
|
|
1570
|
-
|
|
1978
|
+
D(B, {
|
|
1571
1979
|
type: "primary",
|
|
1572
1980
|
size: "small",
|
|
1573
1981
|
round: "",
|
|
1574
|
-
onClick:
|
|
1982
|
+
onClick: Y,
|
|
1575
1983
|
class: "voice-finish-btn"
|
|
1576
1984
|
}, {
|
|
1577
|
-
default: J(() => [...h[
|
|
1578
|
-
|
|
1985
|
+
default: J(() => [...h[6] || (h[6] = [
|
|
1986
|
+
pe(" 完成 ", -1)
|
|
1579
1987
|
])]),
|
|
1580
1988
|
_: 1
|
|
1581
1989
|
})
|
|
1582
|
-
], 64)) :
|
|
1990
|
+
], 64)) : u.value ? (S(), ge(B, {
|
|
1583
1991
|
key: 1,
|
|
1584
1992
|
size: "small",
|
|
1585
1993
|
round: "",
|
|
1586
|
-
onClick:
|
|
1994
|
+
onClick: fe,
|
|
1587
1995
|
class: "voice-cancel-transcribe-btn"
|
|
1588
1996
|
}, {
|
|
1589
|
-
default: J(() => [...h[
|
|
1590
|
-
|
|
1997
|
+
default: J(() => [...h[7] || (h[7] = [
|
|
1998
|
+
pe(" 取消识别 ", -1)
|
|
1591
1999
|
])]),
|
|
1592
2000
|
_: 1
|
|
1593
|
-
})) :
|
|
2001
|
+
})) : $("", !0)
|
|
1594
2002
|
])
|
|
1595
2003
|
]),
|
|
1596
|
-
|
|
2004
|
+
u.value ? (S(), x("div", {
|
|
1597
2005
|
key: 0,
|
|
1598
|
-
class:
|
|
1599
|
-
title:
|
|
2006
|
+
class: re(["live-transcript", { empty: !z.value }]),
|
|
2007
|
+
title: z.value
|
|
1600
2008
|
}, [
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
h[
|
|
1604
|
-
], 64)) : (
|
|
1605
|
-
|
|
2009
|
+
z.value ? (S(), x(me, { key: 0 }, [
|
|
2010
|
+
pe(W(z.value), 1),
|
|
2011
|
+
h[8] || (h[8] = d("span", { class: "caret" }, "|", -1))
|
|
2012
|
+
], 64)) : (S(), x(me, { key: 1 }, [
|
|
2013
|
+
pe("正在识别,文字将实时显示...")
|
|
1606
2014
|
], 64))
|
|
1607
|
-
], 10,
|
|
1608
|
-
], 2)) :
|
|
2015
|
+
], 10, ir)) : $("", !0)
|
|
2016
|
+
], 2)) : $("", !0)
|
|
1609
2017
|
]),
|
|
1610
2018
|
_: 1
|
|
1611
2019
|
}),
|
|
1612
|
-
|
|
2020
|
+
D(ye, { name: "fade" }, {
|
|
1613
2021
|
default: J(() => [
|
|
1614
|
-
|
|
1615
|
-
|
|
2022
|
+
A.value && !f.value && !u.value ? (S(), x("div", lr, [
|
|
2023
|
+
d("div", {
|
|
1616
2024
|
class: "playback-main",
|
|
1617
|
-
onClick:
|
|
1618
|
-
title:
|
|
2025
|
+
onClick: ke,
|
|
2026
|
+
title: p.value ? "点击暂停" : "点击播放录音"
|
|
1619
2027
|
}, [
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
])])) : (
|
|
1624
|
-
|
|
2028
|
+
d("div", ur, [
|
|
2029
|
+
p.value ? (S(), x("svg", fr, [...h[10] || (h[10] = [
|
|
2030
|
+
d("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }, null, -1)
|
|
2031
|
+
])])) : (S(), x("svg", dr, [...h[9] || (h[9] = [
|
|
2032
|
+
d("path", { d: "M8 5v14l11-7z" }, null, -1)
|
|
1625
2033
|
])]))
|
|
1626
2034
|
]),
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
])])) :
|
|
1635
|
-
], 8,
|
|
1636
|
-
|
|
2035
|
+
d("span", hr, W(p.value ? "正在播放录音..." : "点击试听本次录音"), 1),
|
|
2036
|
+
F.value > 0 ? (S(), x("span", pr, W(R(F.value)), 1)) : $("", !0),
|
|
2037
|
+
p.value ? (S(), x("div", mr, [...h[11] || (h[11] = [
|
|
2038
|
+
d("span", { class: "wave-bar" }, null, -1),
|
|
2039
|
+
d("span", { class: "wave-bar" }, null, -1),
|
|
2040
|
+
d("span", { class: "wave-bar" }, null, -1),
|
|
2041
|
+
d("span", { class: "wave-bar" }, null, -1)
|
|
2042
|
+
])])) : $("", !0)
|
|
2043
|
+
], 8, cr),
|
|
2044
|
+
d("div", {
|
|
1637
2045
|
class: "playback-close",
|
|
1638
|
-
onClick:
|
|
2046
|
+
onClick: ae,
|
|
1639
2047
|
title: "清除试听"
|
|
1640
|
-
}, [...h[
|
|
1641
|
-
|
|
2048
|
+
}, [...h[12] || (h[12] = [
|
|
2049
|
+
d("svg", {
|
|
1642
2050
|
viewBox: "0 0 1024 1024",
|
|
1643
2051
|
width: "12",
|
|
1644
2052
|
height: "12"
|
|
1645
2053
|
}, [
|
|
1646
|
-
|
|
2054
|
+
d("path", {
|
|
1647
2055
|
d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
|
|
1648
2056
|
fill: "currentColor"
|
|
1649
2057
|
})
|
|
1650
2058
|
], -1)
|
|
1651
2059
|
])])
|
|
1652
|
-
])) :
|
|
2060
|
+
])) : $("", !0)
|
|
1653
2061
|
]),
|
|
1654
2062
|
_: 1
|
|
1655
2063
|
}),
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
modelValue:
|
|
1659
|
-
"onUpdate:modelValue": h[
|
|
2064
|
+
Ke(d("div", gr, [
|
|
2065
|
+
D(te, {
|
|
2066
|
+
modelValue: _.value,
|
|
2067
|
+
"onUpdate:modelValue": h[1] || (h[1] = (H) => _.value = H),
|
|
1660
2068
|
ref_key: "refInputTextString",
|
|
1661
|
-
ref:
|
|
1662
|
-
placeholder:
|
|
2069
|
+
ref: V,
|
|
2070
|
+
placeholder: C.value,
|
|
1663
2071
|
autofocus: "",
|
|
1664
|
-
onKeyup:
|
|
2072
|
+
onKeyup: kt(_e, ["enter"])
|
|
1665
2073
|
}, {
|
|
1666
2074
|
append: J(() => [
|
|
1667
|
-
|
|
1668
|
-
|
|
2075
|
+
d("div", yr, [
|
|
2076
|
+
e.enableVoiceUpload ? (S(), x("div", {
|
|
1669
2077
|
key: 0,
|
|
1670
2078
|
class: "voice-upload-btn",
|
|
1671
|
-
onClick:
|
|
2079
|
+
onClick: ne,
|
|
1672
2080
|
title: "上传音频/视频文件识别 (支持 .wav, .mp4, .mp3, .m4a)"
|
|
1673
|
-
}, [...h[
|
|
1674
|
-
|
|
2081
|
+
}, [...h[13] || (h[13] = [
|
|
2082
|
+
d("svg", {
|
|
1675
2083
|
viewBox: "0 0 24 24",
|
|
1676
2084
|
width: "17",
|
|
1677
2085
|
height: "17",
|
|
@@ -1681,32 +2089,32 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
|
|
|
1681
2089
|
"stroke-linecap": "round",
|
|
1682
2090
|
"stroke-linejoin": "round"
|
|
1683
2091
|
}, [
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
2092
|
+
d("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
2093
|
+
d("polyline", { points: "17 8 12 3 7 8" }),
|
|
2094
|
+
d("line", {
|
|
1687
2095
|
x1: "12",
|
|
1688
2096
|
y1: "3",
|
|
1689
2097
|
x2: "12",
|
|
1690
2098
|
y2: "15"
|
|
1691
2099
|
})
|
|
1692
2100
|
], -1)
|
|
1693
|
-
])])) :
|
|
1694
|
-
|
|
2101
|
+
])])) : $("", !0),
|
|
2102
|
+
e.enableVoiceUpload ? (S(), x("input", {
|
|
1695
2103
|
key: 1,
|
|
1696
2104
|
type: "file",
|
|
1697
2105
|
ref_key: "refAudioFileInput",
|
|
1698
|
-
ref:
|
|
2106
|
+
ref: Z,
|
|
1699
2107
|
accept: "audio/*,video/mp4,.wav,.mp4,.mp3,.m4a",
|
|
1700
2108
|
style: { display: "none" },
|
|
1701
|
-
onChange:
|
|
1702
|
-
}, null, 544)) :
|
|
1703
|
-
|
|
2109
|
+
onChange: q
|
|
2110
|
+
}, null, 544)) : $("", !0),
|
|
2111
|
+
e.enableVoiceInput ? (S(), x("div", {
|
|
1704
2112
|
key: 2,
|
|
1705
|
-
class:
|
|
1706
|
-
onClick:
|
|
2113
|
+
class: re(["voice-mic-btn", { "loading-anim": m.value || v.value }]),
|
|
2114
|
+
onClick: X,
|
|
1707
2115
|
title: "语音输入"
|
|
1708
|
-
}, [...h[
|
|
1709
|
-
|
|
2116
|
+
}, [...h[14] || (h[14] = [
|
|
2117
|
+
d("svg", {
|
|
1710
2118
|
viewBox: "0 0 24 24",
|
|
1711
2119
|
width: "18",
|
|
1712
2120
|
height: "18",
|
|
@@ -1716,261 +2124,261 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
|
|
|
1716
2124
|
"stroke-linecap": "round",
|
|
1717
2125
|
"stroke-linejoin": "round"
|
|
1718
2126
|
}, [
|
|
1719
|
-
|
|
2127
|
+
d("path", {
|
|
1720
2128
|
d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",
|
|
1721
2129
|
fill: "currentColor",
|
|
1722
2130
|
opacity: "0.2"
|
|
1723
2131
|
}),
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
2132
|
+
d("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }),
|
|
2133
|
+
d("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
|
|
2134
|
+
d("line", {
|
|
1727
2135
|
x1: "12",
|
|
1728
2136
|
y1: "19",
|
|
1729
2137
|
x2: "12",
|
|
1730
2138
|
y2: "22"
|
|
1731
2139
|
})
|
|
1732
2140
|
], -1)
|
|
1733
|
-
])], 2)) :
|
|
1734
|
-
|
|
2141
|
+
])], 2)) : $("", !0),
|
|
2142
|
+
d("div", {
|
|
1735
2143
|
class: "send-icon-box",
|
|
1736
|
-
onClick:
|
|
2144
|
+
onClick: _e
|
|
1737
2145
|
}, [
|
|
1738
|
-
|
|
1739
|
-
src:
|
|
2146
|
+
d("img", {
|
|
2147
|
+
src: dt.value,
|
|
1740
2148
|
alt: "发送",
|
|
1741
2149
|
class: "send-icon"
|
|
1742
|
-
}, null, 8,
|
|
2150
|
+
}, null, 8, vr)
|
|
1743
2151
|
])
|
|
1744
2152
|
])
|
|
1745
2153
|
]),
|
|
1746
2154
|
_: 1
|
|
1747
2155
|
}, 8, ["modelValue", "placeholder"])
|
|
1748
2156
|
], 512), [
|
|
1749
|
-
[
|
|
2157
|
+
[Xe, !f.value && !u.value]
|
|
1750
2158
|
])
|
|
1751
2159
|
])
|
|
1752
|
-
], 2)) :
|
|
2160
|
+
], 2)) : $("", !0)
|
|
1753
2161
|
]),
|
|
1754
2162
|
_: 1
|
|
1755
2163
|
});
|
|
1756
2164
|
};
|
|
1757
2165
|
}
|
|
1758
2166
|
};
|
|
1759
|
-
var
|
|
1760
|
-
(function(
|
|
1761
|
-
(function(
|
|
1762
|
-
|
|
2167
|
+
var lt = { exports: {} };
|
|
2168
|
+
(function(e, t) {
|
|
2169
|
+
(function(s, r) {
|
|
2170
|
+
e.exports = r();
|
|
1763
2171
|
})(window, function() {
|
|
1764
|
-
return function(
|
|
1765
|
-
var
|
|
2172
|
+
return function(s) {
|
|
2173
|
+
var r = {};
|
|
1766
2174
|
function o(n) {
|
|
1767
|
-
if (
|
|
1768
|
-
var
|
|
1769
|
-
return
|
|
2175
|
+
if (r[n]) return r[n].exports;
|
|
2176
|
+
var a = r[n] = { i: n, l: !1, exports: {} };
|
|
2177
|
+
return s[n].call(a.exports, a, a.exports, o), a.l = !0, a.exports;
|
|
1770
2178
|
}
|
|
1771
|
-
return o.m =
|
|
1772
|
-
o.o(n,
|
|
2179
|
+
return o.m = s, o.c = r, o.d = function(n, a, i) {
|
|
2180
|
+
o.o(n, a) || Object.defineProperty(n, a, { enumerable: !0, get: i });
|
|
1773
2181
|
}, o.r = function(n) {
|
|
1774
2182
|
typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(n, "__esModule", { value: !0 });
|
|
1775
|
-
}, o.t = function(n,
|
|
1776
|
-
if (1 &
|
|
2183
|
+
}, o.t = function(n, a) {
|
|
2184
|
+
if (1 & a && (n = o(n)), 8 & a || 4 & a && typeof n == "object" && n && n.__esModule) return n;
|
|
1777
2185
|
var i = /* @__PURE__ */ Object.create(null);
|
|
1778
|
-
if (o.r(i), Object.defineProperty(i, "default", { enumerable: !0, value: n }), 2 &
|
|
1779
|
-
return n[
|
|
2186
|
+
if (o.r(i), Object.defineProperty(i, "default", { enumerable: !0, value: n }), 2 & a && typeof n != "string") for (var l in n) o.d(i, l, (function(c) {
|
|
2187
|
+
return n[c];
|
|
1780
2188
|
}).bind(null, l));
|
|
1781
2189
|
return i;
|
|
1782
2190
|
}, o.n = function(n) {
|
|
1783
|
-
var
|
|
2191
|
+
var a = n && n.__esModule ? function() {
|
|
1784
2192
|
return n.default;
|
|
1785
2193
|
} : function() {
|
|
1786
2194
|
return n;
|
|
1787
2195
|
};
|
|
1788
|
-
return o.d(
|
|
1789
|
-
}, o.o = function(n,
|
|
1790
|
-
return Object.prototype.hasOwnProperty.call(n,
|
|
2196
|
+
return o.d(a, "a", a), a;
|
|
2197
|
+
}, o.o = function(n, a) {
|
|
2198
|
+
return Object.prototype.hasOwnProperty.call(n, a);
|
|
1791
2199
|
}, o.p = "", o(o.s = 0);
|
|
1792
|
-
}([function(
|
|
1793
|
-
function n(
|
|
1794
|
-
|
|
2200
|
+
}([function(s, r, o) {
|
|
2201
|
+
function n(y, m, v, f) {
|
|
2202
|
+
v.push(y), f.push([].concat(m[y] || []));
|
|
1795
2203
|
}
|
|
1796
|
-
function
|
|
1797
|
-
if (!
|
|
1798
|
-
var
|
|
1799
|
-
for (n(
|
|
1800
|
-
var k =
|
|
2204
|
+
function a(y, m) {
|
|
2205
|
+
if (!y) throw new Error("[getMaxDepsChain] dep 参数不能为空");
|
|
2206
|
+
var v = [], f = [], u = [];
|
|
2207
|
+
for (n(y, m, f, u); f.length; ) {
|
|
2208
|
+
var k = u.pop();
|
|
1801
2209
|
if (k && k.length) {
|
|
1802
|
-
var
|
|
1803
|
-
if (
|
|
1804
|
-
n(
|
|
1805
|
-
} else
|
|
2210
|
+
var C = k.shift();
|
|
2211
|
+
if (u.push(k), ~f.indexOf(C)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + C + ", mainStack: " + f);
|
|
2212
|
+
n(C, m, f, u);
|
|
2213
|
+
} else v.push([].concat(f)), f.pop();
|
|
1806
2214
|
}
|
|
1807
|
-
return
|
|
1808
|
-
return
|
|
2215
|
+
return v.reduce(function(L, R) {
|
|
2216
|
+
return R.length > L.length ? R : L;
|
|
1809
2217
|
}, []);
|
|
1810
2218
|
}
|
|
1811
|
-
function i(
|
|
1812
|
-
if (!
|
|
1813
|
-
var
|
|
1814
|
-
|
|
1815
|
-
|
|
2219
|
+
function i(y) {
|
|
2220
|
+
if (!y) throw new Error("[depsParser] 入参不能为空");
|
|
2221
|
+
var m = {};
|
|
2222
|
+
y.forEach(function(f) {
|
|
2223
|
+
m[f.name] = f.deps || [];
|
|
1816
2224
|
});
|
|
1817
|
-
var
|
|
1818
|
-
return
|
|
1819
|
-
var
|
|
1820
|
-
|
|
1821
|
-
}),
|
|
2225
|
+
var v = [];
|
|
2226
|
+
return y.forEach(function(f) {
|
|
2227
|
+
var u = a(f.name, m).length - 1;
|
|
2228
|
+
f.priority = u, v[u] = (v[u] || []).concat(f);
|
|
2229
|
+
}), v;
|
|
1822
2230
|
}
|
|
1823
|
-
o.r(
|
|
1824
|
-
return
|
|
1825
|
-
}), o.d(
|
|
1826
|
-
return
|
|
1827
|
-
}), o.d(
|
|
1828
|
-
return
|
|
1829
|
-
}), o.d(
|
|
1830
|
-
return
|
|
1831
|
-
}), o.d(
|
|
1832
|
-
return
|
|
1833
|
-
}), o.d(
|
|
1834
|
-
return
|
|
1835
|
-
}), o.d(
|
|
2231
|
+
o.r(r), o.d(r, "loadScript", function() {
|
|
2232
|
+
return A;
|
|
2233
|
+
}), o.d(r, "loadScripts", function() {
|
|
2234
|
+
return p;
|
|
2235
|
+
}), o.d(r, "dynamicLoadScripts", function() {
|
|
2236
|
+
return F;
|
|
2237
|
+
}), o.d(r, "createScriptsLoadIterator", function() {
|
|
2238
|
+
return U;
|
|
2239
|
+
}), o.d(r, "loadScriptsQueue", function() {
|
|
2240
|
+
return z;
|
|
2241
|
+
}), o.d(r, "getMaxDepsChain", function() {
|
|
2242
|
+
return a;
|
|
2243
|
+
}), o.d(r, "depsParser", function() {
|
|
1836
2244
|
return i;
|
|
1837
2245
|
});
|
|
1838
2246
|
var l = function() {
|
|
1839
|
-
return (l = Object.assign || function(
|
|
1840
|
-
for (var
|
|
1841
|
-
return
|
|
2247
|
+
return (l = Object.assign || function(y) {
|
|
2248
|
+
for (var m, v = 1, f = arguments.length; v < f; v++) for (var u in m = arguments[v]) Object.prototype.hasOwnProperty.call(m, u) && (y[u] = m[u]);
|
|
2249
|
+
return y;
|
|
1842
2250
|
}).apply(this, arguments);
|
|
1843
|
-
},
|
|
1844
|
-
return new (
|
|
1845
|
-
function
|
|
2251
|
+
}, c = function(y, m, v, f) {
|
|
2252
|
+
return new (v || (v = Promise))(function(u, k) {
|
|
2253
|
+
function C(I) {
|
|
1846
2254
|
try {
|
|
1847
|
-
|
|
1848
|
-
} catch (
|
|
1849
|
-
k(
|
|
2255
|
+
R(f.next(I));
|
|
2256
|
+
} catch (w) {
|
|
2257
|
+
k(w);
|
|
1850
2258
|
}
|
|
1851
2259
|
}
|
|
1852
2260
|
function L(I) {
|
|
1853
2261
|
try {
|
|
1854
|
-
|
|
1855
|
-
} catch (
|
|
1856
|
-
k(
|
|
2262
|
+
R(f.throw(I));
|
|
2263
|
+
} catch (w) {
|
|
2264
|
+
k(w);
|
|
1857
2265
|
}
|
|
1858
2266
|
}
|
|
1859
|
-
function
|
|
1860
|
-
var
|
|
1861
|
-
I.done ?
|
|
1862
|
-
|
|
1863
|
-
})).then(
|
|
2267
|
+
function R(I) {
|
|
2268
|
+
var w;
|
|
2269
|
+
I.done ? u(I.value) : (w = I.value, w instanceof v ? w : new v(function(O) {
|
|
2270
|
+
O(w);
|
|
2271
|
+
})).then(C, L);
|
|
1864
2272
|
}
|
|
1865
|
-
|
|
2273
|
+
R((f = f.apply(y, [])).next());
|
|
1866
2274
|
});
|
|
1867
|
-
},
|
|
1868
|
-
var
|
|
1869
|
-
if (1 &
|
|
1870
|
-
return
|
|
2275
|
+
}, b = function(y, m) {
|
|
2276
|
+
var v, f, u, k, C = { label: 0, sent: function() {
|
|
2277
|
+
if (1 & u[0]) throw u[1];
|
|
2278
|
+
return u[1];
|
|
1871
2279
|
}, trys: [], ops: [] };
|
|
1872
2280
|
return k = { next: L(0), throw: L(1), return: L(2) }, typeof Symbol == "function" && (k[Symbol.iterator] = function() {
|
|
1873
2281
|
return this;
|
|
1874
2282
|
}), k;
|
|
1875
|
-
function L(
|
|
2283
|
+
function L(R) {
|
|
1876
2284
|
return function(I) {
|
|
1877
|
-
return function(
|
|
1878
|
-
if (
|
|
1879
|
-
for (;
|
|
1880
|
-
if (
|
|
1881
|
-
switch (
|
|
2285
|
+
return function(w) {
|
|
2286
|
+
if (v) throw new TypeError("Generator is already executing.");
|
|
2287
|
+
for (; C; ) try {
|
|
2288
|
+
if (v = 1, f && (u = 2 & w[0] ? f.return : w[0] ? f.throw || ((u = f.return) && u.call(f), 0) : f.next) && !(u = u.call(f, w[1])).done) return u;
|
|
2289
|
+
switch (f = 0, u && (w = [2 & w[0], u.value]), w[0]) {
|
|
1882
2290
|
case 0:
|
|
1883
2291
|
case 1:
|
|
1884
|
-
|
|
2292
|
+
u = w;
|
|
1885
2293
|
break;
|
|
1886
2294
|
case 4:
|
|
1887
|
-
return
|
|
2295
|
+
return C.label++, { value: w[1], done: !1 };
|
|
1888
2296
|
case 5:
|
|
1889
|
-
|
|
2297
|
+
C.label++, f = w[1], w = [0];
|
|
1890
2298
|
continue;
|
|
1891
2299
|
case 7:
|
|
1892
|
-
|
|
2300
|
+
w = C.ops.pop(), C.trys.pop();
|
|
1893
2301
|
continue;
|
|
1894
2302
|
default:
|
|
1895
|
-
if (
|
|
1896
|
-
|
|
2303
|
+
if (u = C.trys, !((u = u.length > 0 && u[u.length - 1]) || w[0] !== 6 && w[0] !== 2)) {
|
|
2304
|
+
C = 0;
|
|
1897
2305
|
continue;
|
|
1898
2306
|
}
|
|
1899
|
-
if (
|
|
1900
|
-
|
|
2307
|
+
if (w[0] === 3 && (!u || w[1] > u[0] && w[1] < u[3])) {
|
|
2308
|
+
C.label = w[1];
|
|
1901
2309
|
break;
|
|
1902
2310
|
}
|
|
1903
|
-
if (
|
|
1904
|
-
|
|
2311
|
+
if (w[0] === 6 && C.label < u[1]) {
|
|
2312
|
+
C.label = u[1], u = w;
|
|
1905
2313
|
break;
|
|
1906
2314
|
}
|
|
1907
|
-
if (
|
|
1908
|
-
|
|
2315
|
+
if (u && C.label < u[2]) {
|
|
2316
|
+
C.label = u[2], C.ops.push(w);
|
|
1909
2317
|
break;
|
|
1910
2318
|
}
|
|
1911
|
-
|
|
2319
|
+
u[2] && C.ops.pop(), C.trys.pop();
|
|
1912
2320
|
continue;
|
|
1913
2321
|
}
|
|
1914
|
-
|
|
1915
|
-
} catch (
|
|
1916
|
-
|
|
2322
|
+
w = m.call(y, C);
|
|
2323
|
+
} catch (O) {
|
|
2324
|
+
w = [6, O], f = 0;
|
|
1917
2325
|
} finally {
|
|
1918
|
-
|
|
2326
|
+
v = u = 0;
|
|
1919
2327
|
}
|
|
1920
|
-
if (5 &
|
|
1921
|
-
return { value:
|
|
1922
|
-
}([
|
|
2328
|
+
if (5 & w[0]) throw w[1];
|
|
2329
|
+
return { value: w[0] ? w[1] : void 0, done: !0 };
|
|
2330
|
+
}([R, I]);
|
|
1923
2331
|
};
|
|
1924
2332
|
}
|
|
1925
|
-
},
|
|
2333
|
+
}, P = function(y) {
|
|
1926
2334
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1927
|
-
var
|
|
1928
|
-
return
|
|
2335
|
+
var m, v = y[Symbol.asyncIterator];
|
|
2336
|
+
return v ? v.call(y) : (y = typeof __values == "function" ? __values(y) : y[Symbol.iterator](), m = {}, f("next"), f("throw"), f("return"), m[Symbol.asyncIterator] = function() {
|
|
1929
2337
|
return this;
|
|
1930
|
-
},
|
|
1931
|
-
function
|
|
1932
|
-
|
|
1933
|
-
return new Promise(function(
|
|
1934
|
-
(function(
|
|
1935
|
-
Promise.resolve(
|
|
1936
|
-
|
|
2338
|
+
}, m);
|
|
2339
|
+
function f(u) {
|
|
2340
|
+
m[u] = y[u] && function(k) {
|
|
2341
|
+
return new Promise(function(C, L) {
|
|
2342
|
+
(function(R, I, w, O) {
|
|
2343
|
+
Promise.resolve(O).then(function(X) {
|
|
2344
|
+
R({ value: X, done: w });
|
|
1937
2345
|
}, I);
|
|
1938
|
-
})(
|
|
2346
|
+
})(C, L, (k = y[u](k)).done, k.value);
|
|
1939
2347
|
});
|
|
1940
2348
|
};
|
|
1941
2349
|
}
|
|
1942
2350
|
};
|
|
1943
|
-
function
|
|
1944
|
-
return
|
|
1945
|
-
var
|
|
1946
|
-
k.type = "text/javascript", k.src =
|
|
2351
|
+
function A(y, m) {
|
|
2352
|
+
return m === void 0 && (m = !1), new Promise(function(v, f) {
|
|
2353
|
+
var u = m ? document.head : document.body, k = document.createElement("script");
|
|
2354
|
+
k.type = "text/javascript", k.src = y, k.crossOrigin = "anonymous", k.onreadystatechange = v, k.onload = v, k.onerror = f, u.appendChild(k);
|
|
1947
2355
|
});
|
|
1948
2356
|
}
|
|
1949
|
-
var
|
|
1950
|
-
return
|
|
1951
|
-
var
|
|
1952
|
-
return
|
|
2357
|
+
var p = function(y, m) {
|
|
2358
|
+
return m === void 0 && (m = {}), c(void 0, void 0, void 0, function() {
|
|
2359
|
+
var v, f, u, k, C;
|
|
2360
|
+
return b(this, function(L) {
|
|
1953
2361
|
switch (L.label) {
|
|
1954
2362
|
case 0:
|
|
1955
|
-
return
|
|
1956
|
-
return
|
|
1957
|
-
var I,
|
|
1958
|
-
return
|
|
1959
|
-
switch (
|
|
2363
|
+
return v = m.baseUrl, f = v === void 0 ? "" : v, u = m.lastLoadResult, k = m.inHead, C = k !== void 0 && k, [4, Promise.all(y.map(function(R) {
|
|
2364
|
+
return c(void 0, void 0, void 0, function() {
|
|
2365
|
+
var I, w, O, X, Y, Z, ne, q;
|
|
2366
|
+
return b(this, function(oe) {
|
|
2367
|
+
switch (oe.label) {
|
|
1960
2368
|
case 0:
|
|
1961
|
-
return I =
|
|
2369
|
+
return I = R.name, w = R.path, O = R.deps, (ne = {})[I] = !0, X = ne, (q = {})[I] = !1, Y = q, window[I] ? [2, X] : [3, 1];
|
|
1962
2370
|
case 1:
|
|
1963
|
-
return
|
|
1964
|
-
|
|
1965
|
-
}),
|
|
1966
|
-
return K;
|
|
1967
|
-
}).catch(function() {
|
|
2371
|
+
return Z = !0, O && u && [].concat(O).forEach(function(fe) {
|
|
2372
|
+
u[fe] !== !1 && (Z = !0);
|
|
2373
|
+
}), Z ? [4, A(w.indexOf("http") === 0 || w.indexOf("//:") === 0 ? w : f + w, C).then(function() {
|
|
1968
2374
|
return X;
|
|
2375
|
+
}).catch(function() {
|
|
2376
|
+
return Y;
|
|
1969
2377
|
})] : [3, 3];
|
|
1970
2378
|
case 2:
|
|
1971
|
-
return [2,
|
|
2379
|
+
return [2, oe.sent()];
|
|
1972
2380
|
case 3:
|
|
1973
|
-
return [2,
|
|
2381
|
+
return [2, Y];
|
|
1974
2382
|
}
|
|
1975
2383
|
});
|
|
1976
2384
|
});
|
|
@@ -1980,65 +2388,65 @@ var Ye = { exports: {} };
|
|
|
1980
2388
|
}
|
|
1981
2389
|
});
|
|
1982
2390
|
});
|
|
1983
|
-
},
|
|
1984
|
-
return
|
|
1985
|
-
var
|
|
2391
|
+
}, F = function(y, m) {
|
|
2392
|
+
return m === void 0 && (m = {}), function() {
|
|
2393
|
+
var v = [].concat(i(y));
|
|
1986
2394
|
return { next: function() {
|
|
1987
|
-
if (
|
|
1988
|
-
var
|
|
1989
|
-
return
|
|
1990
|
-
return { value:
|
|
2395
|
+
if (v.length) {
|
|
2396
|
+
var f = v.shift();
|
|
2397
|
+
return p(f, m).then(function(u) {
|
|
2398
|
+
return { value: u, done: !1 };
|
|
1991
2399
|
});
|
|
1992
2400
|
}
|
|
1993
2401
|
return Promise.resolve({ done: !0 });
|
|
1994
2402
|
} };
|
|
1995
2403
|
};
|
|
1996
|
-
},
|
|
1997
|
-
var
|
|
1998
|
-
return
|
|
1999
|
-
},
|
|
2000
|
-
return
|
|
2001
|
-
var
|
|
2002
|
-
return
|
|
2003
|
-
switch (
|
|
2404
|
+
}, U = function(y, m) {
|
|
2405
|
+
var v;
|
|
2406
|
+
return m === void 0 && (m = {}), (v = {})[Symbol.asyncIterator] = F(y, m), v;
|
|
2407
|
+
}, z = function(y, m) {
|
|
2408
|
+
return m === void 0 && (m = {}), c(void 0, void 0, void 0, function() {
|
|
2409
|
+
var v, f, u, k, C, L;
|
|
2410
|
+
return b(this, function(R) {
|
|
2411
|
+
switch (R.label) {
|
|
2004
2412
|
case 0:
|
|
2005
|
-
|
|
2413
|
+
R.trys.push([0, 5, 6, 11]), v = P(U(y, m)), R.label = 1;
|
|
2006
2414
|
case 1:
|
|
2007
|
-
return [4,
|
|
2415
|
+
return [4, v.next()];
|
|
2008
2416
|
case 2:
|
|
2009
|
-
if ((
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
}),
|
|
2417
|
+
if ((f = R.sent()).done) return [3, 4];
|
|
2418
|
+
u = f.value, m.lastLoadResult = m.lastLoadResult || {}, console.log("current load: ", u), u.forEach(function(I) {
|
|
2419
|
+
m.lastLoadResult = l(l({}, m.lastLoadResult), I);
|
|
2420
|
+
}), R.label = 3;
|
|
2013
2421
|
case 3:
|
|
2014
2422
|
return [3, 1];
|
|
2015
2423
|
case 4:
|
|
2016
2424
|
return [3, 11];
|
|
2017
2425
|
case 5:
|
|
2018
|
-
return k =
|
|
2426
|
+
return k = R.sent(), C = { error: k }, [3, 11];
|
|
2019
2427
|
case 6:
|
|
2020
|
-
return
|
|
2428
|
+
return R.trys.push([6, , 9, 10]), f && !f.done && (L = v.return) ? [4, L.call(v)] : [3, 8];
|
|
2021
2429
|
case 7:
|
|
2022
|
-
|
|
2430
|
+
R.sent(), R.label = 8;
|
|
2023
2431
|
case 8:
|
|
2024
2432
|
return [3, 10];
|
|
2025
2433
|
case 9:
|
|
2026
|
-
if (
|
|
2434
|
+
if (C) throw C.error;
|
|
2027
2435
|
return [7];
|
|
2028
2436
|
case 10:
|
|
2029
2437
|
return [7];
|
|
2030
2438
|
case 11:
|
|
2031
|
-
return [2,
|
|
2439
|
+
return [2, m.lastLoadResult];
|
|
2032
2440
|
}
|
|
2033
2441
|
});
|
|
2034
2442
|
});
|
|
2035
2443
|
};
|
|
2036
2444
|
}]);
|
|
2037
2445
|
});
|
|
2038
|
-
})(
|
|
2039
|
-
var
|
|
2040
|
-
function
|
|
2041
|
-
const
|
|
2446
|
+
})(lt);
|
|
2447
|
+
var wr = lt.exports;
|
|
2448
|
+
function ct() {
|
|
2449
|
+
const e = [
|
|
2042
2450
|
{
|
|
2043
2451
|
name: "markdownit",
|
|
2044
2452
|
path: "markdown-it.min.js"
|
|
@@ -2048,26 +2456,26 @@ function Xe() {
|
|
|
2048
2456
|
path: "highlight.11.11.1.min.js"
|
|
2049
2457
|
}
|
|
2050
2458
|
];
|
|
2051
|
-
let
|
|
2052
|
-
|
|
2459
|
+
let t = {};
|
|
2460
|
+
wr.loadScriptsQueue(e, {
|
|
2053
2461
|
baseUrl: "/scripts/ai/",
|
|
2054
|
-
lastLoadResult:
|
|
2462
|
+
lastLoadResult: t,
|
|
2055
2463
|
inHead: !1
|
|
2056
|
-
}).then((
|
|
2057
|
-
if (console.log("load ai deps: ",
|
|
2058
|
-
const
|
|
2059
|
-
console.log("markdownit: ",
|
|
2464
|
+
}).then((s) => {
|
|
2465
|
+
if (console.log("load ai deps: ", s), window.markdownit) {
|
|
2466
|
+
const r = window.markdownit();
|
|
2467
|
+
console.log("markdownit: ", r), yn();
|
|
2060
2468
|
}
|
|
2061
2469
|
});
|
|
2062
2470
|
}
|
|
2063
|
-
const
|
|
2471
|
+
const br = {
|
|
2064
2472
|
key: 0,
|
|
2065
2473
|
class: "ai-assistant"
|
|
2066
|
-
},
|
|
2474
|
+
}, kr = {
|
|
2067
2475
|
name: "AiChat"
|
|
2068
2476
|
//这个⾮常重要,就是未来你放到其他项⽬中,组件标签的名字,⽐如:<sz-workflow></sz-workflow>
|
|
2069
|
-
},
|
|
2070
|
-
...
|
|
2477
|
+
}, Sr = /* @__PURE__ */ Ze({
|
|
2478
|
+
...kr,
|
|
2071
2479
|
props: {
|
|
2072
2480
|
token: {
|
|
2073
2481
|
type: String,
|
|
@@ -2139,65 +2547,93 @@ const In = {
|
|
|
2139
2547
|
enableVoiceUpload: {
|
|
2140
2548
|
type: Boolean,
|
|
2141
2549
|
default: !1
|
|
2550
|
+
},
|
|
2551
|
+
/**
|
|
2552
|
+
* szjy-ui fence 自定义 UI 配置,透传给动作处理器。
|
|
2553
|
+
* 例如:{ postMessage: { target: () => sandboxIframe.contentWindow, targetOrigin: 'http://...' } }
|
|
2554
|
+
*/
|
|
2555
|
+
customUi: {
|
|
2556
|
+
type: Object,
|
|
2557
|
+
default: null
|
|
2558
|
+
},
|
|
2559
|
+
/**
|
|
2560
|
+
* szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
|
|
2561
|
+
*/
|
|
2562
|
+
uiActionHandler: {
|
|
2563
|
+
type: Function,
|
|
2564
|
+
default: null
|
|
2565
|
+
},
|
|
2566
|
+
/**
|
|
2567
|
+
* Mock 响应内容:llmName 为 standard(模拟数据模型)时不请求真实后端,
|
|
2568
|
+
* 将该内容流式输出,用于联调 szjy-ui fence / postMessage 动作
|
|
2569
|
+
*/
|
|
2570
|
+
mockResponse: {
|
|
2571
|
+
type: String,
|
|
2572
|
+
default: ""
|
|
2142
2573
|
}
|
|
2143
2574
|
},
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2575
|
+
emits: ["ui-action"],
|
|
2576
|
+
setup(e, { emit: t }) {
|
|
2577
|
+
const s = T(!1), r = T(!1), o = t, n = () => {
|
|
2578
|
+
s.value = !s.value;
|
|
2579
|
+
}, a = () => {
|
|
2580
|
+
r.value = !0, s.value = !1;
|
|
2581
|
+
}, i = (l) => {
|
|
2582
|
+
console.log("用户输入:", l);
|
|
2151
2583
|
};
|
|
2152
|
-
return
|
|
2153
|
-
|
|
2154
|
-
modelValue:
|
|
2155
|
-
"onUpdate:modelValue":
|
|
2156
|
-
onSubmit:
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2584
|
+
return ct(), (l, c) => r.value ? $("", !0) : (S(), x("div", br, [
|
|
2585
|
+
D(it, {
|
|
2586
|
+
modelValue: s.value,
|
|
2587
|
+
"onUpdate:modelValue": c[0] || (c[0] = (b) => s.value = b),
|
|
2588
|
+
onSubmit: i,
|
|
2589
|
+
onUiAction: c[1] || (c[1] = (b) => o("ui-action", b)),
|
|
2590
|
+
token: e.token,
|
|
2591
|
+
identifier: e.identifier,
|
|
2592
|
+
baseUrl: e.baseUrl,
|
|
2593
|
+
title: e.title,
|
|
2594
|
+
llmName: e.llmName,
|
|
2595
|
+
messagePostRender: e.messagePostRender,
|
|
2596
|
+
extraConfig: e.extraConfig,
|
|
2597
|
+
customUi: e.customUi,
|
|
2598
|
+
uiActionHandler: e.uiActionHandler,
|
|
2599
|
+
mockResponse: e.mockResponse,
|
|
2600
|
+
soundBaseUrl: e.soundBaseUrl,
|
|
2601
|
+
workerUrl: e.workerUrl,
|
|
2602
|
+
enableVoiceInput: e.enableVoiceInput,
|
|
2603
|
+
enableVoiceUpload: e.enableVoiceUpload
|
|
2604
|
+
}, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title", "llmName", "messagePostRender", "extraConfig", "customUi", "uiActionHandler", "mockResponse", "soundBaseUrl", "workerUrl", "enableVoiceInput", "enableVoiceUpload"]),
|
|
2605
|
+
d("div", {
|
|
2170
2606
|
class: "ai-icon",
|
|
2171
|
-
onClick:
|
|
2607
|
+
onClick: n
|
|
2172
2608
|
}, [
|
|
2173
|
-
|
|
2609
|
+
d("div", {
|
|
2174
2610
|
class: "close-icon",
|
|
2175
|
-
onClick:
|
|
2176
|
-
}, [...
|
|
2177
|
-
|
|
2611
|
+
onClick: St(a, ["stop"])
|
|
2612
|
+
}, [...c[2] || (c[2] = [
|
|
2613
|
+
d("svg", {
|
|
2178
2614
|
viewBox: "0 0 1024 1024",
|
|
2179
2615
|
width: "8",
|
|
2180
2616
|
height: "8"
|
|
2181
2617
|
}, [
|
|
2182
|
-
|
|
2618
|
+
d("path", {
|
|
2183
2619
|
d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
|
|
2184
2620
|
fill: "currentColor"
|
|
2185
2621
|
})
|
|
2186
2622
|
], -1)
|
|
2187
2623
|
])]),
|
|
2188
|
-
|
|
2189
|
-
src:
|
|
2624
|
+
c[3] || (c[3] = d("img", {
|
|
2625
|
+
src: Ct,
|
|
2190
2626
|
alt: "AI助手"
|
|
2191
2627
|
}, null, -1)),
|
|
2192
|
-
|
|
2628
|
+
c[4] || (c[4] = d("span", { class: "ai-icon-text" }, "AI助手", -1))
|
|
2193
2629
|
])
|
|
2194
2630
|
]));
|
|
2195
2631
|
}
|
|
2196
|
-
}),
|
|
2632
|
+
}), Cr = { class: "ai-chat-plain" }, Ar = {
|
|
2197
2633
|
name: "AiChatPlain"
|
|
2198
2634
|
// 注册后的组件标签名:<sz-ai-chat-plain>
|
|
2199
|
-
},
|
|
2200
|
-
...
|
|
2635
|
+
}, xr = /* @__PURE__ */ Ze({
|
|
2636
|
+
...Ar,
|
|
2201
2637
|
props: {
|
|
2202
2638
|
token: {
|
|
2203
2639
|
type: String,
|
|
@@ -2269,244 +2705,286 @@ const In = {
|
|
|
2269
2705
|
enableVoiceUpload: {
|
|
2270
2706
|
type: Boolean,
|
|
2271
2707
|
default: !1
|
|
2708
|
+
},
|
|
2709
|
+
/**
|
|
2710
|
+
* szjy-ui fence 自定义 UI 配置,透传给动作处理器。
|
|
2711
|
+
* 例如:{ postMessage: { target: () => sandboxIframe.contentWindow, targetOrigin: 'http://...' } }
|
|
2712
|
+
*/
|
|
2713
|
+
customUi: {
|
|
2714
|
+
type: Object,
|
|
2715
|
+
default: null
|
|
2716
|
+
},
|
|
2717
|
+
/**
|
|
2718
|
+
* szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
|
|
2719
|
+
*/
|
|
2720
|
+
uiActionHandler: {
|
|
2721
|
+
type: Function,
|
|
2722
|
+
default: null
|
|
2723
|
+
},
|
|
2724
|
+
/**
|
|
2725
|
+
* Mock 响应内容:llmName 为 standard(模拟数据模型)时不请求真实后端,
|
|
2726
|
+
* 将该内容流式输出,用于联调 szjy-ui fence / postMessage 动作
|
|
2727
|
+
*/
|
|
2728
|
+
mockResponse: {
|
|
2729
|
+
type: String,
|
|
2730
|
+
default: ""
|
|
2272
2731
|
}
|
|
2273
2732
|
},
|
|
2274
|
-
emits: ["submit"],
|
|
2275
|
-
setup(
|
|
2276
|
-
const
|
|
2277
|
-
return
|
|
2278
|
-
|
|
2733
|
+
emits: ["submit", "ui-action"],
|
|
2734
|
+
setup(e, { emit: t }) {
|
|
2735
|
+
const s = t;
|
|
2736
|
+
return ct(), (r, o) => (S(), x("div", Cr, [
|
|
2737
|
+
D(it, {
|
|
2279
2738
|
"model-value": !0,
|
|
2280
|
-
token:
|
|
2281
|
-
identifier:
|
|
2282
|
-
baseUrl:
|
|
2283
|
-
title:
|
|
2284
|
-
llmName:
|
|
2285
|
-
messagePostRender:
|
|
2286
|
-
extraConfig:
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2739
|
+
token: e.token,
|
|
2740
|
+
identifier: e.identifier,
|
|
2741
|
+
baseUrl: e.baseUrl,
|
|
2742
|
+
title: e.title,
|
|
2743
|
+
llmName: e.llmName,
|
|
2744
|
+
messagePostRender: e.messagePostRender,
|
|
2745
|
+
extraConfig: e.extraConfig,
|
|
2746
|
+
customUi: e.customUi,
|
|
2747
|
+
uiActionHandler: e.uiActionHandler,
|
|
2748
|
+
mockResponse: e.mockResponse,
|
|
2749
|
+
soundBaseUrl: e.soundBaseUrl,
|
|
2750
|
+
workerUrl: e.workerUrl,
|
|
2751
|
+
enableVoiceInput: e.enableVoiceInput,
|
|
2752
|
+
enableVoiceUpload: e.enableVoiceUpload,
|
|
2291
2753
|
embedded: !0,
|
|
2292
|
-
onSubmit: o[0] || (o[0] = (n) =>
|
|
2293
|
-
|
|
2754
|
+
onSubmit: o[0] || (o[0] = (n) => s("submit", n)),
|
|
2755
|
+
onUiAction: o[1] || (o[1] = (n) => s("ui-action", n))
|
|
2756
|
+
}, null, 8, ["token", "identifier", "baseUrl", "title", "llmName", "messagePostRender", "extraConfig", "customUi", "uiActionHandler", "mockResponse", "soundBaseUrl", "workerUrl", "enableVoiceInput", "enableVoiceUpload"])
|
|
2294
2757
|
]));
|
|
2295
2758
|
}
|
|
2296
|
-
}),
|
|
2759
|
+
}), Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2297
2760
|
__proto__: null,
|
|
2298
|
-
SzAiChat:
|
|
2299
|
-
SzAiChatPlain:
|
|
2300
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
2301
|
-
if (!
|
|
2302
|
-
|
|
2303
|
-
for (let
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2761
|
+
SzAiChat: Sr,
|
|
2762
|
+
SzAiChatPlain: xr
|
|
2763
|
+
}, Symbol.toStringTag, { value: "Module" })), ze = function(e) {
|
|
2764
|
+
if (!ze.installed) {
|
|
2765
|
+
ze.installed = !0;
|
|
2766
|
+
for (let t in Ge) {
|
|
2767
|
+
const s = Reflect.get(Ge, t);
|
|
2768
|
+
e.component(s.name, s);
|
|
2306
2769
|
}
|
|
2307
2770
|
}
|
|
2308
|
-
},
|
|
2309
|
-
const
|
|
2310
|
-
console.log(`点击了路由链接: ${
|
|
2311
|
-
},
|
|
2312
|
-
const
|
|
2313
|
-
if (
|
|
2314
|
-
return { routeName:
|
|
2315
|
-
const
|
|
2316
|
-
return new URLSearchParams(
|
|
2317
|
-
o[i] =
|
|
2318
|
-
}), { routeName:
|
|
2319
|
-
},
|
|
2771
|
+
}, Tr = (e, t) => {
|
|
2772
|
+
const s = t ? `?${new URLSearchParams(t).toString()}` : "";
|
|
2773
|
+
console.log(`点击了路由链接: ${e}${s}`);
|
|
2774
|
+
}, Rr = (e) => {
|
|
2775
|
+
const t = e.indexOf("?");
|
|
2776
|
+
if (t === -1)
|
|
2777
|
+
return { routeName: e };
|
|
2778
|
+
const s = e.substring(0, t), r = e.substring(t + 1), o = {};
|
|
2779
|
+
return new URLSearchParams(r).forEach((a, i) => {
|
|
2780
|
+
o[i] = a;
|
|
2781
|
+
}), { routeName: s, queryParams: Object.keys(o).length > 0 ? o : void 0 };
|
|
2782
|
+
}, Ur = {
|
|
2320
2783
|
color: "#536fec",
|
|
2321
2784
|
fontWeight: "bold",
|
|
2322
2785
|
textDecoration: "underline",
|
|
2323
2786
|
cursor: "pointer",
|
|
2324
2787
|
padding: "0 3px"
|
|
2325
|
-
},
|
|
2326
|
-
const
|
|
2327
|
-
let
|
|
2328
|
-
for (; (o =
|
|
2329
|
-
o.index >
|
|
2330
|
-
const n = o[1], { routeName:
|
|
2331
|
-
|
|
2788
|
+
}, _r = (e) => {
|
|
2789
|
+
const t = /#router:([^#]+)#/g, s = [];
|
|
2790
|
+
let r = 0, o;
|
|
2791
|
+
for (; (o = t.exec(e)) !== null; ) {
|
|
2792
|
+
o.index > r && s.push({ text: e.substring(r, o.index) });
|
|
2793
|
+
const n = o[1], { routeName: a, queryParams: i } = Rr(n);
|
|
2794
|
+
s.push({ text: a, routeName: a, queryParams: i }), r = t.lastIndex;
|
|
2332
2795
|
}
|
|
2333
|
-
return
|
|
2334
|
-
},
|
|
2335
|
-
const { onRouteClick: o =
|
|
2336
|
-
|
|
2337
|
-
const i = {
|
|
2338
|
-
return Object.assign(
|
|
2339
|
-
l.preventDefault(), o(
|
|
2340
|
-
}),
|
|
2341
|
-
},
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2796
|
+
return r < e.length && s.push({ text: e.substring(r) }), s;
|
|
2797
|
+
}, Pr = (e, t, s = {}, r) => {
|
|
2798
|
+
const { onRouteClick: o = Tr, linkStyle: n = {} } = s, a = document.createElement("a");
|
|
2799
|
+
a.href = "#", a.textContent = e;
|
|
2800
|
+
const i = { ...Ur, ...n };
|
|
2801
|
+
return Object.assign(a.style, i), a.addEventListener("click", (l) => {
|
|
2802
|
+
l.preventDefault(), o(t, r);
|
|
2803
|
+
}), a;
|
|
2804
|
+
}, Mr = (e) => {
|
|
2805
|
+
const t = /#router:([^#]+)#/g, s = [], r = document.createTreeWalker(
|
|
2806
|
+
e,
|
|
2344
2807
|
NodeFilter.SHOW_TEXT,
|
|
2345
2808
|
null
|
|
2346
2809
|
);
|
|
2347
|
-
let o =
|
|
2810
|
+
let o = r.nextNode();
|
|
2348
2811
|
for (; o; ) {
|
|
2349
|
-
const n = o,
|
|
2350
|
-
if (
|
|
2351
|
-
|
|
2352
|
-
const i =
|
|
2353
|
-
i.length > 0 &&
|
|
2812
|
+
const n = o, a = n.textContent || "";
|
|
2813
|
+
if (t.test(a)) {
|
|
2814
|
+
t.lastIndex = 0;
|
|
2815
|
+
const i = _r(a);
|
|
2816
|
+
i.length > 0 && s.push({ node: n, replacements: i });
|
|
2354
2817
|
}
|
|
2355
|
-
o =
|
|
2818
|
+
o = r.nextNode();
|
|
2356
2819
|
}
|
|
2357
|
-
return
|
|
2358
|
-
},
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2820
|
+
return s;
|
|
2821
|
+
}, Lr = (e, t, s = {}) => {
|
|
2822
|
+
const r = Mr(e);
|
|
2823
|
+
r.forEach(({ node: o, replacements: n }) => {
|
|
2361
2824
|
var i;
|
|
2362
|
-
const
|
|
2363
|
-
n.forEach(({ text: l, routeName:
|
|
2364
|
-
if (
|
|
2365
|
-
const
|
|
2366
|
-
|
|
2825
|
+
const a = document.createDocumentFragment();
|
|
2826
|
+
n.forEach(({ text: l, routeName: c, queryParams: b }) => {
|
|
2827
|
+
if (c) {
|
|
2828
|
+
const P = Pr(l, c, s, b);
|
|
2829
|
+
a.appendChild(P);
|
|
2367
2830
|
} else
|
|
2368
|
-
|
|
2369
|
-
}), (i = o.parentNode) == null || i.replaceChild(
|
|
2370
|
-
}),
|
|
2371
|
-
var
|
|
2372
|
-
(
|
|
2831
|
+
a.appendChild(document.createTextNode(l));
|
|
2832
|
+
}), (i = o.parentNode) == null || i.replaceChild(a, o);
|
|
2833
|
+
}), s != null && s.nodeCallback && r.forEach(({ node: o, replacements: n }) => {
|
|
2834
|
+
var a;
|
|
2835
|
+
(a = s.nodeCallback) == null || a.call(s, o, n);
|
|
2373
2836
|
});
|
|
2374
|
-
},
|
|
2375
|
-
function
|
|
2837
|
+
}, we = "szjy-voice-models", Ae = "szjy-voice-cache-v1";
|
|
2838
|
+
function be() {
|
|
2376
2839
|
return typeof navigator < "u" && !!navigator.storage && typeof navigator.storage.getDirectory == "function";
|
|
2377
2840
|
}
|
|
2378
|
-
async function
|
|
2379
|
-
if (!
|
|
2841
|
+
async function Oe(e = we) {
|
|
2842
|
+
if (!be()) return null;
|
|
2380
2843
|
try {
|
|
2381
|
-
return await (await navigator.storage.getDirectory()).getDirectoryHandle(
|
|
2382
|
-
} catch (
|
|
2383
|
-
return console.warn("[OPFS] 获取目录失败,将使用降级缓存:",
|
|
2844
|
+
return await (await navigator.storage.getDirectory()).getDirectoryHandle(e, { create: !0 });
|
|
2845
|
+
} catch (t) {
|
|
2846
|
+
return console.warn("[OPFS] 获取目录失败,将使用降级缓存:", t), null;
|
|
2384
2847
|
}
|
|
2385
2848
|
}
|
|
2386
|
-
async function
|
|
2387
|
-
if (
|
|
2849
|
+
async function $r(e, t, s = we) {
|
|
2850
|
+
if (be())
|
|
2388
2851
|
try {
|
|
2389
|
-
const
|
|
2390
|
-
if (
|
|
2391
|
-
const n = await (await
|
|
2392
|
-
return await n.write(
|
|
2852
|
+
const r = await Oe(s);
|
|
2853
|
+
if (r) {
|
|
2854
|
+
const n = await (await r.getFileHandle(e, { create: !0 })).createWritable();
|
|
2855
|
+
return await n.write(t), await n.close(), !0;
|
|
2393
2856
|
}
|
|
2394
|
-
} catch (
|
|
2395
|
-
console.warn(`[OPFS] 写入文件 ${
|
|
2857
|
+
} catch (r) {
|
|
2858
|
+
console.warn(`[OPFS] 写入文件 ${e} 失败:`, r);
|
|
2396
2859
|
}
|
|
2397
2860
|
if (typeof caches < "u")
|
|
2398
2861
|
try {
|
|
2399
|
-
const
|
|
2862
|
+
const r = await caches.open(Ae), o = new Response(t, {
|
|
2400
2863
|
headers: { "Content-Type": "application/octet-stream" }
|
|
2401
2864
|
});
|
|
2402
|
-
return await
|
|
2403
|
-
} catch (
|
|
2404
|
-
console.warn(`[CacheStorage] 缓存写入 ${
|
|
2865
|
+
return await r.put(`/${s}/${e}`, o), !0;
|
|
2866
|
+
} catch (r) {
|
|
2867
|
+
console.warn(`[CacheStorage] 缓存写入 ${e} 失败:`, r);
|
|
2405
2868
|
}
|
|
2406
2869
|
return !1;
|
|
2407
2870
|
}
|
|
2408
|
-
async function
|
|
2409
|
-
if (
|
|
2871
|
+
async function Or(e, t = we) {
|
|
2872
|
+
if (be())
|
|
2410
2873
|
try {
|
|
2411
|
-
const
|
|
2412
|
-
if (
|
|
2413
|
-
return await (await (await
|
|
2874
|
+
const s = await Oe(t);
|
|
2875
|
+
if (s)
|
|
2876
|
+
return await (await (await s.getFileHandle(e, { create: !1 })).getFile()).arrayBuffer();
|
|
2414
2877
|
} catch {
|
|
2415
2878
|
}
|
|
2416
2879
|
if (typeof caches < "u")
|
|
2417
2880
|
try {
|
|
2418
|
-
const
|
|
2419
|
-
if (
|
|
2420
|
-
return await
|
|
2881
|
+
const r = await (await caches.open(Ae)).match(`/${t}/${e}`);
|
|
2882
|
+
if (r)
|
|
2883
|
+
return await r.arrayBuffer();
|
|
2421
2884
|
} catch {
|
|
2422
2885
|
}
|
|
2423
2886
|
return null;
|
|
2424
2887
|
}
|
|
2425
|
-
async function
|
|
2426
|
-
if (
|
|
2888
|
+
async function Nr(e, t = we) {
|
|
2889
|
+
if (be())
|
|
2427
2890
|
try {
|
|
2428
|
-
const
|
|
2429
|
-
if (
|
|
2430
|
-
return (await (await
|
|
2891
|
+
const s = await Oe(t);
|
|
2892
|
+
if (s)
|
|
2893
|
+
return (await (await s.getFileHandle(e, { create: !1 })).getFile()).size > 0;
|
|
2431
2894
|
} catch {
|
|
2432
2895
|
}
|
|
2433
2896
|
if (typeof caches < "u")
|
|
2434
2897
|
try {
|
|
2435
|
-
return !!await (await caches.open(
|
|
2898
|
+
return !!await (await caches.open(Ae)).match(`/${t}/${e}`);
|
|
2436
2899
|
} catch {
|
|
2437
2900
|
}
|
|
2438
2901
|
return !1;
|
|
2439
2902
|
}
|
|
2440
|
-
async function
|
|
2441
|
-
let
|
|
2442
|
-
if (
|
|
2903
|
+
async function Fr(e = we) {
|
|
2904
|
+
let t = !1;
|
|
2905
|
+
if (be())
|
|
2443
2906
|
try {
|
|
2444
|
-
await (await navigator.storage.getDirectory()).removeEntry(
|
|
2445
|
-
} catch (
|
|
2446
|
-
|
|
2907
|
+
await (await navigator.storage.getDirectory()).removeEntry(e, { recursive: !0 }), t = !0, console.log(`[OPFS] 成功清空语音模型缓存目录: ${e}`);
|
|
2908
|
+
} catch (s) {
|
|
2909
|
+
s.name === "NotFoundError" ? t = !0 : console.warn(`[OPFS] 清理目录 ${e} 异常:`, s);
|
|
2447
2910
|
}
|
|
2448
2911
|
if (typeof caches < "u")
|
|
2449
2912
|
try {
|
|
2450
|
-
const
|
|
2451
|
-
for (const
|
|
2452
|
-
(
|
|
2453
|
-
} catch (
|
|
2454
|
-
console.warn("[CacheStorage] 清除缓存异常:",
|
|
2913
|
+
const s = await caches.keys();
|
|
2914
|
+
for (const r of s)
|
|
2915
|
+
(r.includes("transformers") || r.includes("szjy-voice") || r === Ae) && (await caches.delete(r), t = !0);
|
|
2916
|
+
} catch (s) {
|
|
2917
|
+
console.warn("[CacheStorage] 清除缓存异常:", s);
|
|
2455
2918
|
}
|
|
2456
|
-
return
|
|
2919
|
+
return t;
|
|
2457
2920
|
}
|
|
2458
|
-
const
|
|
2459
|
-
function
|
|
2460
|
-
componentPrefix:
|
|
2461
|
-
components:
|
|
2921
|
+
const Ir = "0.1.13", Er = "Sz";
|
|
2922
|
+
function Br({
|
|
2923
|
+
componentPrefix: e = Er,
|
|
2924
|
+
components: t = []
|
|
2462
2925
|
} = {}) {
|
|
2463
|
-
const
|
|
2464
|
-
function
|
|
2465
|
-
n.component(
|
|
2466
|
-
|
|
2926
|
+
const s = [];
|
|
2927
|
+
function r(n, a, i) {
|
|
2928
|
+
n.component(e + a) || n.component(
|
|
2929
|
+
e + a,
|
|
2467
2930
|
i
|
|
2468
2931
|
);
|
|
2469
2932
|
}
|
|
2470
2933
|
function o(n) {
|
|
2471
|
-
|
|
2472
|
-
const { name: i, alias: l } =
|
|
2473
|
-
|
|
2474
|
-
|
|
2934
|
+
s.includes(n) || (s.push(n), t.forEach((a) => {
|
|
2935
|
+
const { name: i, alias: l } = a;
|
|
2936
|
+
r(n, i, a), l && l.forEach((c) => {
|
|
2937
|
+
r(n, c, a);
|
|
2475
2938
|
});
|
|
2476
2939
|
}));
|
|
2477
2940
|
}
|
|
2478
2941
|
return {
|
|
2479
|
-
version:
|
|
2480
|
-
componentPrefix:
|
|
2942
|
+
version: Ir,
|
|
2943
|
+
componentPrefix: e,
|
|
2481
2944
|
install: o
|
|
2482
2945
|
};
|
|
2483
2946
|
}
|
|
2484
|
-
const
|
|
2485
|
-
install(
|
|
2486
|
-
|
|
2947
|
+
const Vr = {
|
|
2948
|
+
install(e) {
|
|
2949
|
+
ze(e);
|
|
2487
2950
|
}
|
|
2488
2951
|
};
|
|
2489
2952
|
export {
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2953
|
+
_n as AudioRecorder,
|
|
2954
|
+
Et as DEFAULT_MOCK_RESPONSE,
|
|
2955
|
+
at as DEFAULT_WHISPER_WORKER_URL,
|
|
2956
|
+
hn as SZJY_UI_FENCE_LANG,
|
|
2957
|
+
Un as StreamResampler,
|
|
2958
|
+
Sr as SzAiChat,
|
|
2959
|
+
xr as SzAiChatPlain,
|
|
2960
|
+
Ln as VoiceInputManager,
|
|
2961
|
+
gn as bindSzjyUiEvents,
|
|
2962
|
+
Fr as clearVoiceModelCache,
|
|
2963
|
+
Br as create,
|
|
2964
|
+
Ot as createMockStylized,
|
|
2965
|
+
Pr as createRouteLink,
|
|
2966
|
+
Mn as decodeAudioFile,
|
|
2967
|
+
Vr as default,
|
|
2968
|
+
ve as escapeHtml,
|
|
2969
|
+
Mr as findRouteTextNodes,
|
|
2970
|
+
qe as float32ToWav,
|
|
2971
|
+
Or as getFileFromCache,
|
|
2972
|
+
Oe as getOPFSDirectory,
|
|
2973
|
+
Wt as getSzjyUiAction,
|
|
2974
|
+
Dt as getSzjyUiComponent,
|
|
2975
|
+
Nr as hasFileInCache,
|
|
2976
|
+
Gt as hasSzjyUiAction,
|
|
2977
|
+
qt as hasSzjyUiComponent,
|
|
2978
|
+
be as isOPFSSupported,
|
|
2979
|
+
Rr as parseRouteMarkerContent,
|
|
2980
|
+
_r as parseRouteMarkers,
|
|
2981
|
+
pn as parseSzjyUiFence,
|
|
2982
|
+
Ht as registerSzjyUiAction,
|
|
2983
|
+
et as registerSzjyUiComponent,
|
|
2984
|
+
Xt as renderActionAttrs,
|
|
2985
|
+
Kt as renderSzjyUiBlock,
|
|
2986
|
+
tt as renderSzjyUiNode,
|
|
2987
|
+
Pn as resampleAudioData,
|
|
2988
|
+
Lr as routeLinkRender,
|
|
2989
|
+
$r as saveFileToCache
|
|
2512
2990
|
};
|