rt-chat-messages 1.0.2 → 1.0.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/chat-messages.es.js +287 -281
- package/dist/chat-messages.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/chat-messages.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as Q, ref as
|
|
1
|
+
import { defineComponent as Q, ref as b, onMounted as De, computed as X, createBlock as G, createCommentVNode as D, openBlock as o, Teleport as st, createElementBlock as u, withModifiers as Z, normalizeClass as le, createElementVNode as a, normalizeStyle as ve, renderSlot as be, h as Se, watch as J, nextTick as de, onUnmounted as Re, createVNode as f, withCtx as H, unref as I, createTextVNode as ze, toDisplayString as F, Fragment as ue, renderList as me, resolveDynamicComponent as Pe, withDirectives as at, vShow as nt } from "vue";
|
|
2
2
|
import lt from "markdown-it";
|
|
3
3
|
import ot from "@vscode/markdown-it-katex";
|
|
4
4
|
import Le from "mermaid";
|
|
@@ -14,20 +14,20 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
14
14
|
},
|
|
15
15
|
emits: ["update:visible", "close"],
|
|
16
16
|
setup(n, { emit: p }) {
|
|
17
|
-
const k = n,
|
|
17
|
+
const k = n, i = p, z = b(!1);
|
|
18
18
|
De(() => {
|
|
19
|
-
|
|
19
|
+
z.value = !0;
|
|
20
20
|
});
|
|
21
|
-
const $ =
|
|
22
|
-
|
|
21
|
+
const $ = X(() => k.fullscreen ? { width: "100%", height: "100%", margin: 0 } : { width: k.width }), E = () => {
|
|
22
|
+
i("update:visible", !1), i("close");
|
|
23
23
|
}, x = () => {
|
|
24
24
|
k.closeOnClickModal && E();
|
|
25
25
|
};
|
|
26
|
-
return (T,
|
|
26
|
+
return (T, _) => z.value ? (o(), G(st, {
|
|
27
27
|
key: 0,
|
|
28
28
|
to: "body"
|
|
29
29
|
}, [
|
|
30
|
-
n.visible ? (
|
|
30
|
+
n.visible ? (o(), u("div", {
|
|
31
31
|
key: 0,
|
|
32
32
|
class: le(["cm-dialog-overlay", { "is-fullscreen": n.fullscreen }]),
|
|
33
33
|
onClick: Z(x, ["self"])
|
|
@@ -41,11 +41,11 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
41
41
|
a("div", it, [
|
|
42
42
|
be(T.$slots, "default", {}, void 0, !0)
|
|
43
43
|
]),
|
|
44
|
-
n.showClose ? (
|
|
44
|
+
n.showClose ? (o(), u("button", {
|
|
45
45
|
key: 0,
|
|
46
46
|
class: "cm-dialog__close",
|
|
47
47
|
onClick: E
|
|
48
|
-
}, [...
|
|
48
|
+
}, [..._[0] || (_[0] = [
|
|
49
49
|
a("svg", {
|
|
50
50
|
viewBox: "0 0 1024 1024",
|
|
51
51
|
width: "16",
|
|
@@ -63,8 +63,8 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
63
63
|
}
|
|
64
64
|
}), oe = (n, p) => {
|
|
65
65
|
const k = n.__vccOpts || n;
|
|
66
|
-
for (const [
|
|
67
|
-
k[
|
|
66
|
+
for (const [i, z] of p)
|
|
67
|
+
k[i] = z;
|
|
68
68
|
return k;
|
|
69
69
|
}, Me = /* @__PURE__ */ oe(rt, [["__scopeId", "data-v-efdf0259"]]), ct = ["disabled"], dt = {
|
|
70
70
|
key: 0,
|
|
@@ -80,19 +80,19 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
80
80
|
},
|
|
81
81
|
emits: ["click"],
|
|
82
82
|
setup(n, { emit: p }) {
|
|
83
|
-
const k = n,
|
|
84
|
-
k.disabled || k.loading ||
|
|
83
|
+
const k = n, i = p, z = ($) => {
|
|
84
|
+
k.disabled || k.loading || i("click", $);
|
|
85
85
|
};
|
|
86
|
-
return ($, E) => (
|
|
86
|
+
return ($, E) => (o(), u("button", {
|
|
87
87
|
class: le(["cm-button", [
|
|
88
88
|
`cm-button--${n.type}`,
|
|
89
89
|
`cm-button--${n.size}`,
|
|
90
90
|
{ "is-circle": n.circle, "is-disabled": n.disabled, "is-loading": n.loading }
|
|
91
91
|
]]),
|
|
92
92
|
disabled: n.disabled || n.loading,
|
|
93
|
-
onClick:
|
|
93
|
+
onClick: z
|
|
94
94
|
}, [
|
|
95
|
-
n.loading ? (
|
|
95
|
+
n.loading ? (o(), u("span", dt, [...E[0] || (E[0] = [
|
|
96
96
|
a("svg", {
|
|
97
97
|
viewBox: "0 0 1024 1024",
|
|
98
98
|
width: "1em",
|
|
@@ -106,7 +106,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
106
106
|
])])) : be($.$slots, "default", { key: 1 }, void 0, !0)
|
|
107
107
|
], 10, ct));
|
|
108
108
|
}
|
|
109
|
-
}), N = /* @__PURE__ */ oe(ut, [["__scopeId", "data-v-bab126c7"]]),
|
|
109
|
+
}), N = /* @__PURE__ */ oe(ut, [["__scopeId", "data-v-bab126c7"]]), U = (n, p) => Q({
|
|
110
110
|
name: n,
|
|
111
111
|
render() {
|
|
112
112
|
return Se(
|
|
@@ -122,43 +122,43 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
122
122
|
[Se("path", { d: p })]
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
|
-
}), fe =
|
|
125
|
+
}), fe = U(
|
|
126
126
|
"Close",
|
|
127
127
|
"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
|
|
128
|
-
), Ee =
|
|
128
|
+
), Ee = U(
|
|
129
129
|
"ZoomIn",
|
|
130
130
|
"M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"
|
|
131
|
-
), Ie =
|
|
131
|
+
), Ie = U(
|
|
132
132
|
"ZoomOut",
|
|
133
133
|
"M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"
|
|
134
|
-
), Be =
|
|
134
|
+
), Be = U(
|
|
135
135
|
"Document",
|
|
136
136
|
"M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"
|
|
137
|
-
), Ae =
|
|
137
|
+
), Ae = U(
|
|
138
138
|
"Download",
|
|
139
139
|
"M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"
|
|
140
|
-
), mt =
|
|
140
|
+
), mt = U(
|
|
141
141
|
"VideoPlay",
|
|
142
142
|
"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"
|
|
143
|
-
), vt =
|
|
143
|
+
), vt = U(
|
|
144
144
|
"VideoPause",
|
|
145
145
|
"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"
|
|
146
|
-
), gt =
|
|
146
|
+
), gt = U(
|
|
147
147
|
"ArrowLeft",
|
|
148
148
|
"M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"
|
|
149
|
-
), ht =
|
|
149
|
+
), ht = U(
|
|
150
150
|
"ArrowRight",
|
|
151
151
|
"M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"
|
|
152
|
-
), Te =
|
|
152
|
+
), Te = U(
|
|
153
153
|
"Spinner",
|
|
154
154
|
"M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"
|
|
155
|
-
), He =
|
|
155
|
+
), He = U(
|
|
156
156
|
"Check",
|
|
157
157
|
"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"
|
|
158
|
-
), ft =
|
|
158
|
+
), ft = U(
|
|
159
159
|
"ChevronUp",
|
|
160
160
|
"M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"
|
|
161
|
-
), pt =
|
|
161
|
+
), pt = U(
|
|
162
162
|
"ChevronDown",
|
|
163
163
|
"M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"
|
|
164
164
|
), yt = ["src", "alt"], wt = { class: "preview-controls" }, kt = { class: "cm-button-group" }, Mt = {
|
|
@@ -174,7 +174,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
174
174
|
isStreaming: { type: Boolean, default: !1 }
|
|
175
175
|
},
|
|
176
176
|
setup(n) {
|
|
177
|
-
const p = n, k =
|
|
177
|
+
const p = n, k = b(), i = b(), z = b(!1), $ = b(""), E = b(""), x = b(!1), T = b(""), _ = b(!1), c = b(1), d = b({ x: 0, y: 0 }), M = b(!1), L = b({ x: 0, y: 0 }), S = b(1), C = b({ x: 0, y: 0 }), ee = b(!1), te = b({ x: 0, y: 0 }), se = b(""), q = b(/* @__PURE__ */ new Map());
|
|
178
178
|
let ae = 0;
|
|
179
179
|
Le.initialize({
|
|
180
180
|
startOnLoad: !1,
|
|
@@ -184,9 +184,9 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
184
184
|
});
|
|
185
185
|
const ge = (e) => {
|
|
186
186
|
const t = e.renderer.rules.fence;
|
|
187
|
-
e.renderer.rules.fence = (l, g, r, s,
|
|
187
|
+
e.renderer.rules.fence = (l, g, r, s, v) => {
|
|
188
188
|
const w = l[g], P = w.content.trim();
|
|
189
|
-
return (w.info ? w.info.trim() : "") === "mermaid" ? (ae++, `<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${ae}`}">${P}</pre></div>`) : t(l, g, r, s,
|
|
189
|
+
return (w.info ? w.info.trim() : "") === "mermaid" ? (ae++, `<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${ae}`}">${P}</pre></div>`) : t(l, g, r, s, v);
|
|
190
190
|
};
|
|
191
191
|
}, j = new lt({
|
|
192
192
|
html: !0,
|
|
@@ -209,13 +209,13 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
209
209
|
return r.renderToken(e, t, l);
|
|
210
210
|
};
|
|
211
211
|
j.renderer.rules.image = function(e, t, l, g, r) {
|
|
212
|
-
const s = e[t],
|
|
213
|
-
if (
|
|
214
|
-
const w = s.attrs[
|
|
212
|
+
const s = e[t], v = s.attrIndex("src");
|
|
213
|
+
if (v >= 0) {
|
|
214
|
+
const w = s.attrs[v][1], A = "img-" + ((W) => {
|
|
215
215
|
let R = 0;
|
|
216
|
-
for (let
|
|
217
|
-
const
|
|
218
|
-
R = (R << 5) - R +
|
|
216
|
+
for (let Y = 0; Y < W.length; Y++) {
|
|
217
|
+
const V = W.charCodeAt(Y);
|
|
218
|
+
R = (R << 5) - R + V, R = R & R;
|
|
219
219
|
}
|
|
220
220
|
return Math.abs(R).toString(36);
|
|
221
221
|
})(w);
|
|
@@ -264,20 +264,20 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
264
264
|
let l, g = e;
|
|
265
265
|
const r = [];
|
|
266
266
|
for (; (l = t.exec(e)) !== null; ) {
|
|
267
|
-
const s = l[0],
|
|
268
|
-
if (q.value.has(
|
|
269
|
-
const w = q.value.get(
|
|
267
|
+
const s = l[0], v = l[1];
|
|
268
|
+
if (q.value.has(v)) {
|
|
269
|
+
const w = q.value.get(v);
|
|
270
270
|
s !== w && r.push({ original: s, cached: w });
|
|
271
271
|
} else
|
|
272
|
-
q.value.set(
|
|
272
|
+
q.value.set(v, s);
|
|
273
273
|
}
|
|
274
|
-
for (const { original: s, cached:
|
|
275
|
-
g = g.replace(s,
|
|
274
|
+
for (const { original: s, cached: v } of r)
|
|
275
|
+
g = g.replace(s, v);
|
|
276
276
|
return g;
|
|
277
277
|
}, we = (e) => {
|
|
278
|
-
if (!
|
|
278
|
+
if (!i.value)
|
|
279
279
|
return;
|
|
280
|
-
const t =
|
|
280
|
+
const t = i.value;
|
|
281
281
|
if (!p.isStreaming || t.children.length === 0) {
|
|
282
282
|
t.innerHTML = e, p.isStreaming || de(() => {
|
|
283
283
|
xe(), y();
|
|
@@ -288,12 +288,12 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
288
288
|
l.innerHTML = e;
|
|
289
289
|
const g = /* @__PURE__ */ new Map();
|
|
290
290
|
t.querySelectorAll("img[data-image-id]").forEach((s) => {
|
|
291
|
-
const
|
|
292
|
-
|
|
291
|
+
const v = s.getAttribute("data-image-id");
|
|
292
|
+
v && g.set(v, s);
|
|
293
293
|
}), l.querySelectorAll("img[data-image-id]").forEach((s) => {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const w = g.get(
|
|
294
|
+
const v = s.getAttribute("data-image-id");
|
|
295
|
+
if (v && g.has(v)) {
|
|
296
|
+
const w = g.get(v);
|
|
297
297
|
s.parentNode && s.parentNode.replaceChild(w, s);
|
|
298
298
|
}
|
|
299
299
|
});
|
|
@@ -304,14 +304,14 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
304
304
|
}, K = () => {
|
|
305
305
|
try {
|
|
306
306
|
if (!p.content) {
|
|
307
|
-
se.value = "",
|
|
307
|
+
se.value = "", i.value && (i.value.innerHTML = ""), p.isStreaming || q.value.clear();
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
const e = he(p.content);
|
|
311
311
|
let t = j.render(e);
|
|
312
312
|
p.isStreaming && t.includes("<img") && (t = ye(t)), t !== se.value && (se.value = t, we(t)), p.isStreaming || q.value.clear();
|
|
313
313
|
} catch (e) {
|
|
314
|
-
console.error("Markdown rendering error:", e),
|
|
314
|
+
console.error("Markdown rendering error:", e), i.value && (i.value.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word;">${p.content}</pre>`);
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
J(() => p.content, K), J(
|
|
@@ -322,8 +322,8 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
);
|
|
325
|
-
const
|
|
326
|
-
|
|
325
|
+
const m = () => {
|
|
326
|
+
_.value = window.innerWidth < 768;
|
|
327
327
|
}, h = (e) => {
|
|
328
328
|
let t = e;
|
|
329
329
|
return t = t.replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1"), [
|
|
@@ -331,10 +331,10 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
331
331
|
/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,
|
|
332
332
|
/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g
|
|
333
333
|
].forEach((g) => {
|
|
334
|
-
t = t.replace(g, (r, s,
|
|
335
|
-
if (
|
|
334
|
+
t = t.replace(g, (r, s, v) => {
|
|
335
|
+
if (v.startsWith('"') && v.endsWith('"'))
|
|
336
336
|
return r;
|
|
337
|
-
let w =
|
|
337
|
+
let w = v.replace(/^["']+|["']+$/g, "").replace(/["]/g, '\\"');
|
|
338
338
|
return r.includes("[") ? `${s}["${w}"]` : r.includes("(") ? `${s}("${w}")` : r.includes("{") ? `${s}{"${w}"}` : r;
|
|
339
339
|
});
|
|
340
340
|
}), t;
|
|
@@ -349,94 +349,94 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
349
349
|
if (s && r.getAttribute("data-processed") !== "true")
|
|
350
350
|
try {
|
|
351
351
|
r.setAttribute("data-processed", "true"), s = h(s);
|
|
352
|
-
const
|
|
352
|
+
const v = r.getAttribute("data-mermaid-id") || `mermaid-${Date.now()}-${Math.random()}`, { svg: w } = await Le.render(v, s), P = r.parentElement;
|
|
353
353
|
if (P) {
|
|
354
354
|
const A = document.createElement("div");
|
|
355
|
-
A.className = "mermaid-svg", A.innerHTML = w, A.setAttribute("data-mermaid-svg", "true"), A.style.cursor = "pointer", A.title = "Click to zoom", A.addEventListener("click", (
|
|
356
|
-
|
|
355
|
+
A.className = "mermaid-svg", A.innerHTML = w, A.setAttribute("data-mermaid-svg", "true"), A.style.cursor = "pointer", A.title = "Click to zoom", A.addEventListener("click", (W) => {
|
|
356
|
+
W.preventDefault(), W.stopPropagation(), T.value = w, S.value = 1, C.value = { x: 0, y: 0 }, x.value = !0;
|
|
357
357
|
}), P.replaceChild(A, r);
|
|
358
358
|
}
|
|
359
|
-
} catch (
|
|
360
|
-
console.error("Mermaid render failure:",
|
|
359
|
+
} catch (v) {
|
|
360
|
+
console.error("Mermaid render failure:", v);
|
|
361
361
|
const w = document.createElement("div");
|
|
362
|
-
w.className = "mermaid-error", w.textContent = `Mermaid render error: ${
|
|
362
|
+
w.className = "mermaid-error", w.textContent = `Mermaid render error: ${v}`, (l = r.parentElement) == null || l.replaceChild(w, r);
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
}, B = (e) => {
|
|
366
366
|
e.preventDefault(), e.stopPropagation();
|
|
367
367
|
const t = e.target;
|
|
368
|
-
$.value = t.src, E.value = t.alt || "Image Preview", c.value = 1,
|
|
369
|
-
},
|
|
370
|
-
c.value <= 1 && (
|
|
371
|
-
}, Ve = () => {
|
|
372
|
-
c.value = Math.min(c.value + 1, 10), W();
|
|
368
|
+
$.value = t.src, E.value = t.alt || "Image Preview", c.value = 1, d.value = { x: 0, y: 0 }, z.value = !0;
|
|
369
|
+
}, O = () => {
|
|
370
|
+
c.value <= 1 && (d.value = { x: 0, y: 0 });
|
|
373
371
|
}, Ue = () => {
|
|
374
|
-
c.value = Math.
|
|
375
|
-
}, _e = () => {
|
|
376
|
-
c.value = 1, v.value = { x: 0, y: 0 };
|
|
372
|
+
c.value = Math.min(c.value + 1, 10), O();
|
|
377
373
|
}, Ye = () => {
|
|
378
|
-
c.value
|
|
379
|
-
},
|
|
374
|
+
c.value = Math.max(c.value - 1, 0.5), O();
|
|
375
|
+
}, _e = () => {
|
|
376
|
+
c.value = 1, d.value = { x: 0, y: 0 };
|
|
377
|
+
}, We = () => {
|
|
378
|
+
c.value <= 1 && (z.value = !1);
|
|
379
|
+
}, Oe = (e) => {
|
|
380
380
|
e.preventDefault();
|
|
381
381
|
const t = e.deltaY > 0 ? -0.5 : 0.5, l = Math.max(0.5, Math.min(10, c.value + t));
|
|
382
|
-
c.value = l,
|
|
383
|
-
},
|
|
382
|
+
c.value = l, O();
|
|
383
|
+
}, Xe = (e) => {
|
|
384
384
|
var s;
|
|
385
385
|
if (c.value <= 1) return;
|
|
386
|
-
e.preventDefault(),
|
|
387
|
-
x: e.clientX -
|
|
388
|
-
y: e.clientY -
|
|
386
|
+
e.preventDefault(), M.value = !0, L.value = {
|
|
387
|
+
x: e.clientX - d.value.x,
|
|
388
|
+
y: e.clientY - d.value.y
|
|
389
389
|
};
|
|
390
|
-
const t = e.target, l = (s = t.parentElement) == null ? void 0 : s.getBoundingClientRect(), g = (
|
|
391
|
-
if (!
|
|
392
|
-
let w =
|
|
393
|
-
const A = t.offsetWidth,
|
|
394
|
-
R > l.width ? w = Math.max(ke, Math.min(re, w)) : w = 0,
|
|
390
|
+
const t = e.target, l = (s = t.parentElement) == null ? void 0 : s.getBoundingClientRect(), g = (v) => {
|
|
391
|
+
if (!M.value || !l) return;
|
|
392
|
+
let w = v.clientX - L.value.x, P = v.clientY - L.value.y;
|
|
393
|
+
const A = t.offsetWidth, W = t.offsetHeight, R = A * c.value, Y = W * c.value, V = 0.3, ke = l.width * (1 - V - 0.5) - R / 2, re = R / 2 - l.width * (1 - V - 0.5), ce = l.height * (1 - V - 0.5) - Y / 2, ne = Y / 2 - l.height * (1 - V - 0.5);
|
|
394
|
+
R > l.width ? w = Math.max(ke, Math.min(re, w)) : w = 0, Y > l.height ? P = Math.max(ce, Math.min(ne, P)) : P = 0, d.value = { x: w, y: P };
|
|
395
395
|
}, r = () => {
|
|
396
|
-
|
|
396
|
+
M.value = !1, document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", r);
|
|
397
397
|
};
|
|
398
398
|
document.addEventListener("mousemove", g), document.addEventListener("mouseup", r);
|
|
399
|
-
},
|
|
399
|
+
}, Ve = (e) => {
|
|
400
400
|
var P;
|
|
401
401
|
if (e.touches.length !== 1) return;
|
|
402
402
|
const t = e.touches[0], l = t.clientX, g = t.clientY;
|
|
403
403
|
if (c.value <= 1) return;
|
|
404
|
-
|
|
405
|
-
x: l -
|
|
406
|
-
y: g -
|
|
404
|
+
M.value = !0, L.value = {
|
|
405
|
+
x: l - d.value.x,
|
|
406
|
+
y: g - d.value.y
|
|
407
407
|
};
|
|
408
|
-
const r = e.target, s = (P = r.parentElement) == null ? void 0 : P.getBoundingClientRect(),
|
|
409
|
-
if (!
|
|
408
|
+
const r = e.target, s = (P = r.parentElement) == null ? void 0 : P.getBoundingClientRect(), v = (A) => {
|
|
409
|
+
if (!M.value || A.touches.length !== 1 || !s)
|
|
410
410
|
return;
|
|
411
|
-
const
|
|
412
|
-
let R =
|
|
413
|
-
const
|
|
414
|
-
re > s.width ? R = Math.max(Je, Math.min(Qe, R)) : R = 0, ce > s.height ?
|
|
411
|
+
const W = A.touches[0];
|
|
412
|
+
let R = W.clientX - L.value.x, Y = W.clientY - L.value.y;
|
|
413
|
+
const V = r.offsetWidth, ke = r.offsetHeight, re = V * c.value, ce = ke * c.value, ne = 0.3, Je = s.width * (1 - ne - 0.5) - re / 2, Qe = re / 2 - s.width * (1 - ne - 0.5), et = s.height * (1 - ne - 0.5) - ce / 2, tt = ce / 2 - s.height * (1 - ne - 0.5);
|
|
414
|
+
re > s.width ? R = Math.max(Je, Math.min(Qe, R)) : R = 0, ce > s.height ? Y = Math.max(et, Math.min(tt, Y)) : Y = 0, d.value = { x: R, y: Y };
|
|
415
415
|
}, w = () => {
|
|
416
|
-
|
|
416
|
+
M.value = !1, document.removeEventListener("touchmove", v), document.removeEventListener("touchend", w);
|
|
417
417
|
};
|
|
418
|
-
document.addEventListener("touchmove",
|
|
418
|
+
document.addEventListener("touchmove", v, { passive: !1 }), document.addEventListener("touchend", w);
|
|
419
419
|
}, Ze = () => {
|
|
420
|
-
|
|
420
|
+
S.value = Math.min(S.value + 1, 10);
|
|
421
421
|
}, qe = () => {
|
|
422
|
-
|
|
422
|
+
S.value = Math.max(S.value - 1, 0.5);
|
|
423
423
|
}, $e = () => {
|
|
424
|
-
|
|
424
|
+
S.value = 1, C.value = { x: 0, y: 0 };
|
|
425
425
|
}, je = (e) => {
|
|
426
426
|
e.preventDefault();
|
|
427
427
|
const t = e.deltaY > 0 ? -0.5 : 0.5;
|
|
428
|
-
|
|
428
|
+
S.value = Math.max(0.5, Math.min(10, S.value + t));
|
|
429
429
|
}, Ke = (e) => {
|
|
430
|
-
var s,
|
|
431
|
-
if (
|
|
430
|
+
var s, v;
|
|
431
|
+
if (S.value <= 1) return;
|
|
432
432
|
e.preventDefault(), ee.value = !0, te.value = {
|
|
433
|
-
x: e.clientX -
|
|
434
|
-
y: e.clientY -
|
|
433
|
+
x: e.clientX - C.value.x,
|
|
434
|
+
y: e.clientY - C.value.y
|
|
435
435
|
};
|
|
436
|
-
const l = (
|
|
436
|
+
const l = (v = (s = e.target.closest(".mermaid-preview-content")) == null ? void 0 : s.parentElement) == null ? void 0 : v.getBoundingClientRect(), g = (w) => {
|
|
437
437
|
if (!ee.value || !l) return;
|
|
438
438
|
let P = w.clientX - te.value.x, A = w.clientY - te.value.y;
|
|
439
|
-
|
|
439
|
+
C.value = { x: P, y: A };
|
|
440
440
|
}, r = () => {
|
|
441
441
|
ee.value = !1, document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", r);
|
|
442
442
|
};
|
|
@@ -454,28 +454,28 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
454
454
|
});
|
|
455
455
|
};
|
|
456
456
|
return De(() => {
|
|
457
|
-
|
|
457
|
+
m(), window.addEventListener("resize", m), K(), xe(), y();
|
|
458
458
|
}), Re(() => {
|
|
459
459
|
k.value && k.value.querySelectorAll(
|
|
460
460
|
".markdown-content img"
|
|
461
461
|
).forEach((t) => {
|
|
462
462
|
t.removeEventListener("click", B);
|
|
463
463
|
});
|
|
464
|
-
}), (e, t) => (
|
|
464
|
+
}), (e, t) => (o(), u("div", {
|
|
465
465
|
class: "markdown-message",
|
|
466
466
|
ref_key: "markdownContainer",
|
|
467
467
|
ref: k
|
|
468
468
|
}, [
|
|
469
469
|
a("div", {
|
|
470
470
|
ref_key: "markdownContent",
|
|
471
|
-
ref:
|
|
471
|
+
ref: i,
|
|
472
472
|
class: "markdown-content"
|
|
473
473
|
}, null, 512),
|
|
474
474
|
f(Me, {
|
|
475
|
-
visible:
|
|
476
|
-
"onUpdate:visible": t[2] || (t[2] = (l) =>
|
|
477
|
-
width:
|
|
478
|
-
fullscreen:
|
|
475
|
+
visible: z.value,
|
|
476
|
+
"onUpdate:visible": t[2] || (t[2] = (l) => z.value = l),
|
|
477
|
+
width: _.value ? "95vw" : "80vw",
|
|
478
|
+
fullscreen: _.value,
|
|
479
479
|
class: "image-preview-dialog",
|
|
480
480
|
"close-on-click-modal": !1,
|
|
481
481
|
"append-to-body": ""
|
|
@@ -483,30 +483,30 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
483
483
|
default: H(() => [
|
|
484
484
|
a("div", {
|
|
485
485
|
class: "image-preview-container",
|
|
486
|
-
onClick: t[1] || (t[1] = Z((l) =>
|
|
486
|
+
onClick: t[1] || (t[1] = Z((l) => z.value = !1, ["self"]))
|
|
487
487
|
}, [
|
|
488
488
|
a("img", {
|
|
489
489
|
src: $.value,
|
|
490
490
|
alt: E.value,
|
|
491
491
|
class: "preview-image",
|
|
492
492
|
style: ve({
|
|
493
|
-
transform: `translate(${
|
|
493
|
+
transform: `translate(${d.value.x}px, ${d.value.y}px) scale(${c.value})`
|
|
494
494
|
}),
|
|
495
|
-
onWheel: Z(
|
|
495
|
+
onWheel: Z(Oe, ["prevent"]),
|
|
496
496
|
onDblclick: _e,
|
|
497
|
-
onMousedown:
|
|
498
|
-
onTouchstart: Z(
|
|
499
|
-
onClick:
|
|
497
|
+
onMousedown: Xe,
|
|
498
|
+
onTouchstart: Z(Ve, ["prevent"]),
|
|
499
|
+
onClick: We
|
|
500
500
|
}, null, 44, yt),
|
|
501
501
|
a("div", wt, [
|
|
502
502
|
a("div", kt, [
|
|
503
503
|
f(N, {
|
|
504
504
|
size: "small",
|
|
505
|
-
onClick:
|
|
505
|
+
onClick: Ye,
|
|
506
506
|
disabled: c.value <= 0.5
|
|
507
507
|
}, {
|
|
508
508
|
default: H(() => [
|
|
509
|
-
f(
|
|
509
|
+
f(I(Ie))
|
|
510
510
|
]),
|
|
511
511
|
_: 1
|
|
512
512
|
}, 8, ["disabled"]),
|
|
@@ -521,27 +521,27 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
521
521
|
}),
|
|
522
522
|
f(N, {
|
|
523
523
|
size: "small",
|
|
524
|
-
onClick:
|
|
524
|
+
onClick: Ue,
|
|
525
525
|
disabled: c.value >= 10
|
|
526
526
|
}, {
|
|
527
527
|
default: H(() => [
|
|
528
|
-
f(
|
|
528
|
+
f(I(Ee))
|
|
529
529
|
]),
|
|
530
530
|
_: 1
|
|
531
531
|
}, 8, ["disabled"])
|
|
532
532
|
]),
|
|
533
533
|
f(N, {
|
|
534
534
|
size: "small",
|
|
535
|
-
onClick: t[0] || (t[0] = (l) =>
|
|
535
|
+
onClick: t[0] || (t[0] = (l) => z.value = !1),
|
|
536
536
|
type: "danger"
|
|
537
537
|
}, {
|
|
538
538
|
default: H(() => [
|
|
539
|
-
f(
|
|
539
|
+
f(I(fe))
|
|
540
540
|
]),
|
|
541
541
|
_: 1
|
|
542
542
|
})
|
|
543
543
|
]),
|
|
544
|
-
|
|
544
|
+
_.value ? (o(), u("div", Mt, "双击重置 · 轻触关闭")) : D("", !0)
|
|
545
545
|
])
|
|
546
546
|
]),
|
|
547
547
|
_: 1
|
|
@@ -549,8 +549,8 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
549
549
|
f(Me, {
|
|
550
550
|
visible: x.value,
|
|
551
551
|
"onUpdate:visible": t[5] || (t[5] = (l) => x.value = l),
|
|
552
|
-
width:
|
|
553
|
-
fullscreen:
|
|
552
|
+
width: _.value ? "95vw" : "90vw",
|
|
553
|
+
fullscreen: _.value,
|
|
554
554
|
class: "mermaid-preview-dialog",
|
|
555
555
|
"close-on-click-modal": !1,
|
|
556
556
|
"append-to-body": ""
|
|
@@ -564,7 +564,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
564
564
|
class: "mermaid-preview-content",
|
|
565
565
|
innerHTML: T.value,
|
|
566
566
|
style: ve({
|
|
567
|
-
transform: `translate(${
|
|
567
|
+
transform: `translate(${C.value.x}px, ${C.value.y}px) scale(${S.value})`
|
|
568
568
|
}),
|
|
569
569
|
onWheel: Z(je, ["prevent"]),
|
|
570
570
|
onDblclick: $e,
|
|
@@ -576,10 +576,10 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
576
576
|
f(N, {
|
|
577
577
|
size: "small",
|
|
578
578
|
onClick: qe,
|
|
579
|
-
disabled:
|
|
579
|
+
disabled: S.value <= 0.5
|
|
580
580
|
}, {
|
|
581
581
|
default: H(() => [
|
|
582
|
-
f(
|
|
582
|
+
f(I(Ie))
|
|
583
583
|
]),
|
|
584
584
|
_: 1
|
|
585
585
|
}, 8, ["disabled"]),
|
|
@@ -588,17 +588,17 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
588
588
|
onClick: $e
|
|
589
589
|
}, {
|
|
590
590
|
default: H(() => [
|
|
591
|
-
ze(F(Math.round(
|
|
591
|
+
ze(F(Math.round(S.value * 100)) + "% ", 1)
|
|
592
592
|
]),
|
|
593
593
|
_: 1
|
|
594
594
|
}),
|
|
595
595
|
f(N, {
|
|
596
596
|
size: "small",
|
|
597
597
|
onClick: Ze,
|
|
598
|
-
disabled:
|
|
598
|
+
disabled: S.value >= 10
|
|
599
599
|
}, {
|
|
600
600
|
default: H(() => [
|
|
601
|
-
f(
|
|
601
|
+
f(I(Ee))
|
|
602
602
|
]),
|
|
603
603
|
_: 1
|
|
604
604
|
}, 8, ["disabled"])
|
|
@@ -609,12 +609,12 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
609
609
|
type: "danger"
|
|
610
610
|
}, {
|
|
611
611
|
default: H(() => [
|
|
612
|
-
f(
|
|
612
|
+
f(I(fe))
|
|
613
613
|
]),
|
|
614
614
|
_: 1
|
|
615
615
|
})
|
|
616
616
|
]),
|
|
617
|
-
|
|
617
|
+
_.value ? (o(), u("div", $t, "双击重置 · 轻触关闭")) : D("", !0)
|
|
618
618
|
])
|
|
619
619
|
]),
|
|
620
620
|
_: 1
|
|
@@ -636,10 +636,10 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
636
636
|
}, At = { class: "file-icon-wrapper" }, Tt = { class: "attachment-info" }, Ht = { class: "attachment-name" }, Dt = { class: "attachment-size" }, Rt = {
|
|
637
637
|
key: 3,
|
|
638
638
|
class: "files-content"
|
|
639
|
-
}, Pt = ["onClick"], Ft = { class: "file-icon-wrapper-small" }, Nt = { class: "file-info" },
|
|
639
|
+
}, Pt = ["onClick"], Ft = { class: "file-icon-wrapper-small" }, Nt = { class: "file-info" }, Ut = { class: "file-name" }, Yt = { class: "file-type" }, Wt = { class: "file-actions" }, Ot = {
|
|
640
640
|
key: 4,
|
|
641
641
|
class: "audio-content"
|
|
642
|
-
},
|
|
642
|
+
}, Xt = { class: "audio-player" }, Vt = { class: "audio-info" }, Zt = { class: "audio-progress" }, qt = { class: "progress-bar" }, jt = { class: "audio-time" }, Kt = { class: "image-preview-container" }, Gt = ["src"], Jt = {
|
|
643
643
|
key: 0,
|
|
644
644
|
class: "image-nav"
|
|
645
645
|
}, Qt = { class: "image-counter" }, es = /* @__PURE__ */ Q({
|
|
@@ -650,113 +650,113 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
650
650
|
isStreaming: { type: Boolean, default: !1 }
|
|
651
651
|
},
|
|
652
652
|
setup(n) {
|
|
653
|
-
const p = n, k =
|
|
653
|
+
const p = n, k = X(() => {
|
|
654
654
|
try {
|
|
655
655
|
return p.message.metadata ? JSON.parse(p.message.metadata) : {};
|
|
656
656
|
} catch {
|
|
657
657
|
return {};
|
|
658
658
|
}
|
|
659
|
-
}),
|
|
659
|
+
}), i = X(
|
|
660
660
|
() => k.value.imageUrls || []
|
|
661
|
-
),
|
|
662
|
-
let
|
|
663
|
-
const ee = (
|
|
664
|
-
T.value =
|
|
661
|
+
), z = X(() => k.value.fileUrls || []), $ = X(() => k.value.audioUrl), E = X(() => p.message.attachments && p.message.attachments.length > 0 ? p.message.attachments : k.value.attachments && Array.isArray(k.value.attachments) ? k.value.attachments : []), x = b(!1), T = b(""), _ = b(0), c = b(!1), d = b(!1), M = b(0), L = b(0), S = X(() => L.value > 0 ? M.value / L.value * 100 : 0);
|
|
662
|
+
let C = null;
|
|
663
|
+
const ee = (m, h) => {
|
|
664
|
+
T.value = m, _.value = h, x.value = !0;
|
|
665
665
|
}, te = () => {
|
|
666
|
-
|
|
666
|
+
_.value > 0 && (_.value--, T.value = i.value[_.value]);
|
|
667
667
|
}, se = () => {
|
|
668
|
-
|
|
669
|
-
}, q = (
|
|
668
|
+
_.value < i.value.length - 1 && (_.value++, T.value = i.value[_.value]);
|
|
669
|
+
}, q = (m, h) => {
|
|
670
670
|
console.error("Image load failed:", h);
|
|
671
|
-
const y =
|
|
671
|
+
const y = m.target;
|
|
672
672
|
y.style.display = "none";
|
|
673
|
-
}, ae = (
|
|
673
|
+
}, ae = (m) => {
|
|
674
674
|
try {
|
|
675
|
-
const y = new URL(
|
|
675
|
+
const y = new URL(m).pathname, B = y.substring(y.lastIndexOf("/") + 1);
|
|
676
676
|
return decodeURIComponent(B) || "Unknown File";
|
|
677
677
|
} catch {
|
|
678
678
|
return "Unknown File";
|
|
679
679
|
}
|
|
680
|
-
}, ge = (
|
|
680
|
+
}, ge = (m) => {
|
|
681
681
|
var B;
|
|
682
|
-
return ((B = ae(
|
|
683
|
-
}, j = (
|
|
684
|
-
const h = ge(
|
|
685
|
-
["jpg", "jpeg", "png", "gif", "webp", "pdf"].includes(h) ? window.open(
|
|
686
|
-
}, ie = (
|
|
682
|
+
return ((B = ae(m).split(".").pop()) == null ? void 0 : B.toUpperCase()) || "FILE";
|
|
683
|
+
}, j = (m) => {
|
|
684
|
+
const h = ge(m).toLowerCase();
|
|
685
|
+
["jpg", "jpeg", "png", "gif", "webp", "pdf"].includes(h) ? window.open(m, "_blank") : ie(m);
|
|
686
|
+
}, ie = (m) => {
|
|
687
687
|
try {
|
|
688
688
|
const h = document.createElement("a");
|
|
689
|
-
h.href =
|
|
689
|
+
h.href = m, h.download = ae(m), h.target = "_blank", document.body.appendChild(h), h.click(), document.body.removeChild(h);
|
|
690
690
|
} catch (h) {
|
|
691
691
|
console.error("Download failed:", h), alert("下载失败");
|
|
692
692
|
}
|
|
693
693
|
}, pe = async () => {
|
|
694
694
|
if ($.value)
|
|
695
695
|
try {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}),
|
|
699
|
-
|
|
700
|
-
}),
|
|
701
|
-
c.value = !1,
|
|
702
|
-
}),
|
|
703
|
-
console.error("Audio playback error:",
|
|
704
|
-
})), c.value ? (
|
|
705
|
-
} catch (
|
|
706
|
-
console.error("Audio playback failed:",
|
|
696
|
+
C || (C = new Audio(), C.src = $.value, C.addEventListener("loadedmetadata", () => {
|
|
697
|
+
L.value = (C == null ? void 0 : C.duration) || 0;
|
|
698
|
+
}), C.addEventListener("timeupdate", () => {
|
|
699
|
+
M.value = (C == null ? void 0 : C.currentTime) || 0;
|
|
700
|
+
}), C.addEventListener("ended", () => {
|
|
701
|
+
c.value = !1, M.value = 0;
|
|
702
|
+
}), C.addEventListener("error", (m) => {
|
|
703
|
+
console.error("Audio playback error:", m), d.value = !1, c.value = !1;
|
|
704
|
+
})), c.value ? (C.pause(), c.value = !1) : (d.value = !0, await C.play(), c.value = !0, d.value = !1);
|
|
705
|
+
} catch (m) {
|
|
706
|
+
console.error("Audio playback failed:", m), d.value = !1, c.value = !1;
|
|
707
707
|
}
|
|
708
|
-
}, he = (
|
|
709
|
-
const h = Math.floor(
|
|
708
|
+
}, he = (m) => {
|
|
709
|
+
const h = Math.floor(m / 60), y = Math.floor(m % 60);
|
|
710
710
|
return `${h}:${y.toString().padStart(2, "0")}`;
|
|
711
|
-
}, ye = (
|
|
712
|
-
if (
|
|
713
|
-
const h = 1024, y = ["B", "KB", "MB", "GB"], B = Math.floor(Math.log(
|
|
714
|
-
return (
|
|
715
|
-
}, we = (
|
|
711
|
+
}, ye = (m) => {
|
|
712
|
+
if (m === 0) return "0 B";
|
|
713
|
+
const h = 1024, y = ["B", "KB", "MB", "GB"], B = Math.floor(Math.log(m) / Math.log(h));
|
|
714
|
+
return (m / Math.pow(h, B)).toFixed(2) + y[B];
|
|
715
|
+
}, we = (m) => {
|
|
716
716
|
var y;
|
|
717
|
-
return ((y =
|
|
718
|
-
}, K = (
|
|
719
|
-
x.value && (
|
|
717
|
+
return ((y = m.split(".").pop()) == null ? void 0 : y.toUpperCase()) || "FILE";
|
|
718
|
+
}, K = (m) => {
|
|
719
|
+
x.value && (m.key === "ArrowLeft" ? te() : m.key === "ArrowRight" ? se() : m.key === "Escape" && (x.value = !1));
|
|
720
720
|
};
|
|
721
|
-
return J(x, (
|
|
722
|
-
|
|
721
|
+
return J(x, (m) => {
|
|
722
|
+
m ? document.addEventListener("keydown", K) : document.removeEventListener("keydown", K);
|
|
723
723
|
}), Re(() => {
|
|
724
|
-
|
|
725
|
-
}), (
|
|
724
|
+
C && (C.pause(), C = null), document.removeEventListener("keydown", K);
|
|
725
|
+
}), (m, h) => (o(), u("div", {
|
|
726
726
|
class: le(["multimodal-message", { "is-user": n.isUser, "is-assistant": !n.isUser }])
|
|
727
727
|
}, [
|
|
728
|
-
n.message.content ? (
|
|
728
|
+
n.message.content ? (o(), u("div", St, [
|
|
729
729
|
f(Fe, {
|
|
730
730
|
content: n.message.content,
|
|
731
731
|
"is-streaming": n.isStreaming
|
|
732
732
|
}, null, 8, ["content", "is-streaming"])
|
|
733
733
|
])) : D("", !0),
|
|
734
|
-
|
|
734
|
+
i.value && i.value.length > 0 ? (o(), u("div", zt, [
|
|
735
735
|
a("div", {
|
|
736
|
-
class: le(["images-grid", `grid-${Math.min(
|
|
736
|
+
class: le(["images-grid", `grid-${Math.min(i.value.length, 4)}`])
|
|
737
737
|
}, [
|
|
738
|
-
(
|
|
738
|
+
(o(!0), u(ue, null, me(i.value.slice(0, 4), (y, B) => (o(), u("div", {
|
|
739
739
|
key: B,
|
|
740
740
|
class: "image-item",
|
|
741
|
-
onClick: (
|
|
741
|
+
onClick: (O) => ee(y, B)
|
|
742
742
|
}, [
|
|
743
743
|
a("img", {
|
|
744
744
|
src: y,
|
|
745
745
|
alt: `图片 ${B + 1}`,
|
|
746
|
-
onError: (
|
|
746
|
+
onError: (O) => q(O, y),
|
|
747
747
|
loading: "lazy"
|
|
748
748
|
}, null, 40, Et),
|
|
749
|
-
B === 3 &&
|
|
749
|
+
B === 3 && i.value.length > 4 ? (o(), u("div", It, " +" + F(i.value.length - 4), 1)) : D("", !0)
|
|
750
750
|
], 8, Lt))), 128))
|
|
751
751
|
], 2)
|
|
752
752
|
])) : D("", !0),
|
|
753
|
-
E.value && E.value.length > 0 ? (
|
|
754
|
-
(
|
|
753
|
+
E.value && E.value.length > 0 ? (o(), u("div", Bt, [
|
|
754
|
+
(o(!0), u(ue, null, me(E.value, (y, B) => (o(), u("div", {
|
|
755
755
|
key: B,
|
|
756
756
|
class: "attachment-item"
|
|
757
757
|
}, [
|
|
758
758
|
a("div", At, [
|
|
759
|
-
f(
|
|
759
|
+
f(I(Be), { class: "file-icon" })
|
|
760
760
|
]),
|
|
761
761
|
a("div", Tt, [
|
|
762
762
|
a("span", Ht, F(y.name), 1),
|
|
@@ -764,60 +764,60 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
764
764
|
])
|
|
765
765
|
]))), 128))
|
|
766
766
|
])) : D("", !0),
|
|
767
|
-
|
|
768
|
-
(
|
|
767
|
+
z.value && z.value.length > 0 ? (o(), u("div", Rt, [
|
|
768
|
+
(o(!0), u(ue, null, me(z.value, (y, B) => (o(), u("div", {
|
|
769
769
|
key: B,
|
|
770
770
|
class: "file-item",
|
|
771
|
-
onClick: (
|
|
771
|
+
onClick: (O) => j(y)
|
|
772
772
|
}, [
|
|
773
773
|
a("div", Ft, [
|
|
774
|
-
f(
|
|
774
|
+
f(I(Be), { class: "file-icon" })
|
|
775
775
|
]),
|
|
776
776
|
a("div", Nt, [
|
|
777
|
-
a("span",
|
|
778
|
-
a("span",
|
|
777
|
+
a("span", Ut, F(ae(y)), 1),
|
|
778
|
+
a("span", Yt, F(ge(y)), 1)
|
|
779
779
|
]),
|
|
780
|
-
a("div",
|
|
780
|
+
a("div", Wt, [
|
|
781
781
|
f(N, {
|
|
782
782
|
size: "small",
|
|
783
783
|
type: "text",
|
|
784
|
-
onClick: Z((
|
|
784
|
+
onClick: Z((O) => ie(y), ["stop"])
|
|
785
785
|
}, {
|
|
786
786
|
default: H(() => [
|
|
787
|
-
f(
|
|
787
|
+
f(I(Ae))
|
|
788
788
|
]),
|
|
789
789
|
_: 1
|
|
790
790
|
}, 8, ["onClick"])
|
|
791
791
|
])
|
|
792
792
|
], 8, Pt))), 128))
|
|
793
793
|
])) : D("", !0),
|
|
794
|
-
$.value ? (
|
|
795
|
-
a("div",
|
|
794
|
+
$.value ? (o(), u("div", Ot, [
|
|
795
|
+
a("div", Xt, [
|
|
796
796
|
f(N, {
|
|
797
797
|
onClick: pe,
|
|
798
|
-
loading:
|
|
798
|
+
loading: d.value,
|
|
799
799
|
circle: "",
|
|
800
800
|
size: "small",
|
|
801
801
|
class: "play-btn"
|
|
802
802
|
}, {
|
|
803
803
|
default: H(() => [
|
|
804
|
-
(
|
|
804
|
+
(o(), G(Pe(c.value ? I(vt) : I(mt))))
|
|
805
805
|
]),
|
|
806
806
|
_: 1
|
|
807
807
|
}, 8, ["loading"]),
|
|
808
|
-
a("div",
|
|
808
|
+
a("div", Vt, [
|
|
809
809
|
a("div", Zt, [
|
|
810
810
|
a("div", qt, [
|
|
811
811
|
a("div", {
|
|
812
812
|
class: "progress-fill",
|
|
813
|
-
style: ve({ width:
|
|
813
|
+
style: ve({ width: S.value + "%" })
|
|
814
814
|
}, null, 4)
|
|
815
815
|
])
|
|
816
816
|
]),
|
|
817
817
|
a("div", jt, [
|
|
818
|
-
a("span", null, F(he(
|
|
818
|
+
a("span", null, F(he(M.value)), 1),
|
|
819
819
|
h[4] || (h[4] = a("span", null, "/", -1)),
|
|
820
|
-
a("span", null, F(he(
|
|
820
|
+
a("span", null, F(he(L.value)), 1)
|
|
821
821
|
])
|
|
822
822
|
]),
|
|
823
823
|
f(N, {
|
|
@@ -827,7 +827,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
827
827
|
class: "download-btn"
|
|
828
828
|
}, {
|
|
829
829
|
default: H(() => [
|
|
830
|
-
f(
|
|
830
|
+
f(I(Ae))
|
|
831
831
|
]),
|
|
832
832
|
_: 1
|
|
833
833
|
})
|
|
@@ -849,27 +849,27 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
849
849
|
class: "preview-image",
|
|
850
850
|
onClick: h[1] || (h[1] = (y) => x.value = !1)
|
|
851
851
|
}, null, 8, Gt),
|
|
852
|
-
|
|
852
|
+
i.value && i.value.length > 1 ? (o(), u("div", Jt, [
|
|
853
853
|
f(N, {
|
|
854
854
|
onClick: te,
|
|
855
|
-
disabled:
|
|
855
|
+
disabled: _.value === 0,
|
|
856
856
|
circle: "",
|
|
857
857
|
class: "nav-btn"
|
|
858
858
|
}, {
|
|
859
859
|
default: H(() => [
|
|
860
|
-
f(
|
|
860
|
+
f(I(gt))
|
|
861
861
|
]),
|
|
862
862
|
_: 1
|
|
863
863
|
}, 8, ["disabled"]),
|
|
864
|
-
a("span", Qt, F(
|
|
864
|
+
a("span", Qt, F(_.value + 1) + " / " + F(i.value.length), 1),
|
|
865
865
|
f(N, {
|
|
866
866
|
onClick: se,
|
|
867
|
-
disabled:
|
|
867
|
+
disabled: _.value === i.value.length - 1,
|
|
868
868
|
circle: "",
|
|
869
869
|
class: "nav-btn"
|
|
870
870
|
}, {
|
|
871
871
|
default: H(() => [
|
|
872
|
-
f(
|
|
872
|
+
f(I(ht))
|
|
873
873
|
]),
|
|
874
874
|
_: 1
|
|
875
875
|
}, 8, ["disabled"])
|
|
@@ -880,7 +880,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
880
880
|
circle: ""
|
|
881
881
|
}, {
|
|
882
882
|
default: H(() => [
|
|
883
|
-
f(
|
|
883
|
+
f(I(fe))
|
|
884
884
|
]),
|
|
885
885
|
_: 1
|
|
886
886
|
})
|
|
@@ -909,40 +909,40 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
909
909
|
},
|
|
910
910
|
emits: ["resize"],
|
|
911
911
|
setup(n, { emit: p }) {
|
|
912
|
-
const k = n,
|
|
913
|
-
|
|
914
|
-
|
|
912
|
+
const k = n, i = b(!0), z = p, $ = () => {
|
|
913
|
+
i.value = !i.value, setTimeout(() => {
|
|
914
|
+
z("resize");
|
|
915
915
|
}, 300);
|
|
916
|
-
}, E =
|
|
916
|
+
}, E = X(
|
|
917
917
|
() => k.steps.some((T) => T.status === "running")
|
|
918
|
-
), x =
|
|
918
|
+
), x = X(() => {
|
|
919
919
|
const T = k.steps.find((c) => c.status === "running");
|
|
920
920
|
if (T)
|
|
921
921
|
return `正在${T.displayName}...`;
|
|
922
|
-
const
|
|
922
|
+
const _ = k.steps.filter(
|
|
923
923
|
(c) => c.status === "completed"
|
|
924
924
|
).length;
|
|
925
|
-
return
|
|
925
|
+
return _ === k.steps.length ? "处理完成" : `已完成 ${_}/${k.steps.length} 个步骤`;
|
|
926
926
|
});
|
|
927
|
-
return (T,
|
|
927
|
+
return (T, _) => n.steps.length > 0 ? (o(), u("div", ts, [
|
|
928
928
|
a("div", {
|
|
929
929
|
class: "steps-header",
|
|
930
930
|
onClick: $
|
|
931
931
|
}, [
|
|
932
932
|
a("div", ss, [
|
|
933
|
-
E.value ? (
|
|
934
|
-
f(
|
|
935
|
-
])) : (
|
|
936
|
-
f(
|
|
933
|
+
E.value ? (o(), u("div", as, [
|
|
934
|
+
f(I(Te))
|
|
935
|
+
])) : (o(), u("div", ns, [
|
|
936
|
+
f(I(He))
|
|
937
937
|
]))
|
|
938
938
|
]),
|
|
939
939
|
a("span", ls, F(x.value), 1),
|
|
940
940
|
a("div", os, [
|
|
941
|
-
(
|
|
941
|
+
(o(), G(Pe(i.value ? I(ft) : I(pt))))
|
|
942
942
|
])
|
|
943
943
|
]),
|
|
944
944
|
at(a("div", is, [
|
|
945
|
-
(
|
|
945
|
+
(o(!0), u(ue, null, me(n.steps, (c) => (o(), u("div", {
|
|
946
946
|
key: c.name,
|
|
947
947
|
class: le(["step-item", {
|
|
948
948
|
"is-running": c.status === "running",
|
|
@@ -951,15 +951,15 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
951
951
|
}])
|
|
952
952
|
}, [
|
|
953
953
|
a("div", rs, [
|
|
954
|
-
c.status === "running" ? (
|
|
954
|
+
c.status === "running" ? (o(), G(I(Te), {
|
|
955
955
|
key: 0,
|
|
956
956
|
class: "icon-spin"
|
|
957
|
-
})) : c.status === "completed" ? (
|
|
957
|
+
})) : c.status === "completed" ? (o(), G(I(He), { key: 1 })) : c.status === "error" ? (o(), G(I(fe), { key: 2 })) : (o(), u("div", cs))
|
|
958
958
|
]),
|
|
959
959
|
a("span", ds, F(c.displayName), 1)
|
|
960
960
|
], 2))), 128))
|
|
961
961
|
], 512), [
|
|
962
|
-
[nt,
|
|
962
|
+
[nt, i.value]
|
|
963
963
|
])
|
|
964
964
|
])) : D("", !0);
|
|
965
965
|
}
|
|
@@ -1005,55 +1005,61 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
1005
1005
|
},
|
|
1006
1006
|
emits: ["copy", "scroll", "scroll-bottom"],
|
|
1007
1007
|
setup(n, { expose: p, emit: k }) {
|
|
1008
|
-
const
|
|
1008
|
+
const i = n, z = k, $ = b(null), E = b(!1), x = async (d = "smooth") => {
|
|
1009
1009
|
await de(), $.value && $.value.scrollTo({
|
|
1010
1010
|
top: $.value.scrollHeight,
|
|
1011
|
-
behavior:
|
|
1011
|
+
behavior: d
|
|
1012
1012
|
});
|
|
1013
|
-
}, T = (
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1016
|
-
if (!
|
|
1017
|
-
const { scrollTop:
|
|
1018
|
-
|
|
1013
|
+
}, T = (d) => {
|
|
1014
|
+
z("scroll", d);
|
|
1015
|
+
const M = d.target;
|
|
1016
|
+
if (!M) return;
|
|
1017
|
+
const { scrollTop: L, scrollHeight: S, clientHeight: C } = M;
|
|
1018
|
+
S - L - C < 50 ? (E.value = !1, z("scroll-bottom")) : E.value = !0;
|
|
1019
1019
|
};
|
|
1020
1020
|
J(
|
|
1021
|
-
() =>
|
|
1022
|
-
async () => {
|
|
1023
|
-
|
|
1021
|
+
() => i.messages.length,
|
|
1022
|
+
async (d, M) => {
|
|
1023
|
+
d > (M || 0) && (E.value = !1), i.autoScroll && !E.value && x();
|
|
1024
1024
|
}
|
|
1025
1025
|
), J(
|
|
1026
1026
|
() => {
|
|
1027
|
-
var
|
|
1028
|
-
return (
|
|
1027
|
+
var d;
|
|
1028
|
+
return (d = i.messages[i.messages.length - 1]) == null ? void 0 : d.content;
|
|
1029
1029
|
},
|
|
1030
|
-
async (
|
|
1031
|
-
|
|
1030
|
+
async (d, M) => {
|
|
1031
|
+
if (i.isStreaming && i.autoScroll && !E.value) {
|
|
1032
|
+
const L = (d == null ? void 0 : d.length) || 0, S = (M == null ? void 0 : M.length) || 0;
|
|
1033
|
+
L > S && $.value && $.value.scrollTo({
|
|
1034
|
+
top: $.value.scrollHeight,
|
|
1035
|
+
behavior: "instant"
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1032
1038
|
}
|
|
1033
1039
|
), J(
|
|
1034
|
-
() =>
|
|
1035
|
-
(
|
|
1036
|
-
|
|
1040
|
+
() => i.isTyping,
|
|
1041
|
+
(d) => {
|
|
1042
|
+
d && i.autoScroll && x();
|
|
1037
1043
|
}
|
|
1038
1044
|
);
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1045
|
+
const _ = (d) => {
|
|
1046
|
+
z("copy", d), navigator.clipboard && d.content && navigator.clipboard.writeText(d.content);
|
|
1041
1047
|
};
|
|
1042
1048
|
J(
|
|
1043
|
-
() =>
|
|
1049
|
+
() => i.agentSteps,
|
|
1044
1050
|
() => {
|
|
1045
|
-
|
|
1051
|
+
i.autoScroll && !E.value && x();
|
|
1046
1052
|
},
|
|
1047
1053
|
{ deep: !0 }
|
|
1048
1054
|
);
|
|
1049
1055
|
const c = () => {
|
|
1050
|
-
|
|
1056
|
+
i.autoScroll && !E.value && x();
|
|
1051
1057
|
};
|
|
1052
1058
|
return p({
|
|
1053
1059
|
scrollToBottom: x,
|
|
1054
1060
|
containerRef: $
|
|
1055
|
-
}), (
|
|
1056
|
-
n.showBackground ? (
|
|
1061
|
+
}), (d, M) => (o(), u("div", ms, [
|
|
1062
|
+
n.showBackground ? (o(), u("div", vs)) : D("", !0),
|
|
1057
1063
|
a("div", {
|
|
1058
1064
|
class: "chat-message-list",
|
|
1059
1065
|
ref_key: "containerRef",
|
|
@@ -1064,15 +1070,15 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
1064
1070
|
paddingBottom: n.contentPaddingBottom
|
|
1065
1071
|
})
|
|
1066
1072
|
}, [
|
|
1067
|
-
n.showWelcome && n.messages.length === 0 ? (
|
|
1068
|
-
be(
|
|
1073
|
+
n.showWelcome && n.messages.length === 0 ? (o(), u("div", gs, [
|
|
1074
|
+
be(d.$slots, "welcome", {}, () => [
|
|
1069
1075
|
a("div", hs, [
|
|
1070
1076
|
a("div", fs, [
|
|
1071
|
-
n.appLogo ? (
|
|
1077
|
+
n.appLogo ? (o(), u("img", {
|
|
1072
1078
|
key: 0,
|
|
1073
1079
|
src: n.appLogo,
|
|
1074
1080
|
alt: "Logo"
|
|
1075
|
-
}, null, 8, ps)) : (
|
|
1081
|
+
}, null, 8, ps)) : (o(), u("div", ys, [...M[0] || (M[0] = [
|
|
1076
1082
|
a("svg", {
|
|
1077
1083
|
viewBox: "0 0 1024 1024",
|
|
1078
1084
|
width: "32",
|
|
@@ -1086,41 +1092,41 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
1086
1092
|
])]))
|
|
1087
1093
|
]),
|
|
1088
1094
|
a("h2", ws, F(n.appName), 1),
|
|
1089
|
-
|
|
1095
|
+
M[1] || (M[1] = a("p", { class: "welcome-desc" }, "今天有什么可以帮您?", -1))
|
|
1090
1096
|
])
|
|
1091
1097
|
], !0)
|
|
1092
|
-
])) : (
|
|
1093
|
-
(
|
|
1094
|
-
key:
|
|
1098
|
+
])) : (o(), u("div", ks, [
|
|
1099
|
+
(o(!0), u(ue, null, me(n.messages, (L, S) => (o(), u("div", {
|
|
1100
|
+
key: L.id || S,
|
|
1095
1101
|
class: le([
|
|
1096
1102
|
"message-row",
|
|
1097
|
-
|
|
1103
|
+
L.role === "user" ? "message-user" : "message-assistant"
|
|
1098
1104
|
])
|
|
1099
1105
|
}, [
|
|
1100
|
-
|
|
1106
|
+
L.role === "user" ? (o(), u("div", Ms, [
|
|
1101
1107
|
f(Ce, {
|
|
1102
|
-
message:
|
|
1108
|
+
message: L,
|
|
1103
1109
|
"is-user": !0
|
|
1104
1110
|
}, null, 8, ["message"])
|
|
1105
|
-
])) : (
|
|
1106
|
-
n.showAgentSteps &&
|
|
1111
|
+
])) : (o(), u("div", Cs, [
|
|
1112
|
+
n.showAgentSteps && S === n.messages.length - 1 && n.agentSteps && n.agentSteps.length > 0 ? (o(), G(Ne, {
|
|
1107
1113
|
key: 0,
|
|
1108
1114
|
steps: n.agentSteps,
|
|
1109
1115
|
onResize: c
|
|
1110
1116
|
}, null, 8, ["steps"])) : D("", !0),
|
|
1111
1117
|
a("div", bs, [
|
|
1112
1118
|
f(Ce, {
|
|
1113
|
-
message:
|
|
1119
|
+
message: L,
|
|
1114
1120
|
"is-user": !1,
|
|
1115
|
-
"is-streaming": n.isStreaming &&
|
|
1121
|
+
"is-streaming": n.isStreaming && S === n.messages.length - 1
|
|
1116
1122
|
}, null, 8, ["message", "is-streaming"])
|
|
1117
1123
|
]),
|
|
1118
|
-
|
|
1124
|
+
L.content && !(n.isStreaming && S === n.messages.length - 1) ? (o(), u("div", _s, [
|
|
1119
1125
|
a("button", {
|
|
1120
1126
|
class: "action-btn",
|
|
1121
|
-
onClick: (
|
|
1127
|
+
onClick: (C) => _(L),
|
|
1122
1128
|
title: "复制"
|
|
1123
|
-
}, [...
|
|
1129
|
+
}, [...M[2] || (M[2] = [
|
|
1124
1130
|
a("svg", {
|
|
1125
1131
|
viewBox: "0 0 1024 1024",
|
|
1126
1132
|
width: "12",
|
|
@@ -1136,7 +1142,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
1136
1142
|
])) : D("", !0)
|
|
1137
1143
|
]))
|
|
1138
1144
|
], 2))), 128)),
|
|
1139
|
-
n.isTyping ? (
|
|
1145
|
+
n.isTyping ? (o(), u("div", xs, [...M[3] || (M[3] = [
|
|
1140
1146
|
a("div", { class: "typing-indicator" }, [
|
|
1141
1147
|
a("div", { class: "typing-dot" }),
|
|
1142
1148
|
a("div", {
|
|
@@ -1153,7 +1159,7 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
1153
1159
|
], 36)
|
|
1154
1160
|
]));
|
|
1155
1161
|
}
|
|
1156
|
-
}), zs = /* @__PURE__ */ oe(Ss, [["__scopeId", "data-v-
|
|
1162
|
+
}), zs = /* @__PURE__ */ oe(Ss, [["__scopeId", "data-v-02d657d5"]]), As = {
|
|
1157
1163
|
install(n) {
|
|
1158
1164
|
n.component("ChatMessageList", zs), n.component("MultimodalMessage", Ce), n.component("MarkdownMessage", Fe), n.component("AgentSteps", Ne);
|
|
1159
1165
|
}
|