@szjy/ai-coms 0.1.5 → 0.1.6
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,10 +1,10 @@
|
|
|
1
|
-
import { computed as q, openBlock as P, createElementBlock as L, normalizeStyle as K, createElementVNode as x, normalizeClass as W, getCurrentInstance as re, ref as C, watch as ue, onUnmounted as de, createBlock as J, Transition as oe, withCtx as M, createVNode as
|
|
1
|
+
import { computed as q, openBlock as P, createElementBlock as L, normalizeStyle as K, createElementVNode as x, normalizeClass as W, getCurrentInstance as re, ref as C, watch as ue, onUnmounted as de, createBlock as J, Transition as oe, withCtx as M, createVNode as A, createCommentVNode as B, nextTick as ae, resolveComponent as X, toDisplayString as D, createTextVNode as fe, Fragment as Y, renderList as Z, withKeys as pe, defineComponent as me, withModifiers as he } from "vue";
|
|
2
2
|
const ve = "/images/ai-round.png", ye = "/images/ai-sqrt.png", ge = "/images/bars-loading.svg";
|
|
3
3
|
function se(t) {
|
|
4
4
|
return t.startsWith("http://") || t.startsWith("https://") ? t : `${location.protocol}//${location.host}${t}`;
|
|
5
5
|
}
|
|
6
6
|
async function be(t, n, a, s = "") {
|
|
7
|
-
const r = se(s), e = new URL(`${r}/v1/chat/completions`),
|
|
7
|
+
const r = se(s), e = new URL(`${r}/v1/chat/completions`), l = new Request(e, {
|
|
8
8
|
method: "post",
|
|
9
9
|
headers: {
|
|
10
10
|
"Content-Type": "application/json",
|
|
@@ -28,7 +28,7 @@ async function be(t, n, a, s = "") {
|
|
|
28
28
|
]
|
|
29
29
|
})
|
|
30
30
|
});
|
|
31
|
-
return fetch(
|
|
31
|
+
return fetch(l);
|
|
32
32
|
}
|
|
33
33
|
async function we(t) {
|
|
34
34
|
const n = new URL("http://localhost:11434/api/chat"), a = {};
|
|
@@ -82,7 +82,7 @@ async function xe(t, n) {
|
|
|
82
82
|
});
|
|
83
83
|
return fetch(r);
|
|
84
84
|
}
|
|
85
|
-
async function
|
|
85
|
+
async function Se(t, n) {
|
|
86
86
|
const a = new URL(`${location.origin}/siliconflow/v1/chat/completions`), s = {};
|
|
87
87
|
Object.keys(s).forEach((e) => {
|
|
88
88
|
a.searchParams.append(e, s[e]);
|
|
@@ -107,7 +107,7 @@ async function ke(t, n) {
|
|
|
107
107
|
});
|
|
108
108
|
return fetch(r);
|
|
109
109
|
}
|
|
110
|
-
async function
|
|
110
|
+
async function ke(t, n) {
|
|
111
111
|
const a = new URL(`${location.origin}/moonshot/v1/chat/completions`), s = {};
|
|
112
112
|
Object.keys(s).forEach((e) => {
|
|
113
113
|
a.searchParams.append(e, s[e]);
|
|
@@ -164,9 +164,9 @@ async function _e(t, n) {
|
|
|
164
164
|
return fetch(r);
|
|
165
165
|
}
|
|
166
166
|
async function Ce(t, n, a, s = "") {
|
|
167
|
-
const r = se(s), e = new URL(`${r}/support/${a}/a`),
|
|
168
|
-
Object.keys(
|
|
169
|
-
e.searchParams.append(
|
|
167
|
+
const r = se(s), e = new URL(`${r}/support/${a}/a`), l = {};
|
|
168
|
+
Object.keys(l).forEach((m) => {
|
|
169
|
+
e.searchParams.append(m, l[m]);
|
|
170
170
|
});
|
|
171
171
|
const f = new Request(e, {
|
|
172
172
|
method: "post",
|
|
@@ -180,7 +180,7 @@ async function Ce(t, n, a, s = "") {
|
|
|
180
180
|
});
|
|
181
181
|
return fetch(f);
|
|
182
182
|
}
|
|
183
|
-
const
|
|
183
|
+
const Re = (t) => {
|
|
184
184
|
if (t.startsWith("data:")) {
|
|
185
185
|
const n = t.substring(5).trim();
|
|
186
186
|
if (n === "[DONE]")
|
|
@@ -213,12 +213,12 @@ const Te = (t) => {
|
|
|
213
213
|
{
|
|
214
214
|
label: "SiliconFlow 硅基流动大模型",
|
|
215
215
|
modelName: "siliconflow",
|
|
216
|
-
api:
|
|
216
|
+
api: Se
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
label: "Kimi Moonshot 月之暗面大模型",
|
|
220
220
|
modelName: "moonshot",
|
|
221
|
-
api:
|
|
221
|
+
api: ke
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
label: "通义千问大模型",
|
|
@@ -245,7 +245,7 @@ const Te = (t) => {
|
|
|
245
245
|
};
|
|
246
246
|
},
|
|
247
247
|
spark(t) {
|
|
248
|
-
const n =
|
|
248
|
+
const n = Re(t);
|
|
249
249
|
return n.done ? {
|
|
250
250
|
done: !0
|
|
251
251
|
} : {
|
|
@@ -277,7 +277,7 @@ const Te = (t) => {
|
|
|
277
277
|
return s.slice(0, -1).forEach((r) => {
|
|
278
278
|
r.trim() !== "" && n.enqueue(r);
|
|
279
279
|
}), s[s.length - 1];
|
|
280
|
-
},
|
|
280
|
+
}, Te = (t) => {
|
|
281
281
|
let n = "";
|
|
282
282
|
return new TransformStream({
|
|
283
283
|
transform(a, s) {
|
|
@@ -300,7 +300,7 @@ async function Pe(t, n) {
|
|
|
300
300
|
return a ? new Promise((s) => {
|
|
301
301
|
a(n.text, n.token, n.identifier, n.baseUrl).then((r) => {
|
|
302
302
|
if (r.body) {
|
|
303
|
-
const e = r.body.pipeThrough(new TextDecoderStream()).pipeThrough(
|
|
303
|
+
const e = r.body.pipeThrough(new TextDecoderStream()).pipeThrough(Te(`
|
|
304
304
|
`)).getReader();
|
|
305
305
|
console.log("reader from response:", e), s({
|
|
306
306
|
error: 0,
|
|
@@ -386,7 +386,7 @@ const le = (t, n) => {
|
|
|
386
386
|
};
|
|
387
387
|
return n.color && (e.filter = `drop-shadow(0 0 0 ${n.color})`), e;
|
|
388
388
|
});
|
|
389
|
-
return (e,
|
|
389
|
+
return (e, l) => (P(), L("div", {
|
|
390
390
|
class: "svg-icon-wrapper",
|
|
391
391
|
style: K(s.value)
|
|
392
392
|
}, [
|
|
@@ -423,18 +423,18 @@ const le = (t, n) => {
|
|
|
423
423
|
"updating"
|
|
424
424
|
],
|
|
425
425
|
setup(t, { expose: n, emit: a }) {
|
|
426
|
-
const { appContext: s } = re(), { $message: r } = s.config.globalProperties, e = t,
|
|
427
|
-
let
|
|
428
|
-
const U = q(() => F ? F.render(
|
|
429
|
-
e.reader && e.reader.cancel(), b.value = !0, c.value = !1, d(), _.value = !0,
|
|
426
|
+
const { appContext: s } = re(), { $message: r } = s.config.globalProperties, e = t, l = C(e.displayText || ""), f = C(""), m = C(!0), b = C(!1), _ = C(!!e.displayText), I = a, N = C(null);
|
|
427
|
+
let R = null;
|
|
428
|
+
const U = q(() => F ? F.render(l.value) : l.value), E = () => {
|
|
429
|
+
e.reader && e.reader.cancel(), b.value = !0, c.value = !1, d(), _.value = !0, I("completed", l.value), m.value = !1, R && (cancelAnimationFrame(R), R = null);
|
|
430
430
|
}, z = q(() => `${U.value}`), p = C(!1), u = () => {
|
|
431
431
|
p.value = !0;
|
|
432
432
|
}, d = () => {
|
|
433
433
|
p.value = !1;
|
|
434
|
-
}, c = C(!1),
|
|
434
|
+
}, c = C(!1), i = async () => {
|
|
435
435
|
if (!e.reader) return;
|
|
436
436
|
const g = new TextDecoder("utf-8");
|
|
437
|
-
for (
|
|
437
|
+
for (m.value = !0; !b.value; )
|
|
438
438
|
try {
|
|
439
439
|
if (!e.reader) {
|
|
440
440
|
c.value = !0;
|
|
@@ -449,71 +449,71 @@ const le = (t, n) => {
|
|
|
449
449
|
c.value = !0;
|
|
450
450
|
break;
|
|
451
451
|
}
|
|
452
|
-
const
|
|
453
|
-
if (!
|
|
452
|
+
const k = ee[e.model];
|
|
453
|
+
if (!k)
|
|
454
454
|
break;
|
|
455
|
-
const O =
|
|
455
|
+
const O = k.call(ee, o, g);
|
|
456
456
|
if (O.done) {
|
|
457
457
|
c.value = !0;
|
|
458
458
|
break;
|
|
459
459
|
}
|
|
460
|
-
f.value += O.content,
|
|
460
|
+
f.value += O.content, R === null && S();
|
|
461
461
|
} catch (o) {
|
|
462
|
-
c.value = !0, console.log(3333, o),
|
|
462
|
+
c.value = !0, console.log(3333, o), I("failed", o), E();
|
|
463
463
|
break;
|
|
464
464
|
} finally {
|
|
465
465
|
d();
|
|
466
466
|
}
|
|
467
|
-
},
|
|
467
|
+
}, h = async () => {
|
|
468
468
|
e.scrollToBottomFn && e.scrollToBottomFn();
|
|
469
|
-
},
|
|
469
|
+
}, v = (g = () => {
|
|
470
470
|
}, o = () => {
|
|
471
471
|
}) => {
|
|
472
472
|
if (f.value.length > 0) {
|
|
473
473
|
const y = f.value.substring(0, 10);
|
|
474
|
-
|
|
474
|
+
l.value += y, f.value = f.value.substring(10), g();
|
|
475
475
|
} else
|
|
476
476
|
o();
|
|
477
|
-
},
|
|
478
|
-
if (b.value &&
|
|
479
|
-
cancelAnimationFrame(
|
|
477
|
+
}, S = () => {
|
|
478
|
+
if (b.value && R) {
|
|
479
|
+
cancelAnimationFrame(R), R = null, m.value = !1;
|
|
480
480
|
return;
|
|
481
481
|
}
|
|
482
|
-
c.value ?
|
|
482
|
+
c.value ? v(
|
|
483
483
|
() => {
|
|
484
|
-
|
|
484
|
+
R = requestAnimationFrame(S), I("updating", null);
|
|
485
485
|
},
|
|
486
486
|
() => {
|
|
487
|
-
|
|
487
|
+
I("completed", l.value), m.value = !1, _.value = !0, ae(() => {
|
|
488
488
|
if (c.value = !1, e.messagePostRender && N.value)
|
|
489
489
|
try {
|
|
490
|
-
e.messagePostRender(N.value,
|
|
490
|
+
e.messagePostRender(N.value, l.value);
|
|
491
491
|
} catch (g) {
|
|
492
492
|
console.error("messagePostRender 执行失败:", g);
|
|
493
493
|
}
|
|
494
|
-
}),
|
|
494
|
+
}), R = null;
|
|
495
495
|
}
|
|
496
|
-
) : (
|
|
496
|
+
) : (v(), R = requestAnimationFrame(S)), h();
|
|
497
497
|
};
|
|
498
498
|
ue(
|
|
499
499
|
() => e.reader,
|
|
500
500
|
() => {
|
|
501
|
-
e.reader &&
|
|
501
|
+
e.reader && i();
|
|
502
502
|
},
|
|
503
503
|
{
|
|
504
504
|
immediate: !0,
|
|
505
505
|
deep: !0
|
|
506
506
|
}
|
|
507
507
|
), de(() => {
|
|
508
|
-
|
|
508
|
+
E();
|
|
509
509
|
}), n({
|
|
510
|
-
abortReader:
|
|
510
|
+
abortReader: E,
|
|
511
511
|
initializeStart: u,
|
|
512
512
|
initializeEnd: d
|
|
513
|
-
}), q(() => p.value ? !0 : (!e.reader || !
|
|
513
|
+
}), q(() => p.value ? !0 : (!e.reader || !m || l.value, !1));
|
|
514
514
|
const w = async () => {
|
|
515
515
|
try {
|
|
516
|
-
const g =
|
|
516
|
+
const g = l.value;
|
|
517
517
|
await ze(g), r.success("复制成功");
|
|
518
518
|
} catch (g) {
|
|
519
519
|
console.error("复制失败:", g), r.error("复制失败");
|
|
@@ -538,7 +538,7 @@ const le = (t, n) => {
|
|
|
538
538
|
class: "ai-copy-btn-wrapper",
|
|
539
539
|
onClick: w
|
|
540
540
|
}, [
|
|
541
|
-
|
|
541
|
+
A(V, {
|
|
542
542
|
name: "/images/svg/copy.svg",
|
|
543
543
|
color: "#666666"
|
|
544
544
|
}),
|
|
@@ -549,7 +549,7 @@ const le = (t, n) => {
|
|
|
549
549
|
_: 1
|
|
550
550
|
}));
|
|
551
551
|
}
|
|
552
|
-
},
|
|
552
|
+
}, Ee = { class: "panel-header" }, $e = { class: "header-actions" }, Ae = { class: "header-title" }, Ue = { class: "action-icons" }, qe = { class: "body-content" }, Me = {
|
|
553
553
|
key: 0,
|
|
554
554
|
class: "welcome-content"
|
|
555
555
|
}, Fe = { class: "subtitle" }, Be = { class: "highlight" }, De = { class: "quick-questions" }, Ve = ["onClick"], We = {
|
|
@@ -598,38 +598,38 @@ const le = (t, n) => {
|
|
|
598
598
|
},
|
|
599
599
|
emits: ["update:modelValue", "submit"],
|
|
600
600
|
setup(t, { emit: n }) {
|
|
601
|
-
const { appContext: a } = re(), { $message: s } = a.config.globalProperties, r = t, e = q(() => G.find((o) => o.modelName === r.llmName) ?? G.find((o) => o.modelName === "szjy")),
|
|
601
|
+
const { appContext: a } = re(), { $message: s } = a.config.globalProperties, r = t, e = q(() => G.find((o) => o.modelName === r.llmName) ?? G.find((o) => o.modelName === "szjy")), l = n, f = C(""), m = C(null), b = C(!1), _ = C([]), I = C([
|
|
602
602
|
"什么是AI助理,能做什么?",
|
|
603
603
|
"当前项目的基本情况?",
|
|
604
604
|
"当前项目的进度情况?",
|
|
605
605
|
"当前项目的参建方有哪些?",
|
|
606
606
|
"数智建管平台有哪些功能?能做什么?"
|
|
607
|
-
]), N = C([]),
|
|
607
|
+
]), N = C([]), R = C(!1), U = C(null), E = () => {
|
|
608
608
|
ae(() => {
|
|
609
609
|
if (U.value) {
|
|
610
|
-
const o = U.value, y = o.scrollHeight,
|
|
611
|
-
y -
|
|
610
|
+
const o = U.value, y = o.scrollHeight, k = o.scrollTop, O = o.clientHeight;
|
|
611
|
+
y - k - O < 100 ? o.scrollTop = y : o.scrollTo({
|
|
612
612
|
top: y
|
|
613
613
|
});
|
|
614
614
|
}
|
|
615
615
|
});
|
|
616
616
|
}, z = C(!1), p = q(() => z.value ? "/images/ai-stop.png" : "/images/ai-send.png"), u = (o, y) => {
|
|
617
|
-
console.log("onFailedReader", o, y),
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
617
|
+
console.log("onFailedReader", o, y), R.value = !1;
|
|
618
|
+
const k = w();
|
|
619
|
+
k && k.initializeEnd(), s.error("转换失败,请重试"), z.value = !1, setTimeout(() => {
|
|
620
|
+
m.value && m.value.focus();
|
|
621
621
|
});
|
|
622
622
|
}, d = (o, y) => {
|
|
623
|
-
|
|
624
|
-
|
|
623
|
+
R.value = !1, z.value = !1, E(), y && _.value[o] && (_.value[o].displayText = y), setTimeout(() => {
|
|
624
|
+
m.value && m.value.focus();
|
|
625
625
|
});
|
|
626
626
|
}, c = (o) => {
|
|
627
627
|
z.value = !0;
|
|
628
|
-
},
|
|
629
|
-
z.value = !1,
|
|
630
|
-
},
|
|
631
|
-
|
|
632
|
-
},
|
|
628
|
+
}, i = () => {
|
|
629
|
+
z.value = !1, l("update:modelValue", !1), b.value = !1, _.value = [];
|
|
630
|
+
}, h = C(!1), v = () => {
|
|
631
|
+
h.value = !h.value;
|
|
632
|
+
}, S = (o) => {
|
|
633
633
|
f.value = o, g();
|
|
634
634
|
}, w = () => {
|
|
635
635
|
for (let o = N.value.length - 1; o >= 0; o--)
|
|
@@ -637,67 +637,67 @@ const le = (t, n) => {
|
|
|
637
637
|
return N.value[o];
|
|
638
638
|
return null;
|
|
639
639
|
}, g = async () => {
|
|
640
|
-
if (console.log("stylizingLoading:",
|
|
641
|
-
const
|
|
642
|
-
console.log("lastPreviewer:",
|
|
640
|
+
if (console.log("stylizingLoading:", R.value), R.value) {
|
|
641
|
+
const T = w();
|
|
642
|
+
console.log("lastPreviewer:", T), T && (console.log("abortReader"), T.abortReader());
|
|
643
643
|
return;
|
|
644
644
|
}
|
|
645
645
|
if (!f.value.trim()) {
|
|
646
|
-
console.log("no input, return"),
|
|
646
|
+
console.log("no input, return"), m.value.focus();
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
649
|
_.value.push({
|
|
650
650
|
type: "user",
|
|
651
651
|
content: f.value
|
|
652
|
-
}), z.value = !0, b.value = !0,
|
|
652
|
+
}), z.value = !0, b.value = !0, l("submit", f.value), E();
|
|
653
653
|
const o = f.value;
|
|
654
654
|
f.value = "";
|
|
655
655
|
const y = _.value.length;
|
|
656
|
-
N.value[y] && N.value[y].initializeStart(),
|
|
656
|
+
N.value[y] && N.value[y].initializeStart(), R.value = !0, _.value.push({
|
|
657
657
|
type: "ai"
|
|
658
658
|
});
|
|
659
|
-
const { error:
|
|
659
|
+
const { error: k, reader: O } = await Pe(e.value, {
|
|
660
660
|
text: o,
|
|
661
661
|
token: r.token,
|
|
662
662
|
identifier: r.identifier,
|
|
663
663
|
baseUrl: r.baseUrl
|
|
664
664
|
});
|
|
665
|
-
if (
|
|
666
|
-
console.log(45455,
|
|
665
|
+
if (k) {
|
|
666
|
+
console.log(45455, k), u(y, k);
|
|
667
667
|
return;
|
|
668
668
|
}
|
|
669
669
|
O && (_.value[y].reader = O);
|
|
670
670
|
};
|
|
671
671
|
return (o, y) => {
|
|
672
|
-
const
|
|
672
|
+
const k = X("el-icon"), O = X("el-input");
|
|
673
673
|
return P(), J(oe, { name: "slide" }, {
|
|
674
674
|
default: M(() => [
|
|
675
675
|
t.modelValue ? (P(), L("div", {
|
|
676
676
|
key: 0,
|
|
677
|
-
class: W(["ai-panel", { "drawer-mode":
|
|
677
|
+
class: W(["ai-panel", { "drawer-mode": h.value }])
|
|
678
678
|
}, [
|
|
679
|
-
x("div",
|
|
680
|
-
x("div",
|
|
681
|
-
x("div",
|
|
679
|
+
x("div", Ee, [
|
|
680
|
+
x("div", $e, [
|
|
681
|
+
x("div", Ae, D(t.title), 1),
|
|
682
682
|
x("div", Ue, [
|
|
683
|
-
|
|
683
|
+
A(k, {
|
|
684
684
|
class: "action-icon",
|
|
685
|
-
onClick:
|
|
685
|
+
onClick: v
|
|
686
686
|
}, {
|
|
687
687
|
default: M(() => [
|
|
688
|
-
|
|
688
|
+
A(V, {
|
|
689
689
|
name: "/images/svg/drawer-layout.svg",
|
|
690
690
|
color: "#999999"
|
|
691
691
|
})
|
|
692
692
|
]),
|
|
693
693
|
_: 1
|
|
694
694
|
}),
|
|
695
|
-
|
|
695
|
+
A(k, {
|
|
696
696
|
class: "action-icon",
|
|
697
|
-
onClick:
|
|
697
|
+
onClick: i
|
|
698
698
|
}, {
|
|
699
699
|
default: M(() => [
|
|
700
|
-
|
|
700
|
+
A(V, {
|
|
701
701
|
name: "/images/svg/close.svg",
|
|
702
702
|
color: "#999999"
|
|
703
703
|
})
|
|
@@ -714,24 +714,24 @@ const le = (t, n) => {
|
|
|
714
714
|
ref_key: "messageContainerRef",
|
|
715
715
|
ref: U
|
|
716
716
|
}, [
|
|
717
|
-
(P(!0), L(Y, null, Z(_.value, (
|
|
718
|
-
key:
|
|
719
|
-
class: W(["message-item",
|
|
717
|
+
(P(!0), L(Y, null, Z(_.value, (T, $) => (P(), L("div", {
|
|
718
|
+
key: $,
|
|
719
|
+
class: W(["message-item", T.type === "user" ? "user-message" : "ai-message"])
|
|
720
720
|
}, [
|
|
721
|
-
|
|
721
|
+
T.type === "ai" ? (P(), J(Ie, {
|
|
722
722
|
key: 0,
|
|
723
723
|
ref_for: !0,
|
|
724
|
-
ref: (j) => N.value[
|
|
725
|
-
reader:
|
|
726
|
-
"onUpdate:reader": (j) =>
|
|
724
|
+
ref: (j) => N.value[$] = j,
|
|
725
|
+
reader: T.reader,
|
|
726
|
+
"onUpdate:reader": (j) => T.reader = j,
|
|
727
727
|
model: r.llmName,
|
|
728
|
-
displayText:
|
|
729
|
-
scrollToBottomFn:
|
|
728
|
+
displayText: T.displayText,
|
|
729
|
+
scrollToBottomFn: E,
|
|
730
730
|
messagePostRender: t.messagePostRender,
|
|
731
|
-
onFailed: (j) => u(
|
|
732
|
-
onCompleted: (j) => d(
|
|
731
|
+
onFailed: (j) => u($, j),
|
|
732
|
+
onCompleted: (j) => d($, j),
|
|
733
733
|
onUpdating: () => c()
|
|
734
|
-
}, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (P(), L("div", We, D(
|
|
734
|
+
}, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (P(), L("div", We, D(T.content), 1))
|
|
735
735
|
], 2))), 128))
|
|
736
736
|
], 512)) : (P(), L("div", Me, [
|
|
737
737
|
y[2] || (y[2] = x("div", { class: "title" }, [
|
|
@@ -747,15 +747,15 @@ const le = (t, n) => {
|
|
|
747
747
|
x("span", Be, D(t.title), 1)
|
|
748
748
|
]),
|
|
749
749
|
x("div", De, [
|
|
750
|
-
(P(!0), L(Y, null, Z(
|
|
751
|
-
key:
|
|
750
|
+
(P(!0), L(Y, null, Z(I.value, (T, $) => (P(), L("div", {
|
|
751
|
+
key: $,
|
|
752
752
|
class: "question-item",
|
|
753
|
-
onClick: (j) =>
|
|
753
|
+
onClick: (j) => S(T)
|
|
754
754
|
}, [
|
|
755
|
-
x("span", null, D(
|
|
756
|
-
|
|
755
|
+
x("span", null, D(T), 1),
|
|
756
|
+
A(k, null, {
|
|
757
757
|
default: M(() => [
|
|
758
|
-
|
|
758
|
+
A(V, {
|
|
759
759
|
name: "/images/svg/arrow-right.svg",
|
|
760
760
|
color: "#999999"
|
|
761
761
|
})
|
|
@@ -769,11 +769,11 @@ const le = (t, n) => {
|
|
|
769
769
|
x("div", Je, [
|
|
770
770
|
z.value ? (P(), L("img", He)) : B("", !0),
|
|
771
771
|
x("div", Qe, [
|
|
772
|
-
|
|
772
|
+
A(O, {
|
|
773
773
|
modelValue: f.value,
|
|
774
|
-
"onUpdate:modelValue": y[0] || (y[0] = (
|
|
774
|
+
"onUpdate:modelValue": y[0] || (y[0] = (T) => f.value = T),
|
|
775
775
|
ref_key: "refInputTextString",
|
|
776
|
-
ref:
|
|
776
|
+
ref: m,
|
|
777
777
|
placeholder: "请输入您的问题",
|
|
778
778
|
autofocus: "",
|
|
779
779
|
onKeyup: pe(g, ["enter"])
|
|
@@ -810,47 +810,47 @@ var ie = { exports: {} };
|
|
|
810
810
|
var s = {};
|
|
811
811
|
function r(e) {
|
|
812
812
|
if (s[e]) return s[e].exports;
|
|
813
|
-
var
|
|
814
|
-
return a[e].call(
|
|
813
|
+
var l = s[e] = { i: e, l: !1, exports: {} };
|
|
814
|
+
return a[e].call(l.exports, l, l.exports, r), l.l = !0, l.exports;
|
|
815
815
|
}
|
|
816
|
-
return r.m = a, r.c = s, r.d = function(e,
|
|
817
|
-
r.o(e,
|
|
816
|
+
return r.m = a, r.c = s, r.d = function(e, l, f) {
|
|
817
|
+
r.o(e, l) || Object.defineProperty(e, l, { enumerable: !0, get: f });
|
|
818
818
|
}, r.r = function(e) {
|
|
819
819
|
typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 });
|
|
820
|
-
}, r.t = function(e,
|
|
821
|
-
if (1 &
|
|
820
|
+
}, r.t = function(e, l) {
|
|
821
|
+
if (1 & l && (e = r(e)), 8 & l || 4 & l && typeof e == "object" && e && e.__esModule) return e;
|
|
822
822
|
var f = /* @__PURE__ */ Object.create(null);
|
|
823
|
-
if (r.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: e }), 2 &
|
|
823
|
+
if (r.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: e }), 2 & l && typeof e != "string") for (var m in e) r.d(f, m, (function(b) {
|
|
824
824
|
return e[b];
|
|
825
|
-
}).bind(null,
|
|
825
|
+
}).bind(null, m));
|
|
826
826
|
return f;
|
|
827
827
|
}, r.n = function(e) {
|
|
828
|
-
var
|
|
828
|
+
var l = e && e.__esModule ? function() {
|
|
829
829
|
return e.default;
|
|
830
830
|
} : function() {
|
|
831
831
|
return e;
|
|
832
832
|
};
|
|
833
|
-
return r.d(
|
|
834
|
-
}, r.o = function(e,
|
|
835
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
833
|
+
return r.d(l, "a", l), l;
|
|
834
|
+
}, r.o = function(e, l) {
|
|
835
|
+
return Object.prototype.hasOwnProperty.call(e, l);
|
|
836
836
|
}, r.p = "", r(r.s = 0);
|
|
837
837
|
}([function(a, s, r) {
|
|
838
838
|
function e(p, u, d, c) {
|
|
839
839
|
d.push(p), c.push([].concat(u[p] || []));
|
|
840
840
|
}
|
|
841
|
-
function
|
|
841
|
+
function l(p, u) {
|
|
842
842
|
if (!p) throw new Error("[getMaxDepsChain] dep 参数不能为空");
|
|
843
|
-
var d = [], c = [],
|
|
844
|
-
for (e(p, u, c,
|
|
845
|
-
var
|
|
846
|
-
if (
|
|
847
|
-
var
|
|
848
|
-
if (
|
|
849
|
-
e(
|
|
843
|
+
var d = [], c = [], i = [];
|
|
844
|
+
for (e(p, u, c, i); c.length; ) {
|
|
845
|
+
var h = i.pop();
|
|
846
|
+
if (h && h.length) {
|
|
847
|
+
var v = h.shift();
|
|
848
|
+
if (i.push(h), ~c.indexOf(v)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + v + ", mainStack: " + c);
|
|
849
|
+
e(v, u, c, i);
|
|
850
850
|
} else d.push([].concat(c)), c.pop();
|
|
851
851
|
}
|
|
852
|
-
return d.reduce(function(
|
|
853
|
-
return w.length >
|
|
852
|
+
return d.reduce(function(S, w) {
|
|
853
|
+
return w.length > S.length ? w : S;
|
|
854
854
|
}, []);
|
|
855
855
|
}
|
|
856
856
|
function f(p) {
|
|
@@ -861,154 +861,154 @@ var ie = { exports: {} };
|
|
|
861
861
|
});
|
|
862
862
|
var d = [];
|
|
863
863
|
return p.forEach(function(c) {
|
|
864
|
-
var
|
|
865
|
-
c.priority =
|
|
864
|
+
var i = l(c.name, u).length - 1;
|
|
865
|
+
c.priority = i, d[i] = (d[i] || []).concat(c);
|
|
866
866
|
}), d;
|
|
867
867
|
}
|
|
868
868
|
r.r(s), r.d(s, "loadScript", function() {
|
|
869
869
|
return N;
|
|
870
870
|
}), r.d(s, "loadScripts", function() {
|
|
871
|
-
return
|
|
871
|
+
return R;
|
|
872
872
|
}), r.d(s, "dynamicLoadScripts", function() {
|
|
873
873
|
return U;
|
|
874
874
|
}), r.d(s, "createScriptsLoadIterator", function() {
|
|
875
|
-
return
|
|
875
|
+
return E;
|
|
876
876
|
}), r.d(s, "loadScriptsQueue", function() {
|
|
877
877
|
return z;
|
|
878
878
|
}), r.d(s, "getMaxDepsChain", function() {
|
|
879
|
-
return
|
|
879
|
+
return l;
|
|
880
880
|
}), r.d(s, "depsParser", function() {
|
|
881
881
|
return f;
|
|
882
882
|
});
|
|
883
|
-
var
|
|
884
|
-
return (
|
|
885
|
-
for (var u, d = 1, c = arguments.length; d < c; d++) for (var
|
|
883
|
+
var m = function() {
|
|
884
|
+
return (m = Object.assign || function(p) {
|
|
885
|
+
for (var u, d = 1, c = arguments.length; d < c; d++) for (var i in u = arguments[d]) Object.prototype.hasOwnProperty.call(u, i) && (p[i] = u[i]);
|
|
886
886
|
return p;
|
|
887
887
|
}).apply(this, arguments);
|
|
888
888
|
}, b = function(p, u, d, c) {
|
|
889
|
-
return new (d || (d = Promise))(function(
|
|
890
|
-
function
|
|
889
|
+
return new (d || (d = Promise))(function(i, h) {
|
|
890
|
+
function v(g) {
|
|
891
891
|
try {
|
|
892
892
|
w(c.next(g));
|
|
893
893
|
} catch (o) {
|
|
894
|
-
|
|
894
|
+
h(o);
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
|
-
function
|
|
897
|
+
function S(g) {
|
|
898
898
|
try {
|
|
899
899
|
w(c.throw(g));
|
|
900
900
|
} catch (o) {
|
|
901
|
-
|
|
901
|
+
h(o);
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
function w(g) {
|
|
905
905
|
var o;
|
|
906
|
-
g.done ?
|
|
906
|
+
g.done ? i(g.value) : (o = g.value, o instanceof d ? o : new d(function(y) {
|
|
907
907
|
y(o);
|
|
908
|
-
})).then(
|
|
908
|
+
})).then(v, S);
|
|
909
909
|
}
|
|
910
910
|
w((c = c.apply(p, [])).next());
|
|
911
911
|
});
|
|
912
912
|
}, _ = function(p, u) {
|
|
913
|
-
var d, c,
|
|
914
|
-
if (1 &
|
|
915
|
-
return
|
|
913
|
+
var d, c, i, h, v = { label: 0, sent: function() {
|
|
914
|
+
if (1 & i[0]) throw i[1];
|
|
915
|
+
return i[1];
|
|
916
916
|
}, trys: [], ops: [] };
|
|
917
|
-
return
|
|
917
|
+
return h = { next: S(0), throw: S(1), return: S(2) }, typeof Symbol == "function" && (h[Symbol.iterator] = function() {
|
|
918
918
|
return this;
|
|
919
|
-
}),
|
|
920
|
-
function
|
|
919
|
+
}), h;
|
|
920
|
+
function S(w) {
|
|
921
921
|
return function(g) {
|
|
922
922
|
return function(o) {
|
|
923
923
|
if (d) throw new TypeError("Generator is already executing.");
|
|
924
|
-
for (;
|
|
925
|
-
if (d = 1, c && (
|
|
926
|
-
switch (c = 0,
|
|
924
|
+
for (; v; ) try {
|
|
925
|
+
if (d = 1, c && (i = 2 & o[0] ? c.return : o[0] ? c.throw || ((i = c.return) && i.call(c), 0) : c.next) && !(i = i.call(c, o[1])).done) return i;
|
|
926
|
+
switch (c = 0, i && (o = [2 & o[0], i.value]), o[0]) {
|
|
927
927
|
case 0:
|
|
928
928
|
case 1:
|
|
929
|
-
|
|
929
|
+
i = o;
|
|
930
930
|
break;
|
|
931
931
|
case 4:
|
|
932
|
-
return
|
|
932
|
+
return v.label++, { value: o[1], done: !1 };
|
|
933
933
|
case 5:
|
|
934
|
-
|
|
934
|
+
v.label++, c = o[1], o = [0];
|
|
935
935
|
continue;
|
|
936
936
|
case 7:
|
|
937
|
-
o =
|
|
937
|
+
o = v.ops.pop(), v.trys.pop();
|
|
938
938
|
continue;
|
|
939
939
|
default:
|
|
940
|
-
if (
|
|
941
|
-
|
|
940
|
+
if (i = v.trys, !((i = i.length > 0 && i[i.length - 1]) || o[0] !== 6 && o[0] !== 2)) {
|
|
941
|
+
v = 0;
|
|
942
942
|
continue;
|
|
943
943
|
}
|
|
944
|
-
if (o[0] === 3 && (!
|
|
945
|
-
|
|
944
|
+
if (o[0] === 3 && (!i || o[1] > i[0] && o[1] < i[3])) {
|
|
945
|
+
v.label = o[1];
|
|
946
946
|
break;
|
|
947
947
|
}
|
|
948
|
-
if (o[0] === 6 &&
|
|
949
|
-
|
|
948
|
+
if (o[0] === 6 && v.label < i[1]) {
|
|
949
|
+
v.label = i[1], i = o;
|
|
950
950
|
break;
|
|
951
951
|
}
|
|
952
|
-
if (
|
|
953
|
-
|
|
952
|
+
if (i && v.label < i[2]) {
|
|
953
|
+
v.label = i[2], v.ops.push(o);
|
|
954
954
|
break;
|
|
955
955
|
}
|
|
956
|
-
|
|
956
|
+
i[2] && v.ops.pop(), v.trys.pop();
|
|
957
957
|
continue;
|
|
958
958
|
}
|
|
959
|
-
o = u.call(p,
|
|
959
|
+
o = u.call(p, v);
|
|
960
960
|
} catch (y) {
|
|
961
961
|
o = [6, y], c = 0;
|
|
962
962
|
} finally {
|
|
963
|
-
d =
|
|
963
|
+
d = i = 0;
|
|
964
964
|
}
|
|
965
965
|
if (5 & o[0]) throw o[1];
|
|
966
966
|
return { value: o[0] ? o[1] : void 0, done: !0 };
|
|
967
967
|
}([w, g]);
|
|
968
968
|
};
|
|
969
969
|
}
|
|
970
|
-
},
|
|
970
|
+
}, I = function(p) {
|
|
971
971
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
972
972
|
var u, d = p[Symbol.asyncIterator];
|
|
973
973
|
return d ? d.call(p) : (p = typeof __values == "function" ? __values(p) : p[Symbol.iterator](), u = {}, c("next"), c("throw"), c("return"), u[Symbol.asyncIterator] = function() {
|
|
974
974
|
return this;
|
|
975
975
|
}, u);
|
|
976
|
-
function c(
|
|
977
|
-
u[
|
|
978
|
-
return new Promise(function(
|
|
976
|
+
function c(i) {
|
|
977
|
+
u[i] = p[i] && function(h) {
|
|
978
|
+
return new Promise(function(v, S) {
|
|
979
979
|
(function(w, g, o, y) {
|
|
980
|
-
Promise.resolve(y).then(function(
|
|
981
|
-
w({ value:
|
|
980
|
+
Promise.resolve(y).then(function(k) {
|
|
981
|
+
w({ value: k, done: o });
|
|
982
982
|
}, g);
|
|
983
|
-
})(
|
|
983
|
+
})(v, S, (h = p[i](h)).done, h.value);
|
|
984
984
|
});
|
|
985
985
|
};
|
|
986
986
|
}
|
|
987
987
|
};
|
|
988
988
|
function N(p, u) {
|
|
989
989
|
return u === void 0 && (u = !1), new Promise(function(d, c) {
|
|
990
|
-
var
|
|
991
|
-
|
|
990
|
+
var i = u ? document.head : document.body, h = document.createElement("script");
|
|
991
|
+
h.type = "text/javascript", h.src = p, h.crossOrigin = "anonymous", h.onreadystatechange = d, h.onload = d, h.onerror = c, i.appendChild(h);
|
|
992
992
|
});
|
|
993
993
|
}
|
|
994
|
-
var
|
|
994
|
+
var R = function(p, u) {
|
|
995
995
|
return u === void 0 && (u = {}), b(void 0, void 0, void 0, function() {
|
|
996
|
-
var d, c,
|
|
997
|
-
return _(this, function(
|
|
998
|
-
switch (
|
|
996
|
+
var d, c, i, h, v;
|
|
997
|
+
return _(this, function(S) {
|
|
998
|
+
switch (S.label) {
|
|
999
999
|
case 0:
|
|
1000
|
-
return d = u.baseUrl, c = d === void 0 ? "" : d,
|
|
1000
|
+
return d = u.baseUrl, c = d === void 0 ? "" : d, i = u.lastLoadResult, h = u.inHead, v = h !== void 0 && h, [4, Promise.all(p.map(function(w) {
|
|
1001
1001
|
return b(void 0, void 0, void 0, function() {
|
|
1002
|
-
var g, o, y,
|
|
1002
|
+
var g, o, y, k, O, T, $, j;
|
|
1003
1003
|
return _(this, function(Q) {
|
|
1004
1004
|
switch (Q.label) {
|
|
1005
1005
|
case 0:
|
|
1006
|
-
return g = w.name, o = w.path, y = w.deps, (
|
|
1006
|
+
return g = w.name, o = w.path, y = w.deps, ($ = {})[g] = !0, k = $, (j = {})[g] = !1, O = j, window[g] ? [2, k] : [3, 1];
|
|
1007
1007
|
case 1:
|
|
1008
|
-
return
|
|
1009
|
-
|
|
1010
|
-
}),
|
|
1011
|
-
return
|
|
1008
|
+
return T = !0, y && i && [].concat(y).forEach(function(ce) {
|
|
1009
|
+
i[ce] !== !1 && (T = !0);
|
|
1010
|
+
}), T ? [4, N(o.indexOf("http") === 0 || o.indexOf("//:") === 0 ? o : c + o, v).then(function() {
|
|
1011
|
+
return k;
|
|
1012
1012
|
}).catch(function() {
|
|
1013
1013
|
return O;
|
|
1014
1014
|
})] : [3, 3];
|
|
@@ -1021,7 +1021,7 @@ var ie = { exports: {} };
|
|
|
1021
1021
|
});
|
|
1022
1022
|
}))];
|
|
1023
1023
|
case 1:
|
|
1024
|
-
return [2,
|
|
1024
|
+
return [2, S.sent()];
|
|
1025
1025
|
}
|
|
1026
1026
|
});
|
|
1027
1027
|
});
|
|
@@ -1031,44 +1031,44 @@ var ie = { exports: {} };
|
|
|
1031
1031
|
return { next: function() {
|
|
1032
1032
|
if (d.length) {
|
|
1033
1033
|
var c = d.shift();
|
|
1034
|
-
return
|
|
1035
|
-
return { value:
|
|
1034
|
+
return R(c, u).then(function(i) {
|
|
1035
|
+
return { value: i, done: !1 };
|
|
1036
1036
|
});
|
|
1037
1037
|
}
|
|
1038
1038
|
return Promise.resolve({ done: !0 });
|
|
1039
1039
|
} };
|
|
1040
1040
|
};
|
|
1041
|
-
},
|
|
1041
|
+
}, E = function(p, u) {
|
|
1042
1042
|
var d;
|
|
1043
1043
|
return u === void 0 && (u = {}), (d = {})[Symbol.asyncIterator] = U(p, u), d;
|
|
1044
1044
|
}, z = function(p, u) {
|
|
1045
1045
|
return u === void 0 && (u = {}), b(void 0, void 0, void 0, function() {
|
|
1046
|
-
var d, c,
|
|
1046
|
+
var d, c, i, h, v, S;
|
|
1047
1047
|
return _(this, function(w) {
|
|
1048
1048
|
switch (w.label) {
|
|
1049
1049
|
case 0:
|
|
1050
|
-
w.trys.push([0, 5, 6, 11]), d =
|
|
1050
|
+
w.trys.push([0, 5, 6, 11]), d = I(E(p, u)), w.label = 1;
|
|
1051
1051
|
case 1:
|
|
1052
1052
|
return [4, d.next()];
|
|
1053
1053
|
case 2:
|
|
1054
1054
|
if ((c = w.sent()).done) return [3, 4];
|
|
1055
|
-
|
|
1056
|
-
u.lastLoadResult =
|
|
1055
|
+
i = c.value, u.lastLoadResult = u.lastLoadResult || {}, console.log("current load: ", i), i.forEach(function(g) {
|
|
1056
|
+
u.lastLoadResult = m(m({}, u.lastLoadResult), g);
|
|
1057
1057
|
}), w.label = 3;
|
|
1058
1058
|
case 3:
|
|
1059
1059
|
return [3, 1];
|
|
1060
1060
|
case 4:
|
|
1061
1061
|
return [3, 11];
|
|
1062
1062
|
case 5:
|
|
1063
|
-
return
|
|
1063
|
+
return h = w.sent(), v = { error: h }, [3, 11];
|
|
1064
1064
|
case 6:
|
|
1065
|
-
return w.trys.push([6, , 9, 10]), c && !c.done && (
|
|
1065
|
+
return w.trys.push([6, , 9, 10]), c && !c.done && (S = d.return) ? [4, S.call(d)] : [3, 8];
|
|
1066
1066
|
case 7:
|
|
1067
1067
|
w.sent(), w.label = 8;
|
|
1068
1068
|
case 8:
|
|
1069
1069
|
return [3, 10];
|
|
1070
1070
|
case 9:
|
|
1071
|
-
if (
|
|
1071
|
+
if (v) throw v.error;
|
|
1072
1072
|
return [7];
|
|
1073
1073
|
case 10:
|
|
1074
1074
|
return [7];
|
|
@@ -1132,9 +1132,9 @@ const Ze = {
|
|
|
1132
1132
|
n.value = !n.value;
|
|
1133
1133
|
}, r = () => {
|
|
1134
1134
|
a.value = !0, n.value = !1;
|
|
1135
|
-
}, e = (
|
|
1136
|
-
console.log("用户输入:",
|
|
1137
|
-
},
|
|
1135
|
+
}, e = (m) => {
|
|
1136
|
+
console.log("用户输入:", m);
|
|
1137
|
+
}, l = [
|
|
1138
1138
|
{
|
|
1139
1139
|
name: "markdownit",
|
|
1140
1140
|
path: "markdown-it.min.js"
|
|
@@ -1145,17 +1145,17 @@ const Ze = {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
];
|
|
1147
1147
|
let f = {};
|
|
1148
|
-
return Ye.loadScriptsQueue(
|
|
1148
|
+
return Ye.loadScriptsQueue(l, {
|
|
1149
1149
|
baseUrl: "/scripts/ai/",
|
|
1150
1150
|
lastLoadResult: f,
|
|
1151
1151
|
inHead: !1
|
|
1152
|
-
}).then((
|
|
1153
|
-
if (console.log("load ai deps: ",
|
|
1152
|
+
}).then((m) => {
|
|
1153
|
+
if (console.log("load ai deps: ", m), window.markdownit) {
|
|
1154
1154
|
const b = window.markdownit();
|
|
1155
1155
|
console.log("markdownit: ", b), Ne();
|
|
1156
1156
|
}
|
|
1157
|
-
}), (
|
|
1158
|
-
|
|
1157
|
+
}), (m, b) => a.value ? B("", !0) : (P(), L("div", Ze, [
|
|
1158
|
+
A(Xe, {
|
|
1159
1159
|
modelValue: n.value,
|
|
1160
1160
|
"onUpdate:modelValue": b[0] || (b[0] = (_) => n.value = _),
|
|
1161
1161
|
onSubmit: e,
|
|
@@ -1204,31 +1204,40 @@ const Ze = {
|
|
|
1204
1204
|
t.component(a.name, a);
|
|
1205
1205
|
}
|
|
1206
1206
|
}
|
|
1207
|
-
}, nt = (t) => {
|
|
1208
|
-
|
|
1209
|
-
|
|
1207
|
+
}, nt = (t, n) => {
|
|
1208
|
+
const a = n ? `?${new URLSearchParams(n).toString()}` : "";
|
|
1209
|
+
console.log(`点击了路由链接: ${t}${a}`);
|
|
1210
|
+
}, rt = (t) => {
|
|
1211
|
+
const n = t.indexOf("?");
|
|
1212
|
+
if (n === -1)
|
|
1213
|
+
return { routeName: t };
|
|
1214
|
+
const a = t.substring(0, n), s = t.substring(n + 1), r = {};
|
|
1215
|
+
return new URLSearchParams(s).forEach((l, f) => {
|
|
1216
|
+
r[f] = l;
|
|
1217
|
+
}), { routeName: a, queryParams: Object.keys(r).length > 0 ? r : void 0 };
|
|
1218
|
+
}, ot = {
|
|
1210
1219
|
color: "#536fec",
|
|
1211
1220
|
fontWeight: "bold",
|
|
1212
1221
|
textDecoration: "underline",
|
|
1213
1222
|
cursor: "pointer",
|
|
1214
1223
|
padding: "0 3px"
|
|
1215
|
-
},
|
|
1224
|
+
}, at = (t) => {
|
|
1216
1225
|
const n = /#router:([^#]+)#/g, a = [];
|
|
1217
1226
|
let s = 0, r;
|
|
1218
1227
|
for (; (r = n.exec(t)) !== null; ) {
|
|
1219
1228
|
r.index > s && a.push({ text: t.substring(s, r.index) });
|
|
1220
|
-
const e = r[1];
|
|
1221
|
-
a.push({ text:
|
|
1229
|
+
const e = r[1], { routeName: l, queryParams: f } = rt(e);
|
|
1230
|
+
a.push({ text: l, routeName: l, queryParams: f }), s = n.lastIndex;
|
|
1222
1231
|
}
|
|
1223
1232
|
return s < t.length && a.push({ text: t.substring(s) }), a;
|
|
1224
|
-
},
|
|
1225
|
-
const { onRouteClick:
|
|
1226
|
-
|
|
1227
|
-
const
|
|
1228
|
-
return Object.assign(
|
|
1229
|
-
|
|
1230
|
-
}),
|
|
1231
|
-
},
|
|
1233
|
+
}, st = (t, n, a = {}, s) => {
|
|
1234
|
+
const { onRouteClick: r = nt, linkStyle: e = {} } = a, l = document.createElement("a");
|
|
1235
|
+
l.href = "#", l.textContent = t;
|
|
1236
|
+
const f = { ...ot, ...e };
|
|
1237
|
+
return Object.assign(l.style, f), l.addEventListener("click", (m) => {
|
|
1238
|
+
m.preventDefault(), r(n, s);
|
|
1239
|
+
}), l;
|
|
1240
|
+
}, lt = (t) => {
|
|
1232
1241
|
const n = /#router:([^#]+)#/g, a = [], s = document.createTreeWalker(
|
|
1233
1242
|
t,
|
|
1234
1243
|
NodeFilter.SHOW_TEXT,
|
|
@@ -1236,68 +1245,69 @@ const Ze = {
|
|
|
1236
1245
|
);
|
|
1237
1246
|
let r = s.nextNode();
|
|
1238
1247
|
for (; r; ) {
|
|
1239
|
-
const e = r,
|
|
1240
|
-
if (n.test(
|
|
1248
|
+
const e = r, l = e.textContent || "";
|
|
1249
|
+
if (n.test(l)) {
|
|
1241
1250
|
n.lastIndex = 0;
|
|
1242
|
-
const f =
|
|
1251
|
+
const f = at(l);
|
|
1243
1252
|
f.length > 0 && a.push({ node: e, replacements: f });
|
|
1244
1253
|
}
|
|
1245
1254
|
r = s.nextNode();
|
|
1246
1255
|
}
|
|
1247
1256
|
return a;
|
|
1248
|
-
},
|
|
1249
|
-
const s =
|
|
1257
|
+
}, dt = (t, n, a = {}) => {
|
|
1258
|
+
const s = lt(t);
|
|
1250
1259
|
s.forEach(({ node: r, replacements: e }) => {
|
|
1251
1260
|
var f;
|
|
1252
|
-
const
|
|
1253
|
-
e.forEach(({ text:
|
|
1261
|
+
const l = document.createDocumentFragment();
|
|
1262
|
+
e.forEach(({ text: m, routeName: b, queryParams: _ }) => {
|
|
1254
1263
|
if (b) {
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1264
|
+
const I = st(m, b, a, _);
|
|
1265
|
+
l.appendChild(I);
|
|
1257
1266
|
} else
|
|
1258
|
-
|
|
1259
|
-
}), (f = r.parentNode) == null || f.replaceChild(
|
|
1267
|
+
l.appendChild(document.createTextNode(m));
|
|
1268
|
+
}), (f = r.parentNode) == null || f.replaceChild(l, r);
|
|
1260
1269
|
}), a != null && a.nodeCallback && s.forEach(({ node: r, replacements: e }) => {
|
|
1261
|
-
var
|
|
1262
|
-
(
|
|
1270
|
+
var l;
|
|
1271
|
+
(l = a.nodeCallback) == null || l.call(a, r, e);
|
|
1263
1272
|
});
|
|
1264
|
-
},
|
|
1265
|
-
function
|
|
1266
|
-
componentPrefix: t =
|
|
1273
|
+
}, it = "0.1.6", ct = "Sz";
|
|
1274
|
+
function ft({
|
|
1275
|
+
componentPrefix: t = ct,
|
|
1267
1276
|
components: n = []
|
|
1268
1277
|
} = {}) {
|
|
1269
1278
|
const a = [];
|
|
1270
|
-
function s(e,
|
|
1271
|
-
e.component(t +
|
|
1272
|
-
t +
|
|
1279
|
+
function s(e, l, f) {
|
|
1280
|
+
e.component(t + l) || e.component(
|
|
1281
|
+
t + l,
|
|
1273
1282
|
f
|
|
1274
1283
|
);
|
|
1275
1284
|
}
|
|
1276
1285
|
function r(e) {
|
|
1277
|
-
a.includes(e) || (a.push(e), n.forEach((
|
|
1278
|
-
const { name: f, alias:
|
|
1279
|
-
s(e, f,
|
|
1280
|
-
s(e, b,
|
|
1286
|
+
a.includes(e) || (a.push(e), n.forEach((l) => {
|
|
1287
|
+
const { name: f, alias: m } = l;
|
|
1288
|
+
s(e, f, l), m && m.forEach((b) => {
|
|
1289
|
+
s(e, b, l);
|
|
1281
1290
|
});
|
|
1282
1291
|
}));
|
|
1283
1292
|
}
|
|
1284
1293
|
return {
|
|
1285
|
-
version:
|
|
1294
|
+
version: it,
|
|
1286
1295
|
componentPrefix: t,
|
|
1287
1296
|
install: r
|
|
1288
1297
|
};
|
|
1289
1298
|
}
|
|
1290
|
-
const
|
|
1299
|
+
const pt = {
|
|
1291
1300
|
install(t) {
|
|
1292
1301
|
H(t);
|
|
1293
1302
|
}
|
|
1294
1303
|
};
|
|
1295
1304
|
export {
|
|
1296
1305
|
tt as SzAiChat,
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1306
|
+
ft as create,
|
|
1307
|
+
st as createRouteLink,
|
|
1308
|
+
pt as default,
|
|
1309
|
+
lt as findRouteTextNodes,
|
|
1310
|
+
rt as parseRouteMarkerContent,
|
|
1311
|
+
at as parseRouteMarkers,
|
|
1312
|
+
dt as routeLinkRender
|
|
1303
1313
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E["szjy-ai-coms"]={},E.Vue))})(this,function(E,e){"use strict";const
|
|
2
|
-
`)).getReader();console.log("reader from response:",t),l({error:0,reader:t})}else l({error:1,reader:null})}).catch(o=>{l({error:1,reader:null})})}):{error:1,reader:null}}let j=null;function de(){return j||(window.markdownit?j=new window.markdownit({html:!0,linkify:!0,typographer:!0}):console.log("markdownit is not loaded"),j)}const F=(n,r)=>{const s=n.__vccOpts||n;for(const[l,o]of r)s[l]=o;return s},ue=["src","alt"],I=F({__name:"SvgIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""},className:{type:String,default:""},basePath:{type:String,default:"/icons/"}},setup(n){const r=n,s=e.computed(()=>{if(r.name.startsWith("http://")||r.name.startsWith("https://")||r.name.startsWith("/"))return r.name;const t=r.name.endsWith(".svg")?r.name:`${r.name}.svg`;return`${r.basePath}${t}`}),l=e.computed(()=>{const t=typeof r.size=="number"?`${r.size}px`:r.size;return{width:t,height:t,display:"inline-flex",justifyContent:"center",alignItems:"center"}}),o=e.computed(()=>{const t={width:"100%",height:"100%"};return r.color&&(t.filter=`drop-shadow(0 0 0 ${r.color})`),t});return(t,c)=>(e.openBlock(),e.createElementBlock("div",{class:"svg-icon-wrapper",style:e.normalizeStyle(l.value)},[e.createElementVNode("img",{src:s.value,alt:n.name,class:e.normalizeClass(["svg-icon",n.className]),style:e.normalizeStyle(o.value)},null,14,ue)],4))}},[["__scopeId","data-v-490b11c1"]]),fe=async n=>{if(navigator.clipboard&&navigator.permissions)await navigator.clipboard.writeText(n);else{const r=document.createElement("textArea");r.value=n,r.style.width=0,r.style.position="fixed",r.style.left="-999px",r.style.top="10px",r.setAttribute("readonly","readonly"),document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}},me=["innerHTML"],pe={__name:"Previewer",props:{reader:null,model:"szjy",scrollToBottomFn:null,displayText:"",messagePostRender:{type:Function,default:null}},emits:["failed","completed","updating"],setup(n,{expose:r,emit:s}){const{appContext:l}=e.getCurrentInstance(),{$message:o}=l.config.globalProperties,t=n,c=e.ref(t.displayText||""),m=e.ref(""),g=e.ref(!0),w=e.ref(!1),N=e.ref(!!t.displayText),z=s,T=e.ref(null);let C=null;const L=e.computed(()=>j?j.render(c.value):c.value),P=()=>{t.reader&&t.reader.cancel(),w.value=!0,d.value=!1,f(),N.value=!0,z("completed",c.value),g.value=!1,C&&(cancelAnimationFrame(C),C=null)},V=e.computed(()=>`${L.value}`),p=e.ref(!1),u=()=>{p.value=!0},f=()=>{p.value=!1},d=e.ref(!1),i=async()=>{if(!t.reader)return;const k=new TextDecoder("utf-8");for(g.value=!0;!w.value;)try{if(!t.reader){d.value=!0;break}const{value:a,done:b}=await t.reader.read();if(!t.reader){d.value=!0;break}if(b){d.value=!0;break}const x=M[t.model];if(!x)break;const R=x.call(M,a,k);if(R.done){d.value=!0;break}m.value+=R.content,C===null&&S()}catch(a){d.value=!0,console.log(3333,a),z("failed",a),P();break}finally{f()}},h=async()=>{t.scrollToBottomFn&&t.scrollToBottomFn()},y=(k=()=>{},a=()=>{})=>{if(m.value.length>0){const b=m.value.substring(0,10);c.value+=b,m.value=m.value.substring(10),k()}else a()},S=()=>{if(w.value&&C){cancelAnimationFrame(C),C=null,g.value=!1;return}d.value?y(()=>{C=requestAnimationFrame(S),z("updating",null)},()=>{z("completed",c.value),g.value=!1,N.value=!0,e.nextTick(()=>{if(d.value=!1,t.messagePostRender&&T.value)try{t.messagePostRender(T.value,c.value)}catch(k){console.error("messagePostRender 执行失败:",k)}}),C=null}):(y(),C=requestAnimationFrame(S)),h()};e.watch(()=>t.reader,()=>{t.reader&&i()},{immediate:!0,deep:!0}),e.onUnmounted(()=>{P()}),r({abortReader:P,initializeStart:u,initializeEnd:f}),e.computed(()=>p.value?!0:(!t.reader||!g||c.value,!1));const v=async()=>{try{const k=c.value;await fe(k),o.success("复制成功")}catch(k){console.error("复制失败:",k),o.error("复制失败")}};return(k,a)=>(e.openBlock(),e.createBlock(e.Transition,{name:"fade"},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"refWrapperContent",ref:T,"text-16":"",class:"w-full h-full overflow-y-auto relative","p-24px":""},[e.createElementVNode("div",{class:"markdown-wrapper",innerHTML:V.value},null,8,me),N.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ai-copy-btn-wrapper",onClick:v},[e.createVNode(I,{name:"/images/svg/copy.svg",color:"#666666"}),a[0]||(a[0]=e.createElementVNode("span",{class:"copy-text"},"复制",-1))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)]),_:1}))}},he={class:"panel-header"},ye={class:"header-actions"},ge={class:"header-title"},be={class:"action-icons"},ke={class:"body-content"},we={key:0,class:"welcome-content"},ve={class:"subtitle"},Se={class:"highlight"},xe={class:"quick-questions"},Ne=["onClick"],Ce={key:1,class:"message-content user-content"},_e={class:"panel-footer"},Ee={key:0,src:G,alt:"加载中",class:"loading-icon"},Te={class:"input-box"},Re=["src"],Ve={__name:"ChatPanel",props:{modelValue:{type:Boolean,default:!1},token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null}},emits:["update:modelValue","submit"],setup(n,{emit:r}){const{appContext:s}=e.getCurrentInstance(),{$message:l}=s.config.globalProperties,o=n,t=e.computed(()=>U.find(a=>a.modelName===o.llmName)??U.find(a=>a.modelName==="szjy")),c=r,m=e.ref(""),g=e.ref(null),w=e.ref(!1),N=e.ref([]),z=e.ref(["什么是AI助理,能做什么?","当前项目的基本情况?","当前项目的进度情况?","当前项目的参建方有哪些?","数智建管平台有哪些功能?能做什么?"]),T=e.ref([]),C=e.ref(!1),L=e.ref(null),P=()=>{e.nextTick(()=>{if(L.value){const a=L.value,b=a.scrollHeight,x=a.scrollTop,R=a.clientHeight;b-x-R<100?a.scrollTop=b:a.scrollTo({top:b})}})},V=e.ref(!1),p=e.computed(()=>V.value?"/images/ai-stop.png":"/images/ai-send.png"),u=(a,b)=>{console.log("onFailedReader",a,b),C.value=!1;const x=v();x&&x.initializeEnd(),l.error("转换失败,请重试"),V.value=!1,setTimeout(()=>{g.value&&g.value.focus()})},f=(a,b)=>{C.value=!1,V.value=!1,P(),b&&N.value[a]&&(N.value[a].displayText=b),setTimeout(()=>{g.value&&g.value.focus()})},d=a=>{V.value=!0},i=()=>{V.value=!1,c("update:modelValue",!1),w.value=!1,N.value=[]},h=e.ref(!1),y=()=>{h.value=!h.value},S=a=>{m.value=a,k()},v=()=>{for(let a=T.value.length-1;a>=0;a--)if(T.value[a])return T.value[a];return null},k=async()=>{if(console.log("stylizingLoading:",C.value),C.value){const _=v();console.log("lastPreviewer:",_),_&&(console.log("abortReader"),_.abortReader());return}if(!m.value.trim()){console.log("no input, return"),g.value.focus();return}N.value.push({type:"user",content:m.value}),V.value=!0,w.value=!0,c("submit",m.value),P();const a=m.value;m.value="";const b=N.value.length;T.value[b]&&T.value[b].initializeStart(),C.value=!0,N.value.push({type:"ai"});const{error:x,reader:R}=await ce(t.value,{text:a,token:o.token,identifier:o.identifier,baseUrl:o.baseUrl});if(x){console.log(45455,x),u(b,x);return}R&&(N.value[b].reader=R)};return(a,b)=>{const x=e.resolveComponent("el-icon"),R=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(e.Transition,{name:"slide"},{default:e.withCtx(()=>[n.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ai-panel",{"drawer-mode":h.value}])},[e.createElementVNode("div",he,[e.createElementVNode("div",ye,[e.createElementVNode("div",ge,e.toDisplayString(n.title),1),e.createElementVNode("div",be,[e.createVNode(x,{class:"action-icon",onClick:y},{default:e.withCtx(()=>[e.createVNode(I,{name:"/images/svg/drawer-layout.svg",color:"#999999"})]),_:1}),e.createVNode(x,{class:"action-icon",onClick:i},{default:e.withCtx(()=>[e.createVNode(I,{name:"/images/svg/close.svg",color:"#999999"})]),_:1})])])]),e.createElementVNode("div",ke,[w.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"chat-messages",ref_key:"messageContainerRef",ref:L},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(_,O)=>(e.openBlock(),e.createElementBlock("div",{key:O,class:e.normalizeClass(["message-item",_.type==="user"?"user-message":"ai-message"])},[_.type==="ai"?(e.openBlock(),e.createBlock(pe,{key:0,ref_for:!0,ref:B=>T.value[O]=B,reader:_.reader,"onUpdate:reader":B=>_.reader=B,model:o.llmName,displayText:_.displayText,scrollToBottomFn:P,messagePostRender:n.messagePostRender,onFailed:B=>u(O,B),onCompleted:B=>f(O,B),onUpdating:()=>d()},null,8,["reader","onUpdate:reader","model","displayText","messagePostRender","onFailed","onCompleted","onUpdating"])):(e.openBlock(),e.createElementBlock("div",Ce,e.toDisplayString(_.content),1))],2))),128))],512)):(e.openBlock(),e.createElementBlock("div",we,[b[2]||(b[2]=e.createElementVNode("div",{class:"title"},[e.createElementVNode("img",{src:Z,alt:"AI助手",class:"panel-icon"}),e.createElementVNode("h3",{class:"title-text"},"Hi, 您好")],-1)),e.createElementVNode("div",ve,[b[1]||(b[1]=e.createTextVNode(" 我是",-1)),e.createElementVNode("span",Se,e.toDisplayString(n.title),1)]),e.createElementVNode("div",xe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,(_,O)=>(e.openBlock(),e.createElementBlock("div",{key:O,class:"question-item",onClick:B=>S(_)},[e.createElementVNode("span",null,e.toDisplayString(_),1),e.createVNode(x,null,{default:e.withCtx(()=>[e.createVNode(I,{name:"/images/svg/arrow-right.svg",color:"#999999"})]),_:1})],8,Ne))),128))])]))]),e.createElementVNode("div",_e,[V.value?(e.openBlock(),e.createElementBlock("img",Ee)):e.createCommentVNode("",!0),e.createElementVNode("div",Te,[e.createVNode(R,{modelValue:m.value,"onUpdate:modelValue":b[0]||(b[0]=_=>m.value=_),ref_key:"refInputTextString",ref:g,placeholder:"请输入您的问题",autofocus:"",onKeyup:e.withKeys(k,["enter"])},{append:e.withCtx(()=>[e.createElementVNode("div",{class:"send-icon-box",onClick:k},[e.createElementVNode("img",{src:p.value,alt:"发送",class:"send-icon"},null,8,Re)])]),_:1},8,["modelValue"])])])],2)):e.createCommentVNode("",!0)]),_:1})}}};var D={exports:{}};(function(n,r){(function(s,l){n.exports=l()})(window,function(){return function(s){var l={};function o(t){if(l[t])return l[t].exports;var c=l[t]={i:t,l:!1,exports:{}};return s[t].call(c.exports,c,c.exports,o),c.l=!0,c.exports}return o.m=s,o.c=l,o.d=function(t,c,m){o.o(t,c)||Object.defineProperty(t,c,{enumerable:!0,get:m})},o.r=function(t){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,c){if(1&c&&(t=o(t)),8&c||4&c&&typeof t=="object"&&t&&t.__esModule)return t;var m=Object.create(null);if(o.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:t}),2&c&&typeof t!="string")for(var g in t)o.d(m,g,(function(w){return t[w]}).bind(null,g));return m},o.n=function(t){var c=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(c,"a",c),c},o.o=function(t,c){return Object.prototype.hasOwnProperty.call(t,c)},o.p="",o(o.s=0)}([function(s,l,o){function t(p,u,f,d){f.push(p),d.push([].concat(u[p]||[]))}function c(p,u){if(!p)throw new Error("[getMaxDepsChain] dep 参数不能为空");var f=[],d=[],i=[];for(t(p,u,d,i);d.length;){var h=i.pop();if(h&&h.length){var y=h.shift();if(i.push(h),~d.indexOf(y))throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: "+y+", mainStack: "+d);t(y,u,d,i)}else f.push([].concat(d)),d.pop()}return f.reduce(function(S,v){return v.length>S.length?v:S},[])}function m(p){if(!p)throw new Error("[depsParser] 入参不能为空");var u={};p.forEach(function(d){u[d.name]=d.deps||[]});var f=[];return p.forEach(function(d){var i=c(d.name,u).length-1;d.priority=i,f[i]=(f[i]||[]).concat(d)}),f}o.r(l),o.d(l,"loadScript",function(){return T}),o.d(l,"loadScripts",function(){return C}),o.d(l,"dynamicLoadScripts",function(){return L}),o.d(l,"createScriptsLoadIterator",function(){return P}),o.d(l,"loadScriptsQueue",function(){return V}),o.d(l,"getMaxDepsChain",function(){return c}),o.d(l,"depsParser",function(){return m});var g=function(){return(g=Object.assign||function(p){for(var u,f=1,d=arguments.length;f<d;f++)for(var i in u=arguments[f])Object.prototype.hasOwnProperty.call(u,i)&&(p[i]=u[i]);return p}).apply(this,arguments)},w=function(p,u,f,d){return new(f||(f=Promise))(function(i,h){function y(k){try{v(d.next(k))}catch(a){h(a)}}function S(k){try{v(d.throw(k))}catch(a){h(a)}}function v(k){var a;k.done?i(k.value):(a=k.value,a instanceof f?a:new f(function(b){b(a)})).then(y,S)}v((d=d.apply(p,[])).next())})},N=function(p,u){var f,d,i,h,y={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return h={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(h[Symbol.iterator]=function(){return this}),h;function S(v){return function(k){return function(a){if(f)throw new TypeError("Generator is already executing.");for(;y;)try{if(f=1,d&&(i=2&a[0]?d.return:a[0]?d.throw||((i=d.return)&&i.call(d),0):d.next)&&!(i=i.call(d,a[1])).done)return i;switch(d=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return y.label++,{value:a[1],done:!1};case 5:y.label++,d=a[1],a=[0];continue;case 7:a=y.ops.pop(),y.trys.pop();continue;default:if(i=y.trys,!((i=i.length>0&&i[i.length-1])||a[0]!==6&&a[0]!==2)){y=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){y.label=a[1];break}if(a[0]===6&&y.label<i[1]){y.label=i[1],i=a;break}if(i&&y.label<i[2]){y.label=i[2],y.ops.push(a);break}i[2]&&y.ops.pop(),y.trys.pop();continue}a=u.call(p,y)}catch(b){a=[6,b],d=0}finally{f=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([v,k])}}},z=function(p){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u,f=p[Symbol.asyncIterator];return f?f.call(p):(p=typeof __values=="function"?__values(p):p[Symbol.iterator](),u={},d("next"),d("throw"),d("return"),u[Symbol.asyncIterator]=function(){return this},u);function d(i){u[i]=p[i]&&function(h){return new Promise(function(y,S){(function(v,k,a,b){Promise.resolve(b).then(function(x){v({value:x,done:a})},k)})(y,S,(h=p[i](h)).done,h.value)})}}};function T(p,u){return u===void 0&&(u=!1),new Promise(function(f,d){var i=u?document.head:document.body,h=document.createElement("script");h.type="text/javascript",h.src=p,h.crossOrigin="anonymous",h.onreadystatechange=f,h.onload=f,h.onerror=d,i.appendChild(h)})}var C=function(p,u){return u===void 0&&(u={}),w(void 0,void 0,void 0,function(){var f,d,i,h,y;return N(this,function(S){switch(S.label){case 0:return f=u.baseUrl,d=f===void 0?"":f,i=u.lastLoadResult,h=u.inHead,y=h!==void 0&&h,[4,Promise.all(p.map(function(v){return w(void 0,void 0,void 0,function(){var k,a,b,x,R,_,O,B;return N(this,function(X){switch(X.label){case 0:return k=v.name,a=v.path,b=v.deps,(O={})[k]=!0,x=O,(B={})[k]=!1,R=B,window[k]?[2,x]:[3,1];case 1:return _=!0,b&&i&&[].concat(b).forEach(function(qe){i[qe]!==!1&&(_=!0)}),_?[4,T(a.indexOf("http")===0||a.indexOf("//:")===0?a:d+a,y).then(function(){return x}).catch(function(){return R})]:[3,3];case 2:return[2,X.sent()];case 3:return[2,R]}})})}))];case 1:return[2,S.sent()]}})})},L=function(p,u){return u===void 0&&(u={}),function(){var f=[].concat(m(p));return{next:function(){if(f.length){var d=f.shift();return C(d,u).then(function(i){return{value:i,done:!1}})}return Promise.resolve({done:!0})}}}},P=function(p,u){var f;return u===void 0&&(u={}),(f={})[Symbol.asyncIterator]=L(p,u),f},V=function(p,u){return u===void 0&&(u={}),w(void 0,void 0,void 0,function(){var f,d,i,h,y,S;return N(this,function(v){switch(v.label){case 0:v.trys.push([0,5,6,11]),f=z(P(p,u)),v.label=1;case 1:return[4,f.next()];case 2:if((d=v.sent()).done)return[3,4];i=d.value,u.lastLoadResult=u.lastLoadResult||{},console.log("current load: ",i),i.forEach(function(k){u.lastLoadResult=g(g({},u.lastLoadResult),k)}),v.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return h=v.sent(),y={error:h},[3,11];case 6:return v.trys.push([6,,9,10]),d&&!d.done&&(S=f.return)?[4,S.call(f)]:[3,8];case 7:v.sent(),v.label=8;case 8:return[3,10];case 9:if(y)throw y.error;return[7];case 10:return[7];case 11:return[2,u.lastLoadResult]}})})}}])})})(D);var Be=D.exports;const Pe={key:0,class:"ai-assistant"},Oe={name:"AiChat"},ze=e.defineComponent({...Oe,props:{token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null}},setup(n){const r=e.ref(!1),s=e.ref(!1),l=()=>{r.value=!r.value},o=()=>{s.value=!0,r.value=!1},t=g=>{console.log("用户输入:",g)},c=[{name:"markdownit",path:"markdown-it.min.js"},{name:"hljs",path:"highlight.11.11.1.min.js"}];let m={};return Be.loadScriptsQueue(c,{baseUrl:"/scripts/ai/",lastLoadResult:m,inHead:!1}).then(g=>{if(console.log("load ai deps: ",g),window.markdownit){const w=window.markdownit();console.log("markdownit: ",w),de()}}),(g,w)=>s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Pe,[e.createVNode(Ve,{modelValue:r.value,"onUpdate:modelValue":w[0]||(w[0]=N=>r.value=N),onSubmit:t,token:n.token,identifier:n.identifier,baseUrl:n.baseUrl,title:n.title,llmName:n.llmName,messagePostRender:n.messagePostRender},null,8,["modelValue","token","identifier","baseUrl","title","llmName","messagePostRender"]),e.createElementVNode("div",{class:"ai-icon",onClick:l},[e.createElementVNode("div",{class:"close-icon",onClick:e.withModifiers(o,["stop"])},[...w[1]||(w[1]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"8",height:"8"},[e.createElementVNode("path",{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",fill:"currentColor"})],-1)])]),w[2]||(w[2]=e.createElementVNode("img",{src:Y,alt:"AI助手"},null,-1)),w[3]||(w[3]=e.createElementVNode("span",{class:"ai-icon-text"},"AI助手",-1))])]))}}),W=F(ze,[["__scopeId","data-v-9d212a48"]]),J=Object.freeze(Object.defineProperty({__proto__:null,SzAiChat:W},Symbol.toStringTag,{value:"Module"})),A=function(n){if(!A.installed){A.installed=!0;for(let r in J){const s=Reflect.get(J,r);n.component(s.name,s)}}},Le=n=>{console.log(`点击了路由链接: ${n}`)},je={color:"#536fec",fontWeight:"bold",textDecoration:"underline",cursor:"pointer",padding:"0 3px"},H=n=>{const r=/#router:([^#]+)#/g,s=[];let l=0,o;for(;(o=r.exec(n))!==null;){o.index>l&&s.push({text:n.substring(l,o.index)});const t=o[1];s.push({text:t,routeName:t}),l=r.lastIndex}return l<n.length&&s.push({text:n.substring(l)}),s},Q=(n,r,s={})=>{const{onRouteClick:l=Le,linkStyle:o={}}=s,t=document.createElement("a");t.href="#",t.textContent=n;const c={...je,...o};return Object.assign(t.style,c),t.addEventListener("click",m=>{m.preventDefault(),l(r)}),t},K=n=>{const r=/#router:([^#]+)#/g,s=[],l=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let o=l.nextNode();for(;o;){const t=o,c=t.textContent||"";if(r.test(c)){r.lastIndex=0;const m=H(c);m.length>0&&s.push({node:t,replacements:m})}o=l.nextNode()}return s},Ie=(n,r,s={})=>{const l=K(n);l.forEach(({node:o,replacements:t})=>{var m;const c=document.createDocumentFragment();t.forEach(({text:g,routeName:w})=>{if(w){const N=Q(g,w,s);c.appendChild(N)}else c.appendChild(document.createTextNode(g))}),(m=o.parentNode)==null||m.replaceChild(c,o)}),s!=null&&s.nodeCallback&&l.forEach(({node:o,replacements:t})=>{var c;(c=s.nodeCallback)==null||c.call(s,o,t)})},Ae="0.1.5",$e="Sz";function Ue({componentPrefix:n=$e,components:r=[]}={}){const s=[];function l(t,c,m){t.component(n+c)||t.component(n+c,m)}function o(t){s.includes(t)||(s.push(t),r.forEach(c=>{const{name:m,alias:g}=c;l(t,m,c),g&&g.forEach(w=>{l(t,w,c)})}))}return{version:Ae,componentPrefix:n,install:o}}const Me={install(n){A(n)}};E.SzAiChat=W,E.create=Ue,E.createRouteLink=Q,E.default=Me,E.findRouteTextNodes=K,E.parseRouteMarkers=H,E.routeLinkRender=Ie,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E["szjy-ai-coms"]={},E.Vue))})(this,function(E,e){"use strict";const Z="/images/ai-round.png",G="/images/ai-sqrt.png",ee="/images/bars-loading.svg";function A(n){return n.startsWith("http://")||n.startsWith("https://")?n:`${location.protocol}//${location.host}${n}`}async function te(n,r,s,l=""){const o=A(l),t=new URL(`${o}/v1/chat/completions`),i=new Request(t,{method:"post",headers:{"Content-Type":"application/json",Authorization:"Bearer app-oLZVFFdYyJX2QK3rdOLWsC2u"},body:JSON.stringify({model:"dify",stream:!0,inputs:{token:r},messages:[{role:"system",content:"你是一个专业的AI助手,请用中文回答问题。"},{role:"user",content:n}]})});return fetch(i)}async function ne(n){const r=new URL("http://localhost:11434/api/chat"),s={};Object.keys(s).forEach(o=>{r.searchParams.append(o,s[o])});const l=new Request(r,{mode:"cors",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:"llama3",stream:!0,messages:[{role:"system",content:"全程使用中文回答问题。"},{role:"user",content:n}]})});return fetch(l)}async function re(n,r){const s=new URL(`${location.origin}/spark/v1/chat/completions`),l={};Object.keys(l).forEach(t=>{s.searchParams.append(t,l[t])});const o=new Request(s,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:"generalv4.0Ultra",stream:!0,messages:[{role:"user",content:n}]})});return fetch(o)}async function oe(n,r){const s=new URL(`${location.origin}/siliconflow/v1/chat/completions`),l={};Object.keys(l).forEach(t=>{s.searchParams.append(t,l[t])});const o=new Request(s,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:"Qwen/Qwen1.5-110B-Chat",stream:!0,messages:[{role:"user",content:n}]})});return fetch(o)}async function ae(n,r){const s=new URL(`${location.origin}/moonshot/v1/chat/completions`),l={};Object.keys(l).forEach(t=>{s.searchParams.append(t,l[t])});const o=new Request(s,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:"moonshot-v1-8k",stream:!0,messages:[{role:"system",content:"你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。"},{role:"user",content:n}]})});return fetch(o)}async function se(n,r){const s=new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`),l={};Object.keys(l).forEach(t=>{s.searchParams.append(t,l[t])});const o=new Request(s,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:"qwq-32b-preview",stream:!0,messages:[{role:"system",content:"全程使用中文回答问题"},{role:"user",content:n}]})});return fetch(o)}async function le(n,r,s,l=""){const o=A(l),t=new URL(`${o}/support/${s}/a`),i={};Object.keys(i).forEach(h=>{t.searchParams.append(h,i[h])});const m=new Request(t,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({content:n})});return fetch(m)}const ie=n=>{if(n.startsWith("data:")){const r=n.substring(5).trim();if(r==="[DONE]")return{done:!0};try{return JSON.parse(r)}catch(s){console.error("JSON parsing error:",s)}}return null},U=[{label:"模拟数据模型",modelName:"standard",api:null},{label:"Spark 星火大模型",modelName:"spark",api:re},{label:"Ollama 3 大模型",modelName:"ollama3",api:ne},{label:"SiliconFlow 硅基流动大模型",modelName:"siliconflow",api:oe},{label:"Kimi Moonshot 月之暗面大模型",modelName:"moonshot",api:ae},{label:"通义千问大模型",modelName:"dashscope",api:se},{label:"数智建管大模型",modelName:"szjy",api:le},{label:"Dify (OpenAI 兼容)",modelName:"dify-openai",api:te}],q={standard(n,r){let s="";return n instanceof Uint8Array?s=r.decode(n,{stream:!0}):s=n,{content:s}},spark(n){const r=ie(n);return r.done?{done:!0}:{content:r.choices[0].delta.content||""}},siliconflow(n){return this.spark(n)},moonshot(n){return this.spark(n)},dashscope(n){return this.spark(n)},szjy(n){return this.spark(n)},"dify-openai"(n){return this.spark(n)},ollama3(n){return{content:JSON.parse(n).message.content}}},M=(n,r,s)=>{const l=n.split(s);return l.slice(0,-1).forEach(o=>{o.trim()!==""&&r.enqueue(o)}),l[l.length-1]},ce=n=>{let r="";return new TransformStream({transform(s,l){if(r+=s,r.trim().startsWith("data:"))r=M(r,l,n);else try{JSON.parse(r),r=M(r,l,n)}catch{l.enqueue(s),r=""}},flush(s){r.trim()!==""&&s.enqueue(r)}})};async function de(n,r){const s=n.api;return s?new Promise(l=>{s(r.text,r.token,r.identifier,r.baseUrl).then(o=>{if(o.body){const t=o.body.pipeThrough(new TextDecoderStream).pipeThrough(ce(`
|
|
2
|
+
`)).getReader();console.log("reader from response:",t),l({error:0,reader:t})}else l({error:1,reader:null})}).catch(o=>{l({error:1,reader:null})})}):{error:1,reader:null}}let j=null;function ue(){return j||(window.markdownit?j=new window.markdownit({html:!0,linkify:!0,typographer:!0}):console.log("markdownit is not loaded"),j)}const F=(n,r)=>{const s=n.__vccOpts||n;for(const[l,o]of r)s[l]=o;return s},fe=["src","alt"],I=F({__name:"SvgIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""},className:{type:String,default:""},basePath:{type:String,default:"/icons/"}},setup(n){const r=n,s=e.computed(()=>{if(r.name.startsWith("http://")||r.name.startsWith("https://")||r.name.startsWith("/"))return r.name;const t=r.name.endsWith(".svg")?r.name:`${r.name}.svg`;return`${r.basePath}${t}`}),l=e.computed(()=>{const t=typeof r.size=="number"?`${r.size}px`:r.size;return{width:t,height:t,display:"inline-flex",justifyContent:"center",alignItems:"center"}}),o=e.computed(()=>{const t={width:"100%",height:"100%"};return r.color&&(t.filter=`drop-shadow(0 0 0 ${r.color})`),t});return(t,i)=>(e.openBlock(),e.createElementBlock("div",{class:"svg-icon-wrapper",style:e.normalizeStyle(l.value)},[e.createElementVNode("img",{src:s.value,alt:n.name,class:e.normalizeClass(["svg-icon",n.className]),style:e.normalizeStyle(o.value)},null,14,fe)],4))}},[["__scopeId","data-v-490b11c1"]]),me=async n=>{if(navigator.clipboard&&navigator.permissions)await navigator.clipboard.writeText(n);else{const r=document.createElement("textArea");r.value=n,r.style.width=0,r.style.position="fixed",r.style.left="-999px",r.style.top="10px",r.setAttribute("readonly","readonly"),document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}},pe=["innerHTML"],he={__name:"Previewer",props:{reader:null,model:"szjy",scrollToBottomFn:null,displayText:"",messagePostRender:{type:Function,default:null}},emits:["failed","completed","updating"],setup(n,{expose:r,emit:s}){const{appContext:l}=e.getCurrentInstance(),{$message:o}=l.config.globalProperties,t=n,i=e.ref(t.displayText||""),m=e.ref(""),h=e.ref(!0),k=e.ref(!1),N=e.ref(!!t.displayText),B=s,T=e.ref(null);let C=null;const z=e.computed(()=>j?j.render(i.value):i.value),O=()=>{t.reader&&t.reader.cancel(),k.value=!0,d.value=!1,f(),N.value=!0,B("completed",i.value),h.value=!1,C&&(cancelAnimationFrame(C),C=null)},P=e.computed(()=>`${z.value}`),p=e.ref(!1),u=()=>{p.value=!0},f=()=>{p.value=!1},d=e.ref(!1),c=async()=>{if(!t.reader)return;const w=new TextDecoder("utf-8");for(h.value=!0;!k.value;)try{if(!t.reader){d.value=!0;break}const{value:a,done:b}=await t.reader.read();if(!t.reader){d.value=!0;break}if(b){d.value=!0;break}const x=q[t.model];if(!x)break;const R=x.call(q,a,w);if(R.done){d.value=!0;break}m.value+=R.content,C===null&&S()}catch(a){d.value=!0,console.log(3333,a),B("failed",a),O();break}finally{f()}},y=async()=>{t.scrollToBottomFn&&t.scrollToBottomFn()},g=(w=()=>{},a=()=>{})=>{if(m.value.length>0){const b=m.value.substring(0,10);i.value+=b,m.value=m.value.substring(10),w()}else a()},S=()=>{if(k.value&&C){cancelAnimationFrame(C),C=null,h.value=!1;return}d.value?g(()=>{C=requestAnimationFrame(S),B("updating",null)},()=>{B("completed",i.value),h.value=!1,N.value=!0,e.nextTick(()=>{if(d.value=!1,t.messagePostRender&&T.value)try{t.messagePostRender(T.value,i.value)}catch(w){console.error("messagePostRender 执行失败:",w)}}),C=null}):(g(),C=requestAnimationFrame(S)),y()};e.watch(()=>t.reader,()=>{t.reader&&c()},{immediate:!0,deep:!0}),e.onUnmounted(()=>{O()}),r({abortReader:O,initializeStart:u,initializeEnd:f}),e.computed(()=>p.value?!0:(!t.reader||!h||i.value,!1));const v=async()=>{try{const w=i.value;await me(w),o.success("复制成功")}catch(w){console.error("复制失败:",w),o.error("复制失败")}};return(w,a)=>(e.openBlock(),e.createBlock(e.Transition,{name:"fade"},{default:e.withCtx(()=>[P.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"refWrapperContent",ref:T,"text-16":"",class:"w-full h-full overflow-y-auto relative","p-24px":""},[e.createElementVNode("div",{class:"markdown-wrapper",innerHTML:P.value},null,8,pe),N.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ai-copy-btn-wrapper",onClick:v},[e.createVNode(I,{name:"/images/svg/copy.svg",color:"#666666"}),a[0]||(a[0]=e.createElementVNode("span",{class:"copy-text"},"复制",-1))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)]),_:1}))}},ye={class:"panel-header"},ge={class:"header-actions"},be={class:"header-title"},we={class:"action-icons"},ke={class:"body-content"},ve={key:0,class:"welcome-content"},Se={class:"subtitle"},xe={class:"highlight"},Ne={class:"quick-questions"},Ce=["onClick"],_e={key:1,class:"message-content user-content"},Ee={class:"panel-footer"},Te={key:0,src:ee,alt:"加载中",class:"loading-icon"},Re={class:"input-box"},Pe=["src"],Ve={__name:"ChatPanel",props:{modelValue:{type:Boolean,default:!1},token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null}},emits:["update:modelValue","submit"],setup(n,{emit:r}){const{appContext:s}=e.getCurrentInstance(),{$message:l}=s.config.globalProperties,o=n,t=e.computed(()=>U.find(a=>a.modelName===o.llmName)??U.find(a=>a.modelName==="szjy")),i=r,m=e.ref(""),h=e.ref(null),k=e.ref(!1),N=e.ref([]),B=e.ref(["什么是AI助理,能做什么?","当前项目的基本情况?","当前项目的进度情况?","当前项目的参建方有哪些?","数智建管平台有哪些功能?能做什么?"]),T=e.ref([]),C=e.ref(!1),z=e.ref(null),O=()=>{e.nextTick(()=>{if(z.value){const a=z.value,b=a.scrollHeight,x=a.scrollTop,R=a.clientHeight;b-x-R<100?a.scrollTop=b:a.scrollTo({top:b})}})},P=e.ref(!1),p=e.computed(()=>P.value?"/images/ai-stop.png":"/images/ai-send.png"),u=(a,b)=>{console.log("onFailedReader",a,b),C.value=!1;const x=v();x&&x.initializeEnd(),l.error("转换失败,请重试"),P.value=!1,setTimeout(()=>{h.value&&h.value.focus()})},f=(a,b)=>{C.value=!1,P.value=!1,O(),b&&N.value[a]&&(N.value[a].displayText=b),setTimeout(()=>{h.value&&h.value.focus()})},d=a=>{P.value=!0},c=()=>{P.value=!1,i("update:modelValue",!1),k.value=!1,N.value=[]},y=e.ref(!1),g=()=>{y.value=!y.value},S=a=>{m.value=a,w()},v=()=>{for(let a=T.value.length-1;a>=0;a--)if(T.value[a])return T.value[a];return null},w=async()=>{if(console.log("stylizingLoading:",C.value),C.value){const _=v();console.log("lastPreviewer:",_),_&&(console.log("abortReader"),_.abortReader());return}if(!m.value.trim()){console.log("no input, return"),h.value.focus();return}N.value.push({type:"user",content:m.value}),P.value=!0,k.value=!0,i("submit",m.value),O();const a=m.value;m.value="";const b=N.value.length;T.value[b]&&T.value[b].initializeStart(),C.value=!0,N.value.push({type:"ai"});const{error:x,reader:R}=await de(t.value,{text:a,token:o.token,identifier:o.identifier,baseUrl:o.baseUrl});if(x){console.log(45455,x),u(b,x);return}R&&(N.value[b].reader=R)};return(a,b)=>{const x=e.resolveComponent("el-icon"),R=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(e.Transition,{name:"slide"},{default:e.withCtx(()=>[n.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ai-panel",{"drawer-mode":y.value}])},[e.createElementVNode("div",ye,[e.createElementVNode("div",ge,[e.createElementVNode("div",be,e.toDisplayString(n.title),1),e.createElementVNode("div",we,[e.createVNode(x,{class:"action-icon",onClick:g},{default:e.withCtx(()=>[e.createVNode(I,{name:"/images/svg/drawer-layout.svg",color:"#999999"})]),_:1}),e.createVNode(x,{class:"action-icon",onClick:c},{default:e.withCtx(()=>[e.createVNode(I,{name:"/images/svg/close.svg",color:"#999999"})]),_:1})])])]),e.createElementVNode("div",ke,[k.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"chat-messages",ref_key:"messageContainerRef",ref:z},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(_,L)=>(e.openBlock(),e.createElementBlock("div",{key:L,class:e.normalizeClass(["message-item",_.type==="user"?"user-message":"ai-message"])},[_.type==="ai"?(e.openBlock(),e.createBlock(he,{key:0,ref_for:!0,ref:V=>T.value[L]=V,reader:_.reader,"onUpdate:reader":V=>_.reader=V,model:o.llmName,displayText:_.displayText,scrollToBottomFn:O,messagePostRender:n.messagePostRender,onFailed:V=>u(L,V),onCompleted:V=>f(L,V),onUpdating:()=>d()},null,8,["reader","onUpdate:reader","model","displayText","messagePostRender","onFailed","onCompleted","onUpdating"])):(e.openBlock(),e.createElementBlock("div",_e,e.toDisplayString(_.content),1))],2))),128))],512)):(e.openBlock(),e.createElementBlock("div",ve,[b[2]||(b[2]=e.createElementVNode("div",{class:"title"},[e.createElementVNode("img",{src:G,alt:"AI助手",class:"panel-icon"}),e.createElementVNode("h3",{class:"title-text"},"Hi, 您好")],-1)),e.createElementVNode("div",Se,[b[1]||(b[1]=e.createTextVNode(" 我是",-1)),e.createElementVNode("span",xe,e.toDisplayString(n.title),1)]),e.createElementVNode("div",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,(_,L)=>(e.openBlock(),e.createElementBlock("div",{key:L,class:"question-item",onClick:V=>S(_)},[e.createElementVNode("span",null,e.toDisplayString(_),1),e.createVNode(x,null,{default:e.withCtx(()=>[e.createVNode(I,{name:"/images/svg/arrow-right.svg",color:"#999999"})]),_:1})],8,Ce))),128))])]))]),e.createElementVNode("div",Ee,[P.value?(e.openBlock(),e.createElementBlock("img",Te)):e.createCommentVNode("",!0),e.createElementVNode("div",Re,[e.createVNode(R,{modelValue:m.value,"onUpdate:modelValue":b[0]||(b[0]=_=>m.value=_),ref_key:"refInputTextString",ref:h,placeholder:"请输入您的问题",autofocus:"",onKeyup:e.withKeys(w,["enter"])},{append:e.withCtx(()=>[e.createElementVNode("div",{class:"send-icon-box",onClick:w},[e.createElementVNode("img",{src:p.value,alt:"发送",class:"send-icon"},null,8,Pe)])]),_:1},8,["modelValue"])])])],2)):e.createCommentVNode("",!0)]),_:1})}}};var D={exports:{}};(function(n,r){(function(s,l){n.exports=l()})(window,function(){return function(s){var l={};function o(t){if(l[t])return l[t].exports;var i=l[t]={i:t,l:!1,exports:{}};return s[t].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=s,o.c=l,o.d=function(t,i,m){o.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:m})},o.r=function(t){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,i){if(1&i&&(t=o(t)),8&i||4&i&&typeof t=="object"&&t&&t.__esModule)return t;var m=Object.create(null);if(o.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:t}),2&i&&typeof t!="string")for(var h in t)o.d(m,h,(function(k){return t[k]}).bind(null,h));return m},o.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(i,"a",i),i},o.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},o.p="",o(o.s=0)}([function(s,l,o){function t(p,u,f,d){f.push(p),d.push([].concat(u[p]||[]))}function i(p,u){if(!p)throw new Error("[getMaxDepsChain] dep 参数不能为空");var f=[],d=[],c=[];for(t(p,u,d,c);d.length;){var y=c.pop();if(y&&y.length){var g=y.shift();if(c.push(y),~d.indexOf(g))throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: "+g+", mainStack: "+d);t(g,u,d,c)}else f.push([].concat(d)),d.pop()}return f.reduce(function(S,v){return v.length>S.length?v:S},[])}function m(p){if(!p)throw new Error("[depsParser] 入参不能为空");var u={};p.forEach(function(d){u[d.name]=d.deps||[]});var f=[];return p.forEach(function(d){var c=i(d.name,u).length-1;d.priority=c,f[c]=(f[c]||[]).concat(d)}),f}o.r(l),o.d(l,"loadScript",function(){return T}),o.d(l,"loadScripts",function(){return C}),o.d(l,"dynamicLoadScripts",function(){return z}),o.d(l,"createScriptsLoadIterator",function(){return O}),o.d(l,"loadScriptsQueue",function(){return P}),o.d(l,"getMaxDepsChain",function(){return i}),o.d(l,"depsParser",function(){return m});var h=function(){return(h=Object.assign||function(p){for(var u,f=1,d=arguments.length;f<d;f++)for(var c in u=arguments[f])Object.prototype.hasOwnProperty.call(u,c)&&(p[c]=u[c]);return p}).apply(this,arguments)},k=function(p,u,f,d){return new(f||(f=Promise))(function(c,y){function g(w){try{v(d.next(w))}catch(a){y(a)}}function S(w){try{v(d.throw(w))}catch(a){y(a)}}function v(w){var a;w.done?c(w.value):(a=w.value,a instanceof f?a:new f(function(b){b(a)})).then(g,S)}v((d=d.apply(p,[])).next())})},N=function(p,u){var f,d,c,y,g={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return y={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function S(v){return function(w){return function(a){if(f)throw new TypeError("Generator is already executing.");for(;g;)try{if(f=1,d&&(c=2&a[0]?d.return:a[0]?d.throw||((c=d.return)&&c.call(d),0):d.next)&&!(c=c.call(d,a[1])).done)return c;switch(d=0,c&&(a=[2&a[0],c.value]),a[0]){case 0:case 1:c=a;break;case 4:return g.label++,{value:a[1],done:!1};case 5:g.label++,d=a[1],a=[0];continue;case 7:a=g.ops.pop(),g.trys.pop();continue;default:if(c=g.trys,!((c=c.length>0&&c[c.length-1])||a[0]!==6&&a[0]!==2)){g=0;continue}if(a[0]===3&&(!c||a[1]>c[0]&&a[1]<c[3])){g.label=a[1];break}if(a[0]===6&&g.label<c[1]){g.label=c[1],c=a;break}if(c&&g.label<c[2]){g.label=c[2],g.ops.push(a);break}c[2]&&g.ops.pop(),g.trys.pop();continue}a=u.call(p,g)}catch(b){a=[6,b],d=0}finally{f=c=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([v,w])}}},B=function(p){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u,f=p[Symbol.asyncIterator];return f?f.call(p):(p=typeof __values=="function"?__values(p):p[Symbol.iterator](),u={},d("next"),d("throw"),d("return"),u[Symbol.asyncIterator]=function(){return this},u);function d(c){u[c]=p[c]&&function(y){return new Promise(function(g,S){(function(v,w,a,b){Promise.resolve(b).then(function(x){v({value:x,done:a})},w)})(g,S,(y=p[c](y)).done,y.value)})}}};function T(p,u){return u===void 0&&(u=!1),new Promise(function(f,d){var c=u?document.head:document.body,y=document.createElement("script");y.type="text/javascript",y.src=p,y.crossOrigin="anonymous",y.onreadystatechange=f,y.onload=f,y.onerror=d,c.appendChild(y)})}var C=function(p,u){return u===void 0&&(u={}),k(void 0,void 0,void 0,function(){var f,d,c,y,g;return N(this,function(S){switch(S.label){case 0:return f=u.baseUrl,d=f===void 0?"":f,c=u.lastLoadResult,y=u.inHead,g=y!==void 0&&y,[4,Promise.all(p.map(function(v){return k(void 0,void 0,void 0,function(){var w,a,b,x,R,_,L,V;return N(this,function(Y){switch(Y.label){case 0:return w=v.name,a=v.path,b=v.deps,(L={})[w]=!0,x=L,(V={})[w]=!1,R=V,window[w]?[2,x]:[3,1];case 1:return _=!0,b&&c&&[].concat(b).forEach(function(Fe){c[Fe]!==!1&&(_=!0)}),_?[4,T(a.indexOf("http")===0||a.indexOf("//:")===0?a:d+a,g).then(function(){return x}).catch(function(){return R})]:[3,3];case 2:return[2,Y.sent()];case 3:return[2,R]}})})}))];case 1:return[2,S.sent()]}})})},z=function(p,u){return u===void 0&&(u={}),function(){var f=[].concat(m(p));return{next:function(){if(f.length){var d=f.shift();return C(d,u).then(function(c){return{value:c,done:!1}})}return Promise.resolve({done:!0})}}}},O=function(p,u){var f;return u===void 0&&(u={}),(f={})[Symbol.asyncIterator]=z(p,u),f},P=function(p,u){return u===void 0&&(u={}),k(void 0,void 0,void 0,function(){var f,d,c,y,g,S;return N(this,function(v){switch(v.label){case 0:v.trys.push([0,5,6,11]),f=B(O(p,u)),v.label=1;case 1:return[4,f.next()];case 2:if((d=v.sent()).done)return[3,4];c=d.value,u.lastLoadResult=u.lastLoadResult||{},console.log("current load: ",c),c.forEach(function(w){u.lastLoadResult=h(h({},u.lastLoadResult),w)}),v.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return y=v.sent(),g={error:y},[3,11];case 6:return v.trys.push([6,,9,10]),d&&!d.done&&(S=f.return)?[4,S.call(f)]:[3,8];case 7:v.sent(),v.label=8;case 8:return[3,10];case 9:if(g)throw g.error;return[7];case 10:return[7];case 11:return[2,u.lastLoadResult]}})})}}])})})(D);var Be=D.exports;const Oe={key:0,class:"ai-assistant"},Le={name:"AiChat"},ze=e.defineComponent({...Le,props:{token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null}},setup(n){const r=e.ref(!1),s=e.ref(!1),l=()=>{r.value=!r.value},o=()=>{s.value=!0,r.value=!1},t=h=>{console.log("用户输入:",h)},i=[{name:"markdownit",path:"markdown-it.min.js"},{name:"hljs",path:"highlight.11.11.1.min.js"}];let m={};return Be.loadScriptsQueue(i,{baseUrl:"/scripts/ai/",lastLoadResult:m,inHead:!1}).then(h=>{if(console.log("load ai deps: ",h),window.markdownit){const k=window.markdownit();console.log("markdownit: ",k),ue()}}),(h,k)=>s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(Ve,{modelValue:r.value,"onUpdate:modelValue":k[0]||(k[0]=N=>r.value=N),onSubmit:t,token:n.token,identifier:n.identifier,baseUrl:n.baseUrl,title:n.title,llmName:n.llmName,messagePostRender:n.messagePostRender},null,8,["modelValue","token","identifier","baseUrl","title","llmName","messagePostRender"]),e.createElementVNode("div",{class:"ai-icon",onClick:l},[e.createElementVNode("div",{class:"close-icon",onClick:e.withModifiers(o,["stop"])},[...k[1]||(k[1]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"8",height:"8"},[e.createElementVNode("path",{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",fill:"currentColor"})],-1)])]),k[2]||(k[2]=e.createElementVNode("img",{src:Z,alt:"AI助手"},null,-1)),k[3]||(k[3]=e.createElementVNode("span",{class:"ai-icon-text"},"AI助手",-1))])]))}}),W=F(ze,[["__scopeId","data-v-9d212a48"]]),J=Object.freeze(Object.defineProperty({__proto__:null,SzAiChat:W},Symbol.toStringTag,{value:"Module"})),$=function(n){if(!$.installed){$.installed=!0;for(let r in J){const s=Reflect.get(J,r);n.component(s.name,s)}}},je=(n,r)=>{const s=r?`?${new URLSearchParams(r).toString()}`:"";console.log(`点击了路由链接: ${n}${s}`)},H=n=>{const r=n.indexOf("?");if(r===-1)return{routeName:n};const s=n.substring(0,r),l=n.substring(r+1),o={};return new URLSearchParams(l).forEach((i,m)=>{o[m]=i}),{routeName:s,queryParams:Object.keys(o).length>0?o:void 0}},Ie={color:"#536fec",fontWeight:"bold",textDecoration:"underline",cursor:"pointer",padding:"0 3px"},Q=n=>{const r=/#router:([^#]+)#/g,s=[];let l=0,o;for(;(o=r.exec(n))!==null;){o.index>l&&s.push({text:n.substring(l,o.index)});const t=o[1],{routeName:i,queryParams:m}=H(t);s.push({text:i,routeName:i,queryParams:m}),l=r.lastIndex}return l<n.length&&s.push({text:n.substring(l)}),s},K=(n,r,s={},l)=>{const{onRouteClick:o=je,linkStyle:t={}}=s,i=document.createElement("a");i.href="#",i.textContent=n;const m={...Ie,...t};return Object.assign(i.style,m),i.addEventListener("click",h=>{h.preventDefault(),o(r,l)}),i},X=n=>{const r=/#router:([^#]+)#/g,s=[],l=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let o=l.nextNode();for(;o;){const t=o,i=t.textContent||"";if(r.test(i)){r.lastIndex=0;const m=Q(i);m.length>0&&s.push({node:t,replacements:m})}o=l.nextNode()}return s},$e=(n,r,s={})=>{const l=X(n);l.forEach(({node:o,replacements:t})=>{var m;const i=document.createDocumentFragment();t.forEach(({text:h,routeName:k,queryParams:N})=>{if(k){const B=K(h,k,s,N);i.appendChild(B)}else i.appendChild(document.createTextNode(h))}),(m=o.parentNode)==null||m.replaceChild(i,o)}),s!=null&&s.nodeCallback&&l.forEach(({node:o,replacements:t})=>{var i;(i=s.nodeCallback)==null||i.call(s,o,t)})},Ae="0.1.6",Ue="Sz";function qe({componentPrefix:n=Ue,components:r=[]}={}){const s=[];function l(t,i,m){t.component(n+i)||t.component(n+i,m)}function o(t){s.includes(t)||(s.push(t),r.forEach(i=>{const{name:m,alias:h}=i;l(t,m,i),h&&h.forEach(k=>{l(t,k,i)})}))}return{version:Ae,componentPrefix:n,install:o}}const Me={install(n){$(n)}};E.SzAiChat=W,E.create=qe,E.createRouteLink=K,E.default=Me,E.findRouteTextNodes=X,E.parseRouteMarkerContent=H,E.parseRouteMarkers=Q,E.routeLinkRender=$e,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* 将 #router:xxx# 格式的文本替换为可点击的路由链接
|
|
4
4
|
*/
|
|
5
5
|
export interface RouteLinkOptions {
|
|
6
|
-
/**
|
|
7
|
-
onRouteClick?: (routeName: string) => void;
|
|
6
|
+
/** 路由跳转处理函数,接收路由名称和查询参数作为参数 */
|
|
7
|
+
onRouteClick?: (routeName: string, queryParams?: Record<string, string>) => void;
|
|
8
8
|
/** 节点遍历回调函数,接收节点和替换数组作为参数 */
|
|
9
9
|
nodeCallback?: (node: Node, replacements: RouteReplacement[]) => void;
|
|
10
10
|
/** 链接样式配置 */
|
|
@@ -13,7 +13,18 @@ export interface RouteLinkOptions {
|
|
|
13
13
|
export interface RouteReplacement {
|
|
14
14
|
text: string;
|
|
15
15
|
routeName?: string;
|
|
16
|
+
/** 路由链接中的查询参数,如 #router:personal?a=xx&b=yy# 中的 { a: 'xx', b: 'yy' } */
|
|
17
|
+
queryParams?: Record<string, string>;
|
|
16
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* 解析路由标记内容,分离路由名称和查询参数
|
|
21
|
+
* @param markerContent - #router:xxx# 中 xxx 部分的内容,如 "personal?a=xx&b=yy"
|
|
22
|
+
* @returns 路由名称和查询参数
|
|
23
|
+
*/
|
|
24
|
+
export declare const parseRouteMarkerContent: (markerContent: string) => {
|
|
25
|
+
routeName: string;
|
|
26
|
+
queryParams?: Record<string, string>;
|
|
27
|
+
};
|
|
17
28
|
/**
|
|
18
29
|
* 解析文本中的路由标记,返回替换数组
|
|
19
30
|
* @param text - 要解析的文本
|
|
@@ -27,7 +38,7 @@ export declare const parseRouteMarkers: (text: string) => RouteReplacement[];
|
|
|
27
38
|
* @param options - 配置选项
|
|
28
39
|
* @returns 链接元素
|
|
29
40
|
*/
|
|
30
|
-
export declare const createRouteLink: (text: string, routeName: string, options?: RouteLinkOptions) => HTMLAnchorElement;
|
|
41
|
+
export declare const createRouteLink: (text: string, routeName: string, options?: RouteLinkOptions, queryParams?: Record<string, string>) => HTMLAnchorElement;
|
|
31
42
|
/**
|
|
32
43
|
* 查找容器中包含路由标记的文本节点
|
|
33
44
|
* @param container - 容器元素
|