@szjy/ai-coms 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
- import { computed as M, createElementBlock as z, openBlock as O, normalizeStyle as G, createElementVNode as _, normalizeClass as H, getCurrentInstance as re, ref as C, watch as ie, onUnmounted as ce, createBlock as Q, Transition as oe, withCtx as B, createCommentVNode as V, createVNode as A, nextTick as ae, resolveComponent as X, toDisplayString as D, createTextVNode as ue, Fragment as Y, renderList as Z, unref as de, withKeys as fe, defineComponent as pe, withModifiers as me } from "vue";
2
- const ve = "/images/ai-round.png", he = "/images/ai-sqrt.png", ye = "/images/bars-loading.svg";
3
- function ge(n, t = location.href) {
4
- return new URLSearchParams(new URL(t).search).get(n);
1
+ import { computed as q, createElementBlock as O, openBlock as P, normalizeStyle as K, createElementVNode as k, normalizeClass as H, getCurrentInstance as ne, ref as C, watch as ie, onUnmounted as ce, createBlock as J, Transition as re, withCtx as F, createCommentVNode as D, createVNode as $, nextTick as oe, resolveComponent as X, toDisplayString as V, createTextVNode as ue, Fragment as G, renderList as Y, unref as de, withKeys as fe, defineComponent as pe, withModifiers as me } from "vue";
2
+ const he = "/images/ai-round.png", ve = "/images/ai-sqrt.png", ge = "/images/bars-loading.svg";
3
+ function ye(t, n = location.href) {
4
+ return new URLSearchParams(new URL(n).search).get(t);
5
5
  }
6
- function be(n) {
7
- return n.startsWith("http://") || n.startsWith("https://") ? n : `${location.protocol}//${location.host}${n}`;
6
+ function be(t) {
7
+ return t.startsWith("http://") || t.startsWith("https://") ? t : `${location.protocol}//${location.host}${t}`;
8
8
  }
9
- async function we(n) {
10
- const t = new URL("http://localhost:11434/api/chat"), l = {};
11
- Object.keys(l).forEach((a) => {
12
- t.searchParams.append(a, l[a]);
9
+ async function we(t) {
10
+ const n = new URL("http://localhost:11434/api/chat"), o = {};
11
+ Object.keys(o).forEach((r) => {
12
+ n.searchParams.append(r, o[r]);
13
13
  });
14
- const i = new Request(t, {
14
+ const a = new Request(n, {
15
15
  mode: "cors",
16
16
  method: "post",
17
17
  headers: {
@@ -27,23 +27,23 @@ async function we(n) {
27
27
  },
28
28
  {
29
29
  role: "user",
30
- content: n
30
+ content: t
31
31
  }
32
32
  ]
33
33
  })
34
34
  });
35
- return fetch(i);
35
+ return fetch(a);
36
36
  }
37
- async function Se(n, t) {
38
- const l = new URL(`${location.origin}/spark/v1/chat/completions`), i = {};
39
- Object.keys(i).forEach((e) => {
40
- l.searchParams.append(e, i[e]);
37
+ async function xe(t, n) {
38
+ const o = new URL(`${location.origin}/spark/v1/chat/completions`), a = {};
39
+ Object.keys(a).forEach((e) => {
40
+ o.searchParams.append(e, a[e]);
41
41
  });
42
- const a = new Request(l, {
42
+ const r = new Request(o, {
43
43
  method: "post",
44
44
  headers: {
45
45
  "Content-Type": "application/json",
46
- Authorization: `Bearer ${t}`
46
+ Authorization: `Bearer ${n}`
47
47
  },
48
48
  body: JSON.stringify({
49
49
  model: "generalv4.0Ultra",
@@ -51,23 +51,23 @@ async function Se(n, t) {
51
51
  messages: [
52
52
  {
53
53
  role: "user",
54
- content: n
54
+ content: t
55
55
  }
56
56
  ]
57
57
  })
58
58
  });
59
- return fetch(a);
59
+ return fetch(r);
60
60
  }
61
- async function _e(n, t) {
62
- const l = new URL(`${location.origin}/siliconflow/v1/chat/completions`), i = {};
63
- Object.keys(i).forEach((e) => {
64
- l.searchParams.append(e, i[e]);
61
+ async function ke(t, n) {
62
+ const o = new URL(`${location.origin}/siliconflow/v1/chat/completions`), a = {};
63
+ Object.keys(a).forEach((e) => {
64
+ o.searchParams.append(e, a[e]);
65
65
  });
66
- const a = new Request(l, {
66
+ const r = new Request(o, {
67
67
  method: "post",
68
68
  headers: {
69
69
  "Content-Type": "application/json",
70
- Authorization: `Bearer ${t}`
70
+ Authorization: `Bearer ${n}`
71
71
  },
72
72
  body: JSON.stringify({
73
73
  // 集成了大部分模型,可以免费使用
@@ -76,23 +76,23 @@ async function _e(n, t) {
76
76
  messages: [
77
77
  {
78
78
  role: "user",
79
- content: n
79
+ content: t
80
80
  }
81
81
  ]
82
82
  })
83
83
  });
84
- return fetch(a);
84
+ return fetch(r);
85
85
  }
86
- async function ke(n, t) {
87
- const l = new URL(`${location.origin}/moonshot/v1/chat/completions`), i = {};
88
- Object.keys(i).forEach((e) => {
89
- l.searchParams.append(e, i[e]);
86
+ async function Se(t, n) {
87
+ const o = new URL(`${location.origin}/moonshot/v1/chat/completions`), a = {};
88
+ Object.keys(a).forEach((e) => {
89
+ o.searchParams.append(e, a[e]);
90
90
  });
91
- const a = new Request(l, {
91
+ const r = new Request(o, {
92
92
  method: "post",
93
93
  headers: {
94
94
  "Content-Type": "application/json",
95
- Authorization: `Bearer ${t}`
95
+ Authorization: `Bearer ${n}`
96
96
  },
97
97
  body: JSON.stringify({
98
98
  model: "moonshot-v1-8k",
@@ -104,23 +104,23 @@ async function ke(n, t) {
104
104
  },
105
105
  {
106
106
  role: "user",
107
- content: n
107
+ content: t
108
108
  }
109
109
  ]
110
110
  })
111
111
  });
112
- return fetch(a);
112
+ return fetch(r);
113
113
  }
114
- async function xe(n, t) {
115
- const l = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), i = {};
116
- Object.keys(i).forEach((e) => {
117
- l.searchParams.append(e, i[e]);
114
+ async function _e(t, n) {
115
+ const o = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), a = {};
116
+ Object.keys(a).forEach((e) => {
117
+ o.searchParams.append(e, a[e]);
118
118
  });
119
- const a = new Request(l, {
119
+ const r = new Request(o, {
120
120
  method: "post",
121
121
  headers: {
122
122
  "Content-Type": "application/json",
123
- Authorization: `Bearer ${t}`
123
+ Authorization: `Bearer ${n}`
124
124
  },
125
125
  body: JSON.stringify({
126
126
  model: "qwq-32b-preview",
@@ -132,45 +132,45 @@ async function xe(n, t) {
132
132
  },
133
133
  {
134
134
  role: "user",
135
- content: n
135
+ content: t
136
136
  }
137
137
  ]
138
138
  })
139
139
  });
140
- return fetch(a);
140
+ return fetch(r);
141
141
  }
142
- async function Ce(n, t, l, i = "") {
143
- const a = be(i), e = new URL(`${a}/support/${l}/a`), d = {};
144
- Object.keys(d).forEach((h) => {
145
- e.searchParams.append(h, d[h]);
142
+ async function Ce(t, n, o, a = "") {
143
+ const r = be(a), e = new URL(`${r}/support/${o}/a`), i = {};
144
+ Object.keys(i).forEach((h) => {
145
+ e.searchParams.append(h, i[h]);
146
146
  });
147
- const S = new Request(e, {
147
+ const v = new Request(e, {
148
148
  method: "post",
149
149
  headers: {
150
150
  "Content-Type": "application/json",
151
- Authorization: `Bearer ${t}`
151
+ Authorization: `Bearer ${n}`
152
152
  },
153
153
  body: JSON.stringify({
154
- content: n
154
+ content: t
155
155
  })
156
156
  });
157
- return fetch(S);
157
+ return fetch(v);
158
158
  }
159
- const Te = (n) => {
160
- if (n.startsWith("data:")) {
161
- const t = n.substring(5).trim();
162
- if (t === "[DONE]")
159
+ const Te = (t) => {
160
+ if (t.startsWith("data:")) {
161
+ const n = t.substring(5).trim();
162
+ if (n === "[DONE]")
163
163
  return {
164
164
  done: !0
165
165
  };
166
166
  try {
167
- return JSON.parse(t);
168
- } catch (l) {
169
- console.error("JSON parsing error:", l);
167
+ return JSON.parse(n);
168
+ } catch (o) {
169
+ console.error("JSON parsing error:", o);
170
170
  }
171
171
  }
172
172
  return null;
173
- }, Pe = [
173
+ }, Re = [
174
174
  {
175
175
  label: "模拟数据模型",
176
176
  modelName: "standard",
@@ -179,7 +179,7 @@ const Te = (n) => {
179
179
  {
180
180
  label: "Spark 星火大模型",
181
181
  modelName: "spark",
182
- api: Se
182
+ api: xe
183
183
  },
184
184
  {
185
185
  label: "Ollama 3 大模型",
@@ -189,98 +189,98 @@ const Te = (n) => {
189
189
  {
190
190
  label: "SiliconFlow 硅基流动大模型",
191
191
  modelName: "siliconflow",
192
- api: _e
192
+ api: ke
193
193
  },
194
194
  {
195
195
  label: "Kimi Moonshot 月之暗面大模型",
196
196
  modelName: "moonshot",
197
- api: ke
197
+ api: Se
198
198
  },
199
199
  {
200
200
  label: "通义千问大模型",
201
201
  modelName: "dashscope",
202
- api: xe
202
+ api: _e
203
203
  },
204
204
  {
205
205
  label: "数智建管大模型",
206
206
  modelName: "szjy",
207
207
  api: Ce
208
208
  }
209
- ], ee = {
210
- standard(n, t) {
211
- let l = "";
212
- return n instanceof Uint8Array ? l = t.decode(n, {
209
+ ], Z = {
210
+ standard(t, n) {
211
+ let o = "";
212
+ return t instanceof Uint8Array ? o = n.decode(t, {
213
213
  stream: !0
214
- }) : l = n, {
215
- content: l
214
+ }) : o = t, {
215
+ content: o
216
216
  };
217
217
  },
218
- spark(n) {
219
- const t = Te(n);
220
- return t.done ? {
218
+ spark(t) {
219
+ const n = Te(t);
220
+ return n.done ? {
221
221
  done: !0
222
222
  } : {
223
- content: t.choices[0].delta.content || ""
223
+ content: n.choices[0].delta.content || ""
224
224
  };
225
225
  },
226
- siliconflow(n) {
227
- return this.spark(n);
226
+ siliconflow(t) {
227
+ return this.spark(t);
228
228
  },
229
- moonshot(n) {
230
- return this.spark(n);
229
+ moonshot(t) {
230
+ return this.spark(t);
231
231
  },
232
- dashscope(n) {
233
- return this.spark(n);
232
+ dashscope(t) {
233
+ return this.spark(t);
234
234
  },
235
- szjy(n) {
236
- return this.spark(n);
235
+ szjy(t) {
236
+ return this.spark(t);
237
237
  },
238
- ollama3(n) {
238
+ ollama3(t) {
239
239
  return {
240
- content: JSON.parse(n).message.content
240
+ content: JSON.parse(t).message.content
241
241
  };
242
242
  }
243
- }, te = (n, t, l) => {
244
- const i = n.split(l);
245
- return i.slice(0, -1).forEach((a) => {
246
- a.trim() !== "" && t.enqueue(a);
247
- }), i[i.length - 1];
248
- }, Oe = (n) => {
249
- let t = "";
243
+ }, ee = (t, n, o) => {
244
+ const a = t.split(o);
245
+ return a.slice(0, -1).forEach((r) => {
246
+ r.trim() !== "" && n.enqueue(r);
247
+ }), a[a.length - 1];
248
+ }, Pe = (t) => {
249
+ let n = "";
250
250
  return new TransformStream({
251
- transform(l, i) {
252
- if (t += l, t.trim().startsWith("data:"))
253
- t = te(t, i, n);
251
+ transform(o, a) {
252
+ if (n += o, n.trim().startsWith("data:"))
253
+ n = ee(n, a, t);
254
254
  else
255
255
  try {
256
- JSON.parse(t), t = te(t, i, n);
256
+ JSON.parse(n), n = ee(n, a, t);
257
257
  } catch {
258
- i.enqueue(l), t = "";
258
+ a.enqueue(o), n = "";
259
259
  }
260
260
  },
261
- flush(l) {
262
- t.trim() !== "" && l.enqueue(t);
261
+ flush(o) {
262
+ n.trim() !== "" && o.enqueue(n);
263
263
  }
264
264
  });
265
265
  };
266
- async function Le(n, t) {
267
- const l = n.api;
268
- return l ? new Promise((i) => {
269
- l(t.text, t.token, t.identifier, t.baseUrl).then((a) => {
270
- if (a.body) {
271
- const e = a.body.pipeThrough(new TextDecoderStream()).pipeThrough(Oe(`
266
+ async function Le(t, n) {
267
+ const o = t.api;
268
+ return o ? new Promise((a) => {
269
+ o(n.text, n.token, n.identifier, n.baseUrl).then((r) => {
270
+ if (r.body) {
271
+ const e = r.body.pipeThrough(new TextDecoderStream()).pipeThrough(Pe(`
272
272
  `)).getReader();
273
- console.log("reader from response:", e), i({
273
+ console.log("reader from response:", e), a({
274
274
  error: 0,
275
275
  reader: e
276
276
  });
277
277
  } else
278
- i({
278
+ a({
279
279
  error: 1,
280
280
  reader: null
281
281
  });
282
- }).catch((a) => {
283
- i({
282
+ }).catch((r) => {
283
+ a({
284
284
  error: 1,
285
285
  reader: null
286
286
  });
@@ -290,20 +290,20 @@ async function Le(n, t) {
290
290
  reader: null
291
291
  };
292
292
  }
293
- let F = null;
294
- function Re() {
295
- return F || (window.markdownit ? F = new window.markdownit({
293
+ let B = null;
294
+ function Ne() {
295
+ return B || (window.markdownit ? B = new window.markdownit({
296
296
  html: !0,
297
297
  linkify: !0,
298
298
  typographer: !0
299
- }) : console.log("markdownit is not loaded"), F);
299
+ }) : console.log("markdownit is not loaded"), B);
300
300
  }
301
- const W = (n, t) => {
302
- const l = n.__vccOpts || n;
303
- for (const [i, a] of t)
304
- l[i] = a;
305
- return l;
306
- }, ze = ["src", "alt"], je = {
301
+ const ae = (t, n) => {
302
+ const o = t.__vccOpts || t;
303
+ for (const [a, r] of n)
304
+ o[a] = r;
305
+ return o;
306
+ }, Oe = ["src", "alt"], ze = {
307
307
  __name: "SvgIcon",
308
308
  props: {
309
309
  // 图标名称或完整URL
@@ -332,14 +332,14 @@ const W = (n, t) => {
332
332
  default: "/icons/"
333
333
  }
334
334
  },
335
- setup(n) {
336
- const t = n, l = M(() => {
337
- if (t.name.startsWith("http://") || t.name.startsWith("https://") || t.name.startsWith("/"))
338
- return t.name;
339
- const e = t.name.endsWith(".svg") ? t.name : `${t.name}.svg`;
340
- return `${t.basePath}${e}`;
341
- }), i = M(() => {
342
- const e = typeof t.size == "number" ? `${t.size}px` : t.size;
335
+ setup(t) {
336
+ const n = t, o = q(() => {
337
+ if (n.name.startsWith("http://") || n.name.startsWith("https://") || n.name.startsWith("/"))
338
+ return n.name;
339
+ const e = n.name.endsWith(".svg") ? n.name : `${n.name}.svg`;
340
+ return `${n.basePath}${e}`;
341
+ }), a = q(() => {
342
+ const e = typeof n.size == "number" ? `${n.size}px` : n.size;
343
343
  return {
344
344
  width: e,
345
345
  height: e,
@@ -347,179 +347,188 @@ const W = (n, t) => {
347
347
  justifyContent: "center",
348
348
  alignItems: "center"
349
349
  };
350
- }), a = M(() => {
350
+ }), r = q(() => {
351
351
  const e = {
352
352
  width: "100%",
353
353
  height: "100%"
354
354
  };
355
- return t.color && (e.filter = `drop-shadow(0 0 0 ${t.color})`), e;
355
+ return n.color && (e.filter = `drop-shadow(0 0 0 ${n.color})`), e;
356
356
  });
357
- return (e, d) => (O(), z("div", {
357
+ return (e, i) => (P(), O("div", {
358
358
  class: "svg-icon-wrapper",
359
- style: G(i.value)
359
+ style: K(a.value)
360
360
  }, [
361
- _("img", {
362
- src: l.value,
363
- alt: n.name,
364
- class: H(["svg-icon", n.className]),
365
- style: G(a.value)
366
- }, null, 14, ze)
361
+ k("img", {
362
+ src: o.value,
363
+ alt: t.name,
364
+ class: H(["svg-icon", t.className]),
365
+ style: K(r.value)
366
+ }, null, 14, Oe)
367
367
  ], 4));
368
368
  }
369
- }, J = /* @__PURE__ */ W(je, [["__scopeId", "data-v-490b11c1"]]), Ne = async (n) => {
369
+ }, W = /* @__PURE__ */ ae(ze, [["__scopeId", "data-v-490b11c1"]]), je = async (t) => {
370
370
  if (navigator.clipboard && navigator.permissions)
371
- await navigator.clipboard.writeText(n);
371
+ await navigator.clipboard.writeText(t);
372
372
  else {
373
- const t = document.createElement("textArea");
374
- t.value = n, 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);
373
+ const n = document.createElement("textArea");
374
+ n.value = t, n.style.width = 0, n.style.position = "fixed", n.style.left = "-999px", n.style.top = "10px", n.setAttribute("readonly", "readonly"), document.body.appendChild(n), n.select(), document.execCommand("copy"), document.body.removeChild(n);
375
375
  }
376
- }, Ue = ["innerHTML"], Ie = {
376
+ }, Ee = ["innerHTML"], Ie = {
377
377
  __name: "Previewer",
378
378
  props: {
379
379
  reader: null,
380
380
  model: "szjy",
381
381
  scrollToBottomFn: null,
382
- displayText: ""
382
+ displayText: "",
383
+ messagePostRender: {
384
+ type: Function,
385
+ default: null
386
+ }
383
387
  },
384
388
  emits: [
385
389
  "failed",
386
390
  "completed",
387
391
  "updating"
388
392
  ],
389
- setup(n, { expose: t, emit: l }) {
390
- const { appContext: i } = re(), { $message: a } = i.config.globalProperties, e = n, d = C(e.displayText || ""), S = C(""), h = C(!0), g = C(!1), R = C(!!e.displayText), L = l, q = C(null);
391
- let x = null;
392
- const N = M(() => F ? F.render(d.value) : d.value), U = () => {
393
- e.reader && e.reader.cancel(), g.value = !0, o.value = !1, u(), R.value = !0, L("completed", d.value), h.value = !1, x && (cancelAnimationFrame(x), x = null);
394
- }, E = M(() => `${N.value}`), f = C(!1), c = () => {
393
+ setup(t, { expose: n, emit: o }) {
394
+ const { appContext: a } = ne(), { $message: r } = a.config.globalProperties, e = t, i = C(e.displayText || ""), v = C(""), h = C(!0), y = C(!1), L = C(!!e.displayText), N = o, A = C(null);
395
+ let _ = null;
396
+ const j = q(() => B ? B.render(i.value) : i.value), E = () => {
397
+ e.reader && e.reader.cancel(), y.value = !0, l.value = !1, d(), L.value = !0, N("completed", i.value), h.value = !1, _ && (cancelAnimationFrame(_), _ = null);
398
+ }, M = q(() => `${j.value}`), f = C(!1), u = () => {
395
399
  f.value = !0;
396
- }, u = () => {
400
+ }, d = () => {
397
401
  f.value = !1;
398
- }, o = C(!1), r = async () => {
402
+ }, l = C(!1), s = async () => {
399
403
  if (!e.reader) return;
400
- const y = new TextDecoder("utf-8");
401
- for (h.value = !0; !g.value; )
404
+ const b = new TextDecoder("utf-8");
405
+ for (h.value = !0; !y.value; )
402
406
  try {
403
407
  if (!e.reader) {
404
- o.value = !0;
408
+ l.value = !0;
405
409
  break;
406
410
  }
407
- const { value: s, done: m } = await e.reader.read();
411
+ const { value: c, done: m } = await e.reader.read();
408
412
  if (!e.reader) {
409
- o.value = !0;
413
+ l.value = !0;
410
414
  break;
411
415
  }
412
416
  if (m) {
413
- o.value = !0;
417
+ l.value = !0;
414
418
  break;
415
419
  }
416
- const b = ee[e.model];
417
- if (!b)
420
+ const w = Z[e.model];
421
+ if (!w)
418
422
  break;
419
- const T = b.call(ee, s, y);
423
+ const T = w.call(Z, c, b);
420
424
  if (T.done) {
421
- o.value = !0;
425
+ l.value = !0;
422
426
  break;
423
427
  }
424
- S.value += T.content, x === null && k();
425
- } catch (s) {
426
- o.value = !0, console.log(3333, s), L("failed", s), U();
428
+ v.value += T.content, _ === null && S();
429
+ } catch (c) {
430
+ l.value = !0, console.log(3333, c), N("failed", c), E();
427
431
  break;
428
432
  } finally {
429
- u();
433
+ d();
430
434
  }
431
- }, v = async () => {
435
+ }, g = async () => {
432
436
  e.scrollToBottomFn && e.scrollToBottomFn();
433
- }, p = (y = () => {
434
- }, s = () => {
437
+ }, p = (b = () => {
438
+ }, c = () => {
435
439
  }) => {
436
- if (S.value.length > 0) {
437
- const m = S.value.substring(0, 10);
438
- d.value += m, S.value = S.value.substring(10), y();
440
+ if (v.value.length > 0) {
441
+ const m = v.value.substring(0, 10);
442
+ i.value += m, v.value = v.value.substring(10), b();
439
443
  } else
440
- s();
441
- }, k = () => {
442
- if (g.value && x) {
443
- cancelAnimationFrame(x), x = null, h.value = !1;
444
+ c();
445
+ }, S = () => {
446
+ if (y.value && _) {
447
+ cancelAnimationFrame(_), _ = null, h.value = !1;
444
448
  return;
445
449
  }
446
- o.value ? p(
450
+ l.value ? p(
447
451
  () => {
448
- x = requestAnimationFrame(k), L("updating", null);
452
+ _ = requestAnimationFrame(S), N("updating", null);
449
453
  },
450
454
  () => {
451
- L("completed", d.value), h.value = !1, R.value = !0, ae(() => {
452
- o.value = !1;
453
- }), x = null;
455
+ N("completed", i.value), h.value = !1, L.value = !0, oe(() => {
456
+ if (l.value = !1, e.messagePostRender && A.value)
457
+ try {
458
+ e.messagePostRender(A.value, i.value);
459
+ } catch (b) {
460
+ console.error("messagePostRender 执行失败:", b);
461
+ }
462
+ }), _ = null;
454
463
  }
455
- ) : (p(), x = requestAnimationFrame(k)), v();
464
+ ) : (p(), _ = requestAnimationFrame(S)), g();
456
465
  };
457
466
  ie(
458
467
  () => e.reader,
459
468
  () => {
460
- e.reader && r();
469
+ e.reader && s();
461
470
  },
462
471
  {
463
472
  immediate: !0,
464
473
  deep: !0
465
474
  }
466
475
  ), ce(() => {
467
- U();
468
- }), t({
469
- abortReader: U,
470
- initializeStart: c,
471
- initializeEnd: u
472
- }), M(() => f.value ? !0 : (!e.reader || !h || d.value, !1));
473
- const w = async () => {
476
+ E();
477
+ }), n({
478
+ abortReader: E,
479
+ initializeStart: u,
480
+ initializeEnd: d
481
+ }), q(() => f.value ? !0 : (!e.reader || !h || i.value, !1));
482
+ const x = async () => {
474
483
  try {
475
- const y = d.value;
476
- await Ne(y), a.success("复制成功");
477
- } catch (y) {
478
- console.error("复制失败:", y), a.error("复制失败");
484
+ const b = i.value;
485
+ await je(b), r.success("复制成功");
486
+ } catch (b) {
487
+ console.error("复制失败:", b), r.error("复制失败");
479
488
  }
480
489
  };
481
- return (y, s) => (O(), Q(oe, { name: "fade" }, {
482
- default: B(() => [
483
- E.value ? (O(), z("div", {
490
+ return (b, c) => (P(), J(re, { name: "fade" }, {
491
+ default: F(() => [
492
+ M.value ? (P(), O("div", {
484
493
  key: 0,
485
494
  ref_key: "refWrapperContent",
486
- ref: q,
495
+ ref: A,
487
496
  "text-16": "",
488
497
  class: "w-full h-full overflow-y-auto relative",
489
498
  "p-24px": ""
490
499
  }, [
491
- _("div", {
500
+ k("div", {
492
501
  class: "markdown-wrapper",
493
- innerHTML: E.value
494
- }, null, 8, Ue),
495
- R.value ? (O(), z("div", {
502
+ innerHTML: M.value
503
+ }, null, 8, Ee),
504
+ L.value ? (P(), O("div", {
496
505
  key: 0,
497
- class: "copy-btn-wrapper",
498
- onClick: w
506
+ class: "ai-copy-btn-wrapper",
507
+ onClick: x
499
508
  }, [
500
- A(J, {
509
+ $(W, {
501
510
  name: "/images/svg/copy.svg",
502
511
  color: "#666666"
503
512
  }),
504
- s[0] || (s[0] = _("span", { class: "copy-text" }, "复制", -1))
505
- ])) : V("", !0)
506
- ], 512)) : V("", !0)
513
+ c[0] || (c[0] = k("span", { class: "copy-text" }, "复制", -1))
514
+ ])) : D("", !0)
515
+ ], 512)) : D("", !0)
507
516
  ]),
508
517
  _: 1
509
518
  }));
510
519
  }
511
- }, $e = /* @__PURE__ */ W(Ie, [["__scopeId", "data-v-e07fd8c0"]]), Ae = { class: "panel-header" }, Ee = { class: "header-actions" }, Me = { class: "header-title" }, qe = { class: "action-icons" }, Be = { class: "body-content" }, Fe = {
520
+ }, Ue = { class: "panel-header" }, $e = { class: "header-actions" }, Ae = { class: "header-title" }, Me = { class: "action-icons" }, qe = { class: "body-content" }, Fe = {
512
521
  key: 0,
513
522
  class: "welcome-content"
514
- }, Ve = { class: "subtitle" }, De = { class: "highlight" }, Je = { class: "quick-questions" }, We = ["onClick"], He = {
523
+ }, Be = { class: "subtitle" }, De = { class: "highlight" }, Ve = { class: "quick-questions" }, We = ["onClick"], He = {
515
524
  key: 1,
516
525
  class: "message-content user-content"
517
- }, Qe = { class: "panel-footer" }, Ke = {
526
+ }, Je = { class: "panel-footer" }, Qe = {
518
527
  key: 0,
519
- src: ye,
528
+ src: ge,
520
529
  alt: "加载中",
521
530
  class: "loading-icon"
522
- }, Ge = { class: "input-box" }, Xe = ["src"], Ye = {
531
+ }, Ke = { class: "input-box" }, Xe = ["src"], Ge = {
523
532
  __name: "ChatPanel",
524
533
  props: {
525
534
  modelValue: {
@@ -541,110 +550,114 @@ const W = (n, t) => {
541
550
  title: {
542
551
  type: String,
543
552
  default: "数智AI助理"
553
+ },
554
+ messagePostRender: {
555
+ type: Function,
556
+ default: null
544
557
  }
545
558
  },
546
559
  emits: ["update:modelValue", "submit"],
547
- setup(n, { emit: t }) {
548
- const { appContext: l } = re(), { $message: i } = l.config.globalProperties, a = ge("llmName") || "szjy", e = M(() => Pe.find((m) => m.modelName === a)), d = n, S = t, h = C(""), g = C(null), R = C(!1), L = C([]), q = C([
560
+ setup(t, { emit: n }) {
561
+ const { appContext: o } = ne(), { $message: a } = o.config.globalProperties, r = ye("llmName") || "szjy", e = q(() => Re.find((m) => m.modelName === r)), i = t, v = n, h = C(""), y = C(null), L = C(!1), N = C([]), A = C([
549
562
  "什么是AI助理,能做什么?",
550
563
  "当前项目的基本情况?",
551
564
  "当前项目的进度情况?",
552
565
  "当前项目的参建方有哪些?",
553
566
  "数智建管平台有哪些功能?能做什么?"
554
- ]), x = C([]), N = C(!1), U = C(null), E = () => {
555
- ae(() => {
556
- if (U.value) {
557
- const m = U.value, b = m.scrollHeight, T = m.scrollTop, I = m.clientHeight;
558
- b - T - I < 100 ? m.scrollTop = b : m.scrollTo({
559
- top: b
567
+ ]), _ = C([]), j = C(!1), E = C(null), M = () => {
568
+ oe(() => {
569
+ if (E.value) {
570
+ const m = E.value, w = m.scrollHeight, T = m.scrollTop, I = m.clientHeight;
571
+ w - T - I < 100 ? m.scrollTop = w : m.scrollTo({
572
+ top: w
560
573
  });
561
574
  }
562
575
  });
563
- }, f = C(!1), c = M(() => f.value ? "/images/ai-stop.png" : "/images/ai-send.png"), u = (m, b) => {
564
- console.log("onFailedReader", m, b), N.value = !1;
565
- const T = y();
566
- T && T.initializeEnd(), i.error("转换失败,请重试"), f.value = !1, setTimeout(() => {
567
- g.value && g.value.focus();
576
+ }, f = C(!1), u = q(() => f.value ? "/images/ai-stop.png" : "/images/ai-send.png"), d = (m, w) => {
577
+ console.log("onFailedReader", m, w), j.value = !1;
578
+ const T = b();
579
+ T && T.initializeEnd(), a.error("转换失败,请重试"), f.value = !1, setTimeout(() => {
580
+ y.value && y.value.focus();
568
581
  });
569
- }, o = (m, b) => {
570
- N.value = !1, f.value = !1, E(), b && L.value[m] && (L.value[m].displayText = b), setTimeout(() => {
571
- g.value && g.value.focus();
582
+ }, l = (m, w) => {
583
+ j.value = !1, f.value = !1, M(), w && N.value[m] && (N.value[m].displayText = w), setTimeout(() => {
584
+ y.value && y.value.focus();
572
585
  });
573
- }, r = (m) => {
586
+ }, s = (m) => {
574
587
  f.value = !0;
575
- }, v = () => {
576
- f.value = !1, S("update:modelValue", !1), R.value = !1, L.value = [];
577
- }, p = C(!1), k = () => {
588
+ }, g = () => {
589
+ f.value = !1, v("update:modelValue", !1), L.value = !1, N.value = [];
590
+ }, p = C(!1), S = () => {
578
591
  p.value = !p.value;
579
- }, w = (m) => {
580
- h.value = m, s();
581
- }, y = () => {
582
- for (let m = x.value.length - 1; m >= 0; m--)
583
- if (x.value[m])
584
- return x.value[m];
592
+ }, x = (m) => {
593
+ h.value = m, c();
594
+ }, b = () => {
595
+ for (let m = _.value.length - 1; m >= 0; m--)
596
+ if (_.value[m])
597
+ return _.value[m];
585
598
  return null;
586
- }, s = async () => {
587
- if (console.log("stylizingLoading:", N.value), N.value) {
588
- const P = y();
589
- console.log("lastPreviewer:", P), P && (console.log("abortReader"), P.abortReader());
599
+ }, c = async () => {
600
+ if (console.log("stylizingLoading:", j.value), j.value) {
601
+ const R = b();
602
+ console.log("lastPreviewer:", R), R && (console.log("abortReader"), R.abortReader());
590
603
  return;
591
604
  }
592
605
  if (!h.value.trim()) {
593
- console.log("no input, return"), g.value.focus();
606
+ console.log("no input, return"), y.value.focus();
594
607
  return;
595
608
  }
596
- L.value.push({
609
+ N.value.push({
597
610
  type: "user",
598
611
  content: h.value
599
- }), f.value = !0, R.value = !0, S("submit", h.value), E();
612
+ }), f.value = !0, L.value = !0, v("submit", h.value), M();
600
613
  const m = h.value;
601
614
  h.value = "";
602
- const b = L.value.length;
603
- x.value[b] && x.value[b].initializeStart(), N.value = !0, L.value.push({
615
+ const w = N.value.length;
616
+ _.value[w] && _.value[w].initializeStart(), j.value = !0, N.value.push({
604
617
  type: "ai"
605
618
  });
606
619
  const { error: T, reader: I } = await Le(e.value, {
607
620
  text: m,
608
- token: d.token,
609
- identifier: d.identifier,
610
- baseUrl: d.baseUrl
621
+ token: i.token,
622
+ identifier: i.identifier,
623
+ baseUrl: i.baseUrl
611
624
  });
612
625
  if (T) {
613
- console.log(45455, T), u(b, T);
626
+ console.log(45455, T), d(w, T);
614
627
  return;
615
628
  }
616
- I && (L.value[b].reader = I);
629
+ I && (N.value[w].reader = I);
617
630
  };
618
- return (m, b) => {
631
+ return (m, w) => {
619
632
  const T = X("el-icon"), I = X("el-input");
620
- return O(), Q(oe, { name: "slide" }, {
621
- default: B(() => [
622
- n.modelValue ? (O(), z("div", {
633
+ return P(), J(re, { name: "slide" }, {
634
+ default: F(() => [
635
+ t.modelValue ? (P(), O("div", {
623
636
  key: 0,
624
637
  class: H(["ai-panel", { "drawer-mode": p.value }])
625
638
  }, [
626
- _("div", Ae, [
627
- _("div", Ee, [
628
- _("div", Me, D(n.title), 1),
629
- _("div", qe, [
630
- A(T, {
639
+ k("div", Ue, [
640
+ k("div", $e, [
641
+ k("div", Ae, V(t.title), 1),
642
+ k("div", Me, [
643
+ $(T, {
631
644
  class: "action-icon",
632
- onClick: k
645
+ onClick: S
633
646
  }, {
634
- default: B(() => [
635
- A(J, {
647
+ default: F(() => [
648
+ $(W, {
636
649
  name: "/images/svg/drawer-layout.svg",
637
650
  color: "#999999"
638
651
  })
639
652
  ]),
640
653
  _: 1
641
654
  }),
642
- A(T, {
655
+ $(T, {
643
656
  class: "action-icon",
644
- onClick: v
657
+ onClick: g
645
658
  }, {
646
- default: B(() => [
647
- A(J, {
659
+ default: F(() => [
660
+ $(W, {
648
661
  name: "/images/svg/close.svg",
649
662
  color: "#999999"
650
663
  })
@@ -654,54 +667,55 @@ const W = (n, t) => {
654
667
  ])
655
668
  ])
656
669
  ]),
657
- _("div", Be, [
658
- R.value ? (O(), z("div", {
670
+ k("div", qe, [
671
+ L.value ? (P(), O("div", {
659
672
  key: 1,
660
673
  class: "chat-messages",
661
674
  ref_key: "messageContainerRef",
662
- ref: U
675
+ ref: E
663
676
  }, [
664
- (O(!0), z(Y, null, Z(L.value, (P, $) => (O(), z("div", {
665
- key: $,
666
- class: H(["message-item", P.type === "user" ? "user-message" : "ai-message"])
677
+ (P(!0), O(G, null, Y(N.value, (R, U) => (P(), O("div", {
678
+ key: U,
679
+ class: H(["message-item", R.type === "user" ? "user-message" : "ai-message"])
667
680
  }, [
668
- P.type === "ai" ? (O(), Q($e, {
681
+ R.type === "ai" ? (P(), J(Ie, {
669
682
  key: 0,
670
683
  ref_for: !0,
671
- ref: (j) => x.value[$] = j,
672
- reader: P.reader,
673
- "onUpdate:reader": (j) => P.reader = j,
674
- model: de(a),
675
- displayText: P.displayText,
676
- scrollToBottomFn: E,
677
- onFailed: (j) => u($, j),
678
- onCompleted: (j) => o($, j),
679
- onUpdating: () => r()
680
- }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "onFailed", "onCompleted", "onUpdating"])) : (O(), z("div", He, D(P.content), 1))
684
+ ref: (z) => _.value[U] = z,
685
+ reader: R.reader,
686
+ "onUpdate:reader": (z) => R.reader = z,
687
+ model: de(r),
688
+ displayText: R.displayText,
689
+ scrollToBottomFn: M,
690
+ messagePostRender: t.messagePostRender,
691
+ onFailed: (z) => d(U, z),
692
+ onCompleted: (z) => l(U, z),
693
+ onUpdating: () => s()
694
+ }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (P(), O("div", He, V(R.content), 1))
681
695
  ], 2))), 128))
682
- ], 512)) : (O(), z("div", Fe, [
683
- b[2] || (b[2] = _("div", { class: "title" }, [
684
- _("img", {
685
- src: he,
696
+ ], 512)) : (P(), O("div", Fe, [
697
+ w[2] || (w[2] = k("div", { class: "title" }, [
698
+ k("img", {
699
+ src: ve,
686
700
  alt: "AI助手",
687
701
  class: "panel-icon"
688
702
  }),
689
- _("h3", { class: "title-text" }, "Hi, 您好")
703
+ k("h3", { class: "title-text" }, "Hi, 您好")
690
704
  ], -1)),
691
- _("div", Ve, [
692
- b[1] || (b[1] = ue(" 我是")),
693
- _("span", De, D(n.title), 1)
705
+ k("div", Be, [
706
+ w[1] || (w[1] = ue(" 我是", -1)),
707
+ k("span", De, V(t.title), 1)
694
708
  ]),
695
- _("div", Je, [
696
- (O(!0), z(Y, null, Z(q.value, (P, $) => (O(), z("div", {
697
- key: $,
709
+ k("div", Ve, [
710
+ (P(!0), O(G, null, Y(A.value, (R, U) => (P(), O("div", {
711
+ key: U,
698
712
  class: "question-item",
699
- onClick: (j) => w(P)
713
+ onClick: (z) => x(R)
700
714
  }, [
701
- _("span", null, D(P), 1),
702
- A(T, null, {
703
- default: B(() => [
704
- A(J, {
715
+ k("span", null, V(R), 1),
716
+ $(T, null, {
717
+ default: F(() => [
718
+ $(W, {
705
719
  name: "/images/svg/arrow-right.svg",
706
720
  color: "#999999"
707
721
  })
@@ -712,25 +726,25 @@ const W = (n, t) => {
712
726
  ])
713
727
  ]))
714
728
  ]),
715
- _("div", Qe, [
716
- f.value ? (O(), z("img", Ke)) : V("", !0),
717
- _("div", Ge, [
718
- A(I, {
729
+ k("div", Je, [
730
+ f.value ? (P(), O("img", Qe)) : D("", !0),
731
+ k("div", Ke, [
732
+ $(I, {
719
733
  modelValue: h.value,
720
- "onUpdate:modelValue": b[0] || (b[0] = (P) => h.value = P),
734
+ "onUpdate:modelValue": w[0] || (w[0] = (R) => h.value = R),
721
735
  ref_key: "refInputTextString",
722
- ref: g,
736
+ ref: y,
723
737
  placeholder: "请输入您的问题",
724
738
  autofocus: "",
725
- onKeyup: fe(s, ["enter"])
739
+ onKeyup: fe(c, ["enter"])
726
740
  }, {
727
- append: B(() => [
728
- _("div", {
741
+ append: F(() => [
742
+ k("div", {
729
743
  class: "send-icon-box",
730
- onClick: s
744
+ onClick: c
731
745
  }, [
732
- _("img", {
733
- src: c.value,
746
+ k("img", {
747
+ src: u.value,
734
748
  alt: "发送",
735
749
  class: "send-icon"
736
750
  }, null, 8, Xe)
@@ -740,226 +754,226 @@ const W = (n, t) => {
740
754
  }, 8, ["modelValue"])
741
755
  ])
742
756
  ])
743
- ], 2)) : V("", !0)
757
+ ], 2)) : D("", !0)
744
758
  ]),
745
759
  _: 1
746
760
  });
747
761
  };
748
762
  }
749
- }, Ze = /* @__PURE__ */ W(Ye, [["__scopeId", "data-v-cf96dd03"]]);
763
+ };
750
764
  var se = { exports: {} };
751
- (function(n, t) {
752
- (function(l, i) {
753
- n.exports = i();
765
+ (function(t, n) {
766
+ (function(o, a) {
767
+ t.exports = a();
754
768
  })(window, function() {
755
- return function(l) {
756
- var i = {};
757
- function a(e) {
758
- if (i[e]) return i[e].exports;
759
- var d = i[e] = { i: e, l: !1, exports: {} };
760
- return l[e].call(d.exports, d, d.exports, a), d.l = !0, d.exports;
769
+ return function(o) {
770
+ var a = {};
771
+ function r(e) {
772
+ if (a[e]) return a[e].exports;
773
+ var i = a[e] = { i: e, l: !1, exports: {} };
774
+ return o[e].call(i.exports, i, i.exports, r), i.l = !0, i.exports;
761
775
  }
762
- return a.m = l, a.c = i, a.d = function(e, d, S) {
763
- a.o(e, d) || Object.defineProperty(e, d, { enumerable: !0, get: S });
764
- }, a.r = function(e) {
776
+ return r.m = o, r.c = a, r.d = function(e, i, v) {
777
+ r.o(e, i) || Object.defineProperty(e, i, { enumerable: !0, get: v });
778
+ }, r.r = function(e) {
765
779
  typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 });
766
- }, a.t = function(e, d) {
767
- if (1 & d && (e = a(e)), 8 & d || 4 & d && typeof e == "object" && e && e.__esModule) return e;
768
- var S = /* @__PURE__ */ Object.create(null);
769
- if (a.r(S), Object.defineProperty(S, "default", { enumerable: !0, value: e }), 2 & d && typeof e != "string") for (var h in e) a.d(S, h, (function(g) {
770
- return e[g];
780
+ }, r.t = function(e, i) {
781
+ if (1 & i && (e = r(e)), 8 & i || 4 & i && typeof e == "object" && e && e.__esModule) return e;
782
+ var v = /* @__PURE__ */ Object.create(null);
783
+ if (r.r(v), Object.defineProperty(v, "default", { enumerable: !0, value: e }), 2 & i && typeof e != "string") for (var h in e) r.d(v, h, (function(y) {
784
+ return e[y];
771
785
  }).bind(null, h));
772
- return S;
773
- }, a.n = function(e) {
774
- var d = e && e.__esModule ? function() {
786
+ return v;
787
+ }, r.n = function(e) {
788
+ var i = e && e.__esModule ? function() {
775
789
  return e.default;
776
790
  } : function() {
777
791
  return e;
778
792
  };
779
- return a.d(d, "a", d), d;
780
- }, a.o = function(e, d) {
781
- return Object.prototype.hasOwnProperty.call(e, d);
782
- }, a.p = "", a(a.s = 0);
783
- }([function(l, i, a) {
784
- function e(f, c, u, o) {
785
- u.push(f), o.push([].concat(c[f] || []));
793
+ return r.d(i, "a", i), i;
794
+ }, r.o = function(e, i) {
795
+ return Object.prototype.hasOwnProperty.call(e, i);
796
+ }, r.p = "", r(r.s = 0);
797
+ }([function(o, a, r) {
798
+ function e(f, u, d, l) {
799
+ d.push(f), l.push([].concat(u[f] || []));
786
800
  }
787
- function d(f, c) {
801
+ function i(f, u) {
788
802
  if (!f) throw new Error("[getMaxDepsChain] dep 参数不能为空");
789
- var u = [], o = [], r = [];
790
- for (e(f, c, o, r); o.length; ) {
791
- var v = r.pop();
792
- if (v && v.length) {
793
- var p = v.shift();
794
- if (r.push(v), ~o.indexOf(p)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + p + ", mainStack: " + o);
795
- e(p, c, o, r);
796
- } else u.push([].concat(o)), o.pop();
803
+ var d = [], l = [], s = [];
804
+ for (e(f, u, l, s); l.length; ) {
805
+ var g = s.pop();
806
+ if (g && g.length) {
807
+ var p = g.shift();
808
+ if (s.push(g), ~l.indexOf(p)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + p + ", mainStack: " + l);
809
+ e(p, u, l, s);
810
+ } else d.push([].concat(l)), l.pop();
797
811
  }
798
- return u.reduce(function(k, w) {
799
- return w.length > k.length ? w : k;
812
+ return d.reduce(function(S, x) {
813
+ return x.length > S.length ? x : S;
800
814
  }, []);
801
815
  }
802
- function S(f) {
816
+ function v(f) {
803
817
  if (!f) throw new Error("[depsParser] 入参不能为空");
804
- var c = {};
805
- f.forEach(function(o) {
806
- c[o.name] = o.deps || [];
818
+ var u = {};
819
+ f.forEach(function(l) {
820
+ u[l.name] = l.deps || [];
807
821
  });
808
- var u = [];
809
- return f.forEach(function(o) {
810
- var r = d(o.name, c).length - 1;
811
- o.priority = r, u[r] = (u[r] || []).concat(o);
812
- }), u;
822
+ var d = [];
823
+ return f.forEach(function(l) {
824
+ var s = i(l.name, u).length - 1;
825
+ l.priority = s, d[s] = (d[s] || []).concat(l);
826
+ }), d;
813
827
  }
814
- a.r(i), a.d(i, "loadScript", function() {
815
- return q;
816
- }), a.d(i, "loadScripts", function() {
817
- return x;
818
- }), a.d(i, "dynamicLoadScripts", function() {
819
- return N;
820
- }), a.d(i, "createScriptsLoadIterator", function() {
821
- return U;
822
- }), a.d(i, "loadScriptsQueue", function() {
828
+ r.r(a), r.d(a, "loadScript", function() {
829
+ return A;
830
+ }), r.d(a, "loadScripts", function() {
831
+ return _;
832
+ }), r.d(a, "dynamicLoadScripts", function() {
833
+ return j;
834
+ }), r.d(a, "createScriptsLoadIterator", function() {
823
835
  return E;
824
- }), a.d(i, "getMaxDepsChain", function() {
825
- return d;
826
- }), a.d(i, "depsParser", function() {
827
- return S;
836
+ }), r.d(a, "loadScriptsQueue", function() {
837
+ return M;
838
+ }), r.d(a, "getMaxDepsChain", function() {
839
+ return i;
840
+ }), r.d(a, "depsParser", function() {
841
+ return v;
828
842
  });
829
843
  var h = function() {
830
844
  return (h = Object.assign || function(f) {
831
- for (var c, u = 1, o = arguments.length; u < o; u++) for (var r in c = arguments[u]) Object.prototype.hasOwnProperty.call(c, r) && (f[r] = c[r]);
845
+ for (var u, d = 1, l = arguments.length; d < l; d++) for (var s in u = arguments[d]) Object.prototype.hasOwnProperty.call(u, s) && (f[s] = u[s]);
832
846
  return f;
833
847
  }).apply(this, arguments);
834
- }, g = function(f, c, u, o) {
835
- return new (u || (u = Promise))(function(r, v) {
836
- function p(y) {
848
+ }, y = function(f, u, d, l) {
849
+ return new (d || (d = Promise))(function(s, g) {
850
+ function p(b) {
837
851
  try {
838
- w(o.next(y));
839
- } catch (s) {
840
- v(s);
852
+ x(l.next(b));
853
+ } catch (c) {
854
+ g(c);
841
855
  }
842
856
  }
843
- function k(y) {
857
+ function S(b) {
844
858
  try {
845
- w(o.throw(y));
846
- } catch (s) {
847
- v(s);
859
+ x(l.throw(b));
860
+ } catch (c) {
861
+ g(c);
848
862
  }
849
863
  }
850
- function w(y) {
851
- var s;
852
- y.done ? r(y.value) : (s = y.value, s instanceof u ? s : new u(function(m) {
853
- m(s);
854
- })).then(p, k);
864
+ function x(b) {
865
+ var c;
866
+ b.done ? s(b.value) : (c = b.value, c instanceof d ? c : new d(function(m) {
867
+ m(c);
868
+ })).then(p, S);
855
869
  }
856
- w((o = o.apply(f, [])).next());
870
+ x((l = l.apply(f, [])).next());
857
871
  });
858
- }, R = function(f, c) {
859
- var u, o, r, v, p = { label: 0, sent: function() {
860
- if (1 & r[0]) throw r[1];
861
- return r[1];
872
+ }, L = function(f, u) {
873
+ var d, l, s, g, p = { label: 0, sent: function() {
874
+ if (1 & s[0]) throw s[1];
875
+ return s[1];
862
876
  }, trys: [], ops: [] };
863
- return v = { next: k(0), throw: k(1), return: k(2) }, typeof Symbol == "function" && (v[Symbol.iterator] = function() {
877
+ return g = { next: S(0), throw: S(1), return: S(2) }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
864
878
  return this;
865
- }), v;
866
- function k(w) {
867
- return function(y) {
868
- return function(s) {
869
- if (u) throw new TypeError("Generator is already executing.");
879
+ }), g;
880
+ function S(x) {
881
+ return function(b) {
882
+ return function(c) {
883
+ if (d) throw new TypeError("Generator is already executing.");
870
884
  for (; p; ) try {
871
- if (u = 1, o && (r = 2 & s[0] ? o.return : s[0] ? o.throw || ((r = o.return) && r.call(o), 0) : o.next) && !(r = r.call(o, s[1])).done) return r;
872
- switch (o = 0, r && (s = [2 & s[0], r.value]), s[0]) {
885
+ if (d = 1, l && (s = 2 & c[0] ? l.return : c[0] ? l.throw || ((s = l.return) && s.call(l), 0) : l.next) && !(s = s.call(l, c[1])).done) return s;
886
+ switch (l = 0, s && (c = [2 & c[0], s.value]), c[0]) {
873
887
  case 0:
874
888
  case 1:
875
- r = s;
889
+ s = c;
876
890
  break;
877
891
  case 4:
878
- return p.label++, { value: s[1], done: !1 };
892
+ return p.label++, { value: c[1], done: !1 };
879
893
  case 5:
880
- p.label++, o = s[1], s = [0];
894
+ p.label++, l = c[1], c = [0];
881
895
  continue;
882
896
  case 7:
883
- s = p.ops.pop(), p.trys.pop();
897
+ c = p.ops.pop(), p.trys.pop();
884
898
  continue;
885
899
  default:
886
- if (r = p.trys, !((r = r.length > 0 && r[r.length - 1]) || s[0] !== 6 && s[0] !== 2)) {
900
+ if (s = p.trys, !((s = s.length > 0 && s[s.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
887
901
  p = 0;
888
902
  continue;
889
903
  }
890
- if (s[0] === 3 && (!r || s[1] > r[0] && s[1] < r[3])) {
891
- p.label = s[1];
904
+ if (c[0] === 3 && (!s || c[1] > s[0] && c[1] < s[3])) {
905
+ p.label = c[1];
892
906
  break;
893
907
  }
894
- if (s[0] === 6 && p.label < r[1]) {
895
- p.label = r[1], r = s;
908
+ if (c[0] === 6 && p.label < s[1]) {
909
+ p.label = s[1], s = c;
896
910
  break;
897
911
  }
898
- if (r && p.label < r[2]) {
899
- p.label = r[2], p.ops.push(s);
912
+ if (s && p.label < s[2]) {
913
+ p.label = s[2], p.ops.push(c);
900
914
  break;
901
915
  }
902
- r[2] && p.ops.pop(), p.trys.pop();
916
+ s[2] && p.ops.pop(), p.trys.pop();
903
917
  continue;
904
918
  }
905
- s = c.call(f, p);
919
+ c = u.call(f, p);
906
920
  } catch (m) {
907
- s = [6, m], o = 0;
921
+ c = [6, m], l = 0;
908
922
  } finally {
909
- u = r = 0;
923
+ d = s = 0;
910
924
  }
911
- if (5 & s[0]) throw s[1];
912
- return { value: s[0] ? s[1] : void 0, done: !0 };
913
- }([w, y]);
925
+ if (5 & c[0]) throw c[1];
926
+ return { value: c[0] ? c[1] : void 0, done: !0 };
927
+ }([x, b]);
914
928
  };
915
929
  }
916
- }, L = function(f) {
930
+ }, N = function(f) {
917
931
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
918
- var c, u = f[Symbol.asyncIterator];
919
- return u ? u.call(f) : (f = typeof __values == "function" ? __values(f) : f[Symbol.iterator](), c = {}, o("next"), o("throw"), o("return"), c[Symbol.asyncIterator] = function() {
932
+ var u, d = f[Symbol.asyncIterator];
933
+ return d ? d.call(f) : (f = typeof __values == "function" ? __values(f) : f[Symbol.iterator](), u = {}, l("next"), l("throw"), l("return"), u[Symbol.asyncIterator] = function() {
920
934
  return this;
921
- }, c);
922
- function o(r) {
923
- c[r] = f[r] && function(v) {
924
- return new Promise(function(p, k) {
925
- (function(w, y, s, m) {
926
- Promise.resolve(m).then(function(b) {
927
- w({ value: b, done: s });
928
- }, y);
929
- })(p, k, (v = f[r](v)).done, v.value);
935
+ }, u);
936
+ function l(s) {
937
+ u[s] = f[s] && function(g) {
938
+ return new Promise(function(p, S) {
939
+ (function(x, b, c, m) {
940
+ Promise.resolve(m).then(function(w) {
941
+ x({ value: w, done: c });
942
+ }, b);
943
+ })(p, S, (g = f[s](g)).done, g.value);
930
944
  });
931
945
  };
932
946
  }
933
947
  };
934
- function q(f, c) {
935
- return c === void 0 && (c = !1), new Promise(function(u, o) {
936
- var r = c ? document.head : document.body, v = document.createElement("script");
937
- v.type = "text/javascript", v.src = f, v.crossOrigin = "anonymous", v.onreadystatechange = u, v.onload = u, v.onerror = o, r.appendChild(v);
948
+ function A(f, u) {
949
+ return u === void 0 && (u = !1), new Promise(function(d, l) {
950
+ var s = u ? document.head : document.body, g = document.createElement("script");
951
+ g.type = "text/javascript", g.src = f, g.crossOrigin = "anonymous", g.onreadystatechange = d, g.onload = d, g.onerror = l, s.appendChild(g);
938
952
  });
939
953
  }
940
- var x = function(f, c) {
941
- return c === void 0 && (c = {}), g(void 0, void 0, void 0, function() {
942
- var u, o, r, v, p;
943
- return R(this, function(k) {
944
- switch (k.label) {
954
+ var _ = function(f, u) {
955
+ return u === void 0 && (u = {}), y(void 0, void 0, void 0, function() {
956
+ var d, l, s, g, p;
957
+ return L(this, function(S) {
958
+ switch (S.label) {
945
959
  case 0:
946
- return u = c.baseUrl, o = u === void 0 ? "" : u, r = c.lastLoadResult, v = c.inHead, p = v !== void 0 && v, [4, Promise.all(f.map(function(w) {
947
- return g(void 0, void 0, void 0, function() {
948
- var y, s, m, b, T, I, P, $;
949
- return R(this, function(j) {
950
- switch (j.label) {
960
+ return d = u.baseUrl, l = d === void 0 ? "" : d, s = u.lastLoadResult, g = u.inHead, p = g !== void 0 && g, [4, Promise.all(f.map(function(x) {
961
+ return y(void 0, void 0, void 0, function() {
962
+ var b, c, m, w, T, I, R, U;
963
+ return L(this, function(z) {
964
+ switch (z.label) {
951
965
  case 0:
952
- return y = w.name, s = w.path, m = w.deps, (P = {})[y] = !0, b = P, ($ = {})[y] = !1, T = $, window[y] ? [2, b] : [3, 1];
966
+ return b = x.name, c = x.path, m = x.deps, (R = {})[b] = !0, w = R, (U = {})[b] = !1, T = U, window[b] ? [2, w] : [3, 1];
953
967
  case 1:
954
- return I = !0, m && r && [].concat(m).forEach(function(le) {
955
- r[le] !== !1 && (I = !0);
956
- }), I ? [4, q(s.indexOf("http") === 0 || s.indexOf("//:") === 0 ? s : o + s, p).then(function() {
957
- return b;
968
+ return I = !0, m && s && [].concat(m).forEach(function(le) {
969
+ s[le] !== !1 && (I = !0);
970
+ }), I ? [4, A(c.indexOf("http") === 0 || c.indexOf("//:") === 0 ? c : l + c, p).then(function() {
971
+ return w;
958
972
  }).catch(function() {
959
973
  return T;
960
974
  })] : [3, 3];
961
975
  case 2:
962
- return [2, j.sent()];
976
+ return [2, z.sent()];
963
977
  case 3:
964
978
  return [2, T];
965
979
  }
@@ -967,50 +981,50 @@ var se = { exports: {} };
967
981
  });
968
982
  }))];
969
983
  case 1:
970
- return [2, k.sent()];
984
+ return [2, S.sent()];
971
985
  }
972
986
  });
973
987
  });
974
- }, N = function(f, c) {
975
- return c === void 0 && (c = {}), function() {
976
- var u = [].concat(S(f));
988
+ }, j = function(f, u) {
989
+ return u === void 0 && (u = {}), function() {
990
+ var d = [].concat(v(f));
977
991
  return { next: function() {
978
- if (u.length) {
979
- var o = u.shift();
980
- return x(o, c).then(function(r) {
981
- return { value: r, done: !1 };
992
+ if (d.length) {
993
+ var l = d.shift();
994
+ return _(l, u).then(function(s) {
995
+ return { value: s, done: !1 };
982
996
  });
983
997
  }
984
998
  return Promise.resolve({ done: !0 });
985
999
  } };
986
1000
  };
987
- }, U = function(f, c) {
988
- var u;
989
- return c === void 0 && (c = {}), (u = {})[Symbol.asyncIterator] = N(f, c), u;
990
- }, E = function(f, c) {
991
- return c === void 0 && (c = {}), g(void 0, void 0, void 0, function() {
992
- var u, o, r, v, p, k;
993
- return R(this, function(w) {
994
- switch (w.label) {
1001
+ }, E = function(f, u) {
1002
+ var d;
1003
+ return u === void 0 && (u = {}), (d = {})[Symbol.asyncIterator] = j(f, u), d;
1004
+ }, M = function(f, u) {
1005
+ return u === void 0 && (u = {}), y(void 0, void 0, void 0, function() {
1006
+ var d, l, s, g, p, S;
1007
+ return L(this, function(x) {
1008
+ switch (x.label) {
995
1009
  case 0:
996
- w.trys.push([0, 5, 6, 11]), u = L(U(f, c)), w.label = 1;
1010
+ x.trys.push([0, 5, 6, 11]), d = N(E(f, u)), x.label = 1;
997
1011
  case 1:
998
- return [4, u.next()];
1012
+ return [4, d.next()];
999
1013
  case 2:
1000
- if ((o = w.sent()).done) return [3, 4];
1001
- r = o.value, c.lastLoadResult = c.lastLoadResult || {}, console.log("current load: ", r), r.forEach(function(y) {
1002
- c.lastLoadResult = h(h({}, c.lastLoadResult), y);
1003
- }), w.label = 3;
1014
+ if ((l = x.sent()).done) return [3, 4];
1015
+ s = l.value, u.lastLoadResult = u.lastLoadResult || {}, console.log("current load: ", s), s.forEach(function(b) {
1016
+ u.lastLoadResult = h(h({}, u.lastLoadResult), b);
1017
+ }), x.label = 3;
1004
1018
  case 3:
1005
1019
  return [3, 1];
1006
1020
  case 4:
1007
1021
  return [3, 11];
1008
1022
  case 5:
1009
- return v = w.sent(), p = { error: v }, [3, 11];
1023
+ return g = x.sent(), p = { error: g }, [3, 11];
1010
1024
  case 6:
1011
- return w.trys.push([6, , 9, 10]), o && !o.done && (k = u.return) ? [4, k.call(u)] : [3, 8];
1025
+ return x.trys.push([6, , 9, 10]), l && !l.done && (S = d.return) ? [4, S.call(d)] : [3, 8];
1012
1026
  case 7:
1013
- w.sent(), w.label = 8;
1027
+ x.sent(), x.label = 8;
1014
1028
  case 8:
1015
1029
  return [3, 10];
1016
1030
  case 9:
@@ -1019,7 +1033,7 @@ var se = { exports: {} };
1019
1033
  case 10:
1020
1034
  return [7];
1021
1035
  case 11:
1022
- return [2, c.lastLoadResult];
1036
+ return [2, u.lastLoadResult];
1023
1037
  }
1024
1038
  });
1025
1039
  });
@@ -1027,15 +1041,15 @@ var se = { exports: {} };
1027
1041
  }]);
1028
1042
  });
1029
1043
  })(se);
1030
- var et = se.exports;
1031
- const tt = {
1044
+ var Ye = se.exports;
1045
+ const Ze = {
1032
1046
  key: 0,
1033
1047
  class: "ai-assistant"
1034
- }, nt = {
1048
+ }, et = {
1035
1049
  name: "AiChat"
1036
1050
  //这个⾮常重要,就是未来你放到其他项⽬中,组件标签的名字,⽐如:<sz-workflow></sz-workflow>
1037
- }, rt = /* @__PURE__ */ pe({
1038
- ...nt,
1051
+ }, tt = /* @__PURE__ */ pe({
1052
+ ...et,
1039
1053
  props: {
1040
1054
  token: {
1041
1055
  type: String,
@@ -1052,16 +1066,26 @@ const tt = {
1052
1066
  title: {
1053
1067
  type: String,
1054
1068
  default: "数智AI助理"
1069
+ },
1070
+ /**
1071
+ * 消息后处理回调函数
1072
+ * 在 AI 消息渲染完成后调用,可用于自定义处理渲染后的内容
1073
+ * @param container - 消息容器的 DOM 元素
1074
+ * @param textContent - 消息的文本内容
1075
+ */
1076
+ messagePostRender: {
1077
+ type: Function,
1078
+ default: null
1055
1079
  }
1056
1080
  },
1057
- setup(n) {
1058
- const t = C(!1), l = C(!1), i = () => {
1059
- t.value = !t.value;
1060
- }, a = () => {
1061
- l.value = !0, t.value = !1;
1081
+ setup(t) {
1082
+ const n = C(!1), o = C(!1), a = () => {
1083
+ n.value = !n.value;
1084
+ }, r = () => {
1085
+ o.value = !0, n.value = !1;
1062
1086
  }, e = (h) => {
1063
1087
  console.log("用户输入:", h);
1064
- }, d = [
1088
+ }, i = [
1065
1089
  {
1066
1090
  name: "markdownit",
1067
1091
  path: "markdown-it.min.js"
@@ -1071,97 +1095,155 @@ const tt = {
1071
1095
  path: "highlight.11.11.1.min.js"
1072
1096
  }
1073
1097
  ];
1074
- let S = {};
1075
- return et.loadScriptsQueue(d, {
1098
+ let v = {};
1099
+ return Ye.loadScriptsQueue(i, {
1076
1100
  baseUrl: "/scripts/ai/",
1077
- lastLoadResult: S,
1101
+ lastLoadResult: v,
1078
1102
  inHead: !1
1079
1103
  }).then((h) => {
1080
1104
  if (console.log("load ai deps: ", h), window.markdownit) {
1081
- const g = window.markdownit();
1082
- console.log("markdownit: ", g), Re();
1105
+ const y = window.markdownit();
1106
+ console.log("markdownit: ", y), Ne();
1083
1107
  }
1084
- }), (h, g) => l.value ? V("", !0) : (O(), z("div", tt, [
1085
- A(Ze, {
1086
- modelValue: t.value,
1087
- "onUpdate:modelValue": g[0] || (g[0] = (R) => t.value = R),
1108
+ }), (h, y) => o.value ? D("", !0) : (P(), O("div", Ze, [
1109
+ $(Ge, {
1110
+ modelValue: n.value,
1111
+ "onUpdate:modelValue": y[0] || (y[0] = (L) => n.value = L),
1088
1112
  onSubmit: e,
1089
- token: n.token,
1090
- identifier: n.identifier,
1091
- baseUrl: n.baseUrl,
1092
- title: n.title
1093
- }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title"]),
1094
- _("div", {
1113
+ token: t.token,
1114
+ identifier: t.identifier,
1115
+ baseUrl: t.baseUrl,
1116
+ title: t.title,
1117
+ messagePostRender: t.messagePostRender
1118
+ }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title", "messagePostRender"]),
1119
+ k("div", {
1095
1120
  class: "ai-icon",
1096
- onClick: i
1121
+ onClick: a
1097
1122
  }, [
1098
- _("div", {
1123
+ k("div", {
1099
1124
  class: "close-icon",
1100
- onClick: me(a, ["stop"])
1101
- }, g[1] || (g[1] = [
1102
- _("svg", {
1125
+ onClick: me(r, ["stop"])
1126
+ }, [...y[1] || (y[1] = [
1127
+ k("svg", {
1103
1128
  viewBox: "0 0 1024 1024",
1104
1129
  width: "8",
1105
1130
  height: "8"
1106
1131
  }, [
1107
- _("path", {
1132
+ k("path", {
1108
1133
  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",
1109
1134
  fill: "currentColor"
1110
1135
  })
1111
1136
  ], -1)
1112
- ])),
1113
- g[2] || (g[2] = _("img", {
1114
- src: ve,
1137
+ ])]),
1138
+ y[2] || (y[2] = k("img", {
1139
+ src: he,
1115
1140
  alt: "AI助手"
1116
1141
  }, null, -1)),
1117
- g[3] || (g[3] = _("span", { class: "ai-icon-text" }, "AI助手", -1))
1142
+ y[3] || (y[3] = k("span", { class: "ai-icon-text" }, "AI助手", -1))
1118
1143
  ])
1119
1144
  ]));
1120
1145
  }
1121
- }), ot = /* @__PURE__ */ W(rt, [["__scopeId", "data-v-4b85f480"]]), ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1146
+ }), nt = /* @__PURE__ */ ae(tt, [["__scopeId", "data-v-a4639f2d"]]), te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1122
1147
  __proto__: null,
1123
- SzAiChat: ot
1124
- }, Symbol.toStringTag, { value: "Module" })), K = function(n) {
1125
- if (!K.installed) {
1126
- K.installed = !0;
1127
- for (let t in ne) {
1128
- const l = Reflect.get(ne, t);
1129
- n.component(l.name, l);
1148
+ SzAiChat: nt
1149
+ }, Symbol.toStringTag, { value: "Module" })), Q = function(t) {
1150
+ if (!Q.installed) {
1151
+ Q.installed = !0;
1152
+ for (let n in te) {
1153
+ const o = Reflect.get(te, n);
1154
+ t.component(o.name, o);
1130
1155
  }
1131
1156
  }
1132
- }, at = "0.1.2", st = "Sz";
1133
- function it({
1134
- componentPrefix: n = st,
1135
- components: t = []
1157
+ }, rt = (t) => {
1158
+ console.log(`点击了路由链接: ${t}`);
1159
+ }, ot = {
1160
+ color: "#536fec",
1161
+ fontWeight: "bold",
1162
+ textDecoration: "underline",
1163
+ cursor: "pointer",
1164
+ padding: "0 3px"
1165
+ }, at = (t) => {
1166
+ const n = /#router:([^#]+)#/g, o = [];
1167
+ let a = 0, r;
1168
+ for (; (r = n.exec(t)) !== null; ) {
1169
+ r.index > a && o.push({ text: t.substring(a, r.index) });
1170
+ const e = r[1];
1171
+ o.push({ text: e, routeName: e }), a = n.lastIndex;
1172
+ }
1173
+ return a < t.length && o.push({ text: t.substring(a) }), o;
1174
+ }, st = (t, n, o = {}) => {
1175
+ const { onRouteClick: a = rt, linkStyle: r = {} } = o, e = document.createElement("a");
1176
+ e.href = "#", e.textContent = t;
1177
+ const i = { ...ot, ...r };
1178
+ return Object.assign(e.style, i), e.addEventListener("click", (v) => {
1179
+ v.preventDefault(), a(n);
1180
+ }), e;
1181
+ }, lt = (t) => {
1182
+ const n = /#router:([^#]+)#/g, o = [], a = document.createTreeWalker(
1183
+ t,
1184
+ NodeFilter.SHOW_TEXT,
1185
+ null
1186
+ );
1187
+ let r = a.nextNode();
1188
+ for (; r; ) {
1189
+ const e = r, i = e.textContent || "";
1190
+ if (n.test(i)) {
1191
+ n.lastIndex = 0;
1192
+ const v = at(i);
1193
+ v.length > 0 && o.push({ node: e, replacements: v });
1194
+ }
1195
+ r = a.nextNode();
1196
+ }
1197
+ return o;
1198
+ }, dt = (t, n, o = {}) => {
1199
+ lt(t).forEach(({ node: r, replacements: e }) => {
1200
+ var v;
1201
+ const i = document.createDocumentFragment();
1202
+ e.forEach(({ text: h, routeName: y }) => {
1203
+ if (y) {
1204
+ const L = st(h, y, o);
1205
+ i.appendChild(L);
1206
+ } else
1207
+ i.appendChild(document.createTextNode(h));
1208
+ }), (v = r.parentNode) == null || v.replaceChild(i, r);
1209
+ });
1210
+ }, it = "0.1.3", ct = "Sz";
1211
+ function ft({
1212
+ componentPrefix: t = ct,
1213
+ components: n = []
1136
1214
  } = {}) {
1137
- const l = [];
1138
- function i(e, d, S) {
1139
- e.component(n + d) || e.component(
1140
- n + d,
1141
- S
1215
+ const o = [];
1216
+ function a(e, i, v) {
1217
+ e.component(t + i) || e.component(
1218
+ t + i,
1219
+ v
1142
1220
  );
1143
1221
  }
1144
- function a(e) {
1145
- l.includes(e) || (l.push(e), t.forEach((d) => {
1146
- const { name: S, alias: h } = d;
1147
- i(e, S, d), h && h.forEach((g) => {
1148
- i(e, g, d);
1222
+ function r(e) {
1223
+ o.includes(e) || (o.push(e), n.forEach((i) => {
1224
+ const { name: v, alias: h } = i;
1225
+ a(e, v, i), h && h.forEach((y) => {
1226
+ a(e, y, i);
1149
1227
  });
1150
1228
  }));
1151
1229
  }
1152
1230
  return {
1153
- version: at,
1154
- componentPrefix: n,
1155
- install: a
1231
+ version: it,
1232
+ componentPrefix: t,
1233
+ install: r
1156
1234
  };
1157
1235
  }
1158
- const ct = {
1159
- install(n) {
1160
- K(n);
1236
+ const pt = {
1237
+ install(t) {
1238
+ Q(t);
1161
1239
  }
1162
1240
  };
1163
1241
  export {
1164
- ot as SzAiChat,
1165
- it as create,
1166
- ct as default
1242
+ nt as SzAiChat,
1243
+ ft as create,
1244
+ st as createRouteLink,
1245
+ pt as default,
1246
+ lt as findRouteTextNodes,
1247
+ at as parseRouteMarkers,
1248
+ dt as routeLinkRender
1167
1249
  };