@eternalheart/react-file-preview 1.0.0 → 1.0.1
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/lib/FilePreviewModal.d.ts +2 -1
- package/lib/FilePreviewModal.d.ts.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +348 -343
- package/lib/index.mjs.map +1 -1
- package/lib/types.d.ts +4 -0
- package/lib/types.d.ts.map +1 -1
- package/package.json +15 -26
package/lib/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
1
|
+
import { jsxs as f, jsx as e, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useRef as S, useEffect as M, useCallback as C, useMemo as U } from "react";
|
|
3
|
+
import { createPortal as Y } from "react-dom";
|
|
4
|
+
import { motion as B, AnimatePresence as K } from "framer-motion";
|
|
5
|
+
import { Presentation as Q, Music as J, SkipBack as ee, Pause as te, Play as re, SkipForward as oe, VolumeX as ne, Volume2 as le, FileText as ae, FileQuestion as se, Download as Z, ZoomOut as ie, ZoomIn as ce, Minimize2 as de, Maximize2 as me, RotateCcw as ue, RotateCw as he, RefreshCw as pe, X as fe, ChevronLeft as xe, ChevronRight as we } from "lucide-react";
|
|
6
|
+
import { pdfjs as H, Document as ge, Page as be } from "react-pdf";
|
|
7
|
+
import ve from "mammoth";
|
|
8
|
+
import * as V from "xlsx";
|
|
9
|
+
import { init as X } from "pptx-preview";
|
|
10
|
+
import ye from "video.js";
|
|
11
|
+
import Ne from "react-markdown";
|
|
12
|
+
import ke from "remark-gfm";
|
|
13
|
+
import { Prism as _ } from "react-syntax-highlighter";
|
|
14
|
+
function je(r) {
|
|
14
15
|
try {
|
|
15
16
|
const i = new URL(r).pathname.split("/").pop() || "file";
|
|
16
17
|
return decodeURIComponent(i);
|
|
@@ -19,7 +20,7 @@ function ve(r) {
|
|
|
19
20
|
return decodeURIComponent(t);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function A(r) {
|
|
23
24
|
var i;
|
|
24
25
|
const t = ((i = r.split(".").pop()) == null ? void 0 : i.toLowerCase()) || "";
|
|
25
26
|
return {
|
|
@@ -80,99 +81,99 @@ function B(r) {
|
|
|
80
81
|
yml: "text/yaml"
|
|
81
82
|
}[t] || "application/octet-stream";
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function Ce(r, t = 0) {
|
|
84
85
|
if (r instanceof File)
|
|
85
86
|
return {
|
|
86
87
|
id: `file-${Date.now()}-${t}`,
|
|
87
88
|
name: r.name,
|
|
88
89
|
url: URL.createObjectURL(r),
|
|
89
|
-
type: r.type ||
|
|
90
|
+
type: r.type || A(r.name),
|
|
90
91
|
size: r.size
|
|
91
92
|
};
|
|
92
93
|
if (typeof r == "string") {
|
|
93
|
-
const n =
|
|
94
|
+
const n = je(r);
|
|
94
95
|
return {
|
|
95
96
|
id: `url-${Date.now()}-${t}`,
|
|
96
97
|
name: n,
|
|
97
98
|
url: r,
|
|
98
|
-
type:
|
|
99
|
+
type: A(n)
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
return {
|
|
102
103
|
id: r.id || `link-${Date.now()}-${t}`,
|
|
103
104
|
name: r.name,
|
|
104
105
|
url: r.url,
|
|
105
|
-
type: r.type ||
|
|
106
|
+
type: r.type || A(r.name),
|
|
106
107
|
size: r.size
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
return r.map((t, n) =>
|
|
110
|
+
function Me(r) {
|
|
111
|
+
return r.map((t, n) => Ce(t, n));
|
|
111
112
|
}
|
|
112
|
-
const
|
|
113
|
+
const Te = ({
|
|
113
114
|
url: r,
|
|
114
115
|
zoom: t,
|
|
115
116
|
rotation: n,
|
|
116
117
|
onZoomChange: i
|
|
117
118
|
}) => {
|
|
118
|
-
const [c, d] =
|
|
119
|
+
const [c, d] = b(!1), [s, o] = b(null), [a, w] = b({ x: 0, y: 0 }), [p, u] = b(!1), [v, h] = b({ x: 0, y: 0 }), [l, x] = b(1), m = S(null);
|
|
119
120
|
M(() => {
|
|
120
|
-
d(!1), o(null),
|
|
121
|
+
d(!1), o(null), w({ x: 0, y: 0 }), x(1);
|
|
121
122
|
}, [r]), M(() => {
|
|
122
|
-
|
|
123
|
+
x(t);
|
|
123
124
|
}, [t]), M(() => {
|
|
124
|
-
|
|
125
|
+
w({ x: 0, y: 0 });
|
|
125
126
|
}, [t, n]);
|
|
126
127
|
const k = () => {
|
|
127
128
|
d(!0);
|
|
128
129
|
}, T = () => {
|
|
129
130
|
o("图片加载失败"), d(!0);
|
|
130
131
|
}, L = () => {
|
|
131
|
-
|
|
132
|
+
w({ x: 0, y: 0 });
|
|
132
133
|
}, P = C((N) => {
|
|
133
134
|
N.preventDefault(), N.stopPropagation();
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
return i && i(
|
|
135
|
+
const D = N.deltaY > 0 ? -0.1 : 0.1;
|
|
136
|
+
x((R) => {
|
|
137
|
+
const F = Math.max(0.5, Math.min(5, R + D));
|
|
138
|
+
return i && i(F), F;
|
|
138
139
|
});
|
|
139
140
|
}, [i]), z = C((N) => {
|
|
140
|
-
N.button === 0 && (
|
|
141
|
+
N.button === 0 && (u(!0), h({
|
|
141
142
|
x: N.clientX - a.x,
|
|
142
143
|
y: N.clientY - a.y
|
|
143
144
|
}));
|
|
144
|
-
}, [a]),
|
|
145
|
-
|
|
145
|
+
}, [a]), g = C((N) => {
|
|
146
|
+
p && w({
|
|
146
147
|
x: N.clientX - v.x,
|
|
147
148
|
y: N.clientY - v.y
|
|
148
149
|
});
|
|
149
|
-
}, [
|
|
150
|
-
|
|
150
|
+
}, [p, v]), j = C(() => {
|
|
151
|
+
u(!1);
|
|
151
152
|
}, []);
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ f(
|
|
153
154
|
"div",
|
|
154
155
|
{
|
|
155
|
-
ref:
|
|
156
|
+
ref: m,
|
|
156
157
|
className: "flex items-center justify-center w-full h-full overflow-hidden",
|
|
157
158
|
onWheel: P,
|
|
158
159
|
onMouseDown: z,
|
|
159
|
-
onMouseMove:
|
|
160
|
+
onMouseMove: g,
|
|
160
161
|
onMouseUp: j,
|
|
161
162
|
onMouseLeave: j,
|
|
162
|
-
style: { cursor:
|
|
163
|
+
style: { cursor: p ? "grabbing" : "grab" },
|
|
163
164
|
children: [
|
|
164
165
|
!c && !s && /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin" }) }),
|
|
165
166
|
s && /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: s }) }),
|
|
166
167
|
/* @__PURE__ */ e(
|
|
167
|
-
|
|
168
|
+
B.img,
|
|
168
169
|
{
|
|
169
170
|
src: r,
|
|
170
171
|
alt: "Preview",
|
|
171
172
|
className: `max-w-none select-none ${c ? "" : "hidden"}`,
|
|
172
173
|
style: {
|
|
173
|
-
transform: `translate(${a.x}px, ${a.y}px) scale(${
|
|
174
|
+
transform: `translate(${a.x}px, ${a.y}px) scale(${l}) rotate(${n}deg)`,
|
|
174
175
|
transformOrigin: "center",
|
|
175
|
-
transition:
|
|
176
|
+
transition: p ? "none" : "transform 0.3s ease-out"
|
|
176
177
|
},
|
|
177
178
|
onLoad: k,
|
|
178
179
|
onError: T,
|
|
@@ -186,69 +187,69 @@ const ke = ({
|
|
|
186
187
|
]
|
|
187
188
|
}
|
|
188
189
|
);
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
const
|
|
190
|
+
}, Le = H.version, Se = "/pdf.worker.min.mjs";
|
|
191
|
+
H.GlobalWorkerOptions.workerSrc = Se;
|
|
192
|
+
const Pe = H.GlobalWorkerOptions.workerSrc, q = `https://unpkg.com/pdfjs-dist@${Le}/build/pdf.worker.min.mjs`;
|
|
192
193
|
typeof window < "u" && window.addEventListener("error", (r) => {
|
|
193
194
|
var t;
|
|
194
|
-
(t = r.message) != null && t.includes("pdf.worker") &&
|
|
195
|
+
(t = r.message) != null && t.includes("pdf.worker") && H.GlobalWorkerOptions.workerSrc === Pe && (console.warn("本地 PDF worker 加载失败,切换到 CDN:", q), H.GlobalWorkerOptions.workerSrc = q);
|
|
195
196
|
});
|
|
196
|
-
const
|
|
197
|
+
const Re = ({
|
|
197
198
|
url: r,
|
|
198
199
|
zoom: t,
|
|
199
200
|
currentPage: n,
|
|
200
201
|
onPageChange: i,
|
|
201
202
|
onTotalPagesChange: c
|
|
202
203
|
}) => {
|
|
203
|
-
const [d, s] =
|
|
204
|
+
const [d, s] = b(0), [o, a] = b(null), w = S(null), p = S(/* @__PURE__ */ new Map());
|
|
204
205
|
M(() => {
|
|
205
206
|
a(null);
|
|
206
207
|
}, [r]);
|
|
207
|
-
const
|
|
208
|
-
s(
|
|
209
|
-
}, v = (
|
|
210
|
-
console.error("PDF 加载错误:",
|
|
211
|
-
},
|
|
212
|
-
if (!
|
|
213
|
-
const
|
|
208
|
+
const u = ({ numPages: x }) => {
|
|
209
|
+
s(x), c(x), i(1);
|
|
210
|
+
}, v = (x) => {
|
|
211
|
+
console.error("PDF 加载错误:", x), a("PDF 文件加载失败");
|
|
212
|
+
}, h = C(() => {
|
|
213
|
+
if (!w.current) return;
|
|
214
|
+
const x = w.current, m = x.scrollTop, k = x.clientHeight, T = m + k / 2;
|
|
214
215
|
let L = 1, P = 1 / 0;
|
|
215
|
-
|
|
216
|
-
const j = z.getBoundingClientRect(), N =
|
|
217
|
-
|
|
216
|
+
p.current.forEach((z, g) => {
|
|
217
|
+
const j = z.getBoundingClientRect(), N = x.getBoundingClientRect(), D = j.top - N.top + j.height / 2 + m, R = Math.abs(D - T);
|
|
218
|
+
R < P && (P = R, L = g);
|
|
218
219
|
}), L !== n && i(L);
|
|
219
220
|
}, [n, i]);
|
|
220
221
|
M(() => {
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
223
|
-
return
|
|
224
|
-
}, [
|
|
225
|
-
const
|
|
226
|
-
|
|
222
|
+
const x = w.current;
|
|
223
|
+
if (x)
|
|
224
|
+
return x.addEventListener("scroll", h), () => x.removeEventListener("scroll", h);
|
|
225
|
+
}, [h]);
|
|
226
|
+
const l = C((x, m) => {
|
|
227
|
+
m ? p.current.set(x, m) : p.current.delete(x);
|
|
227
228
|
}, []);
|
|
228
|
-
return /* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ f(
|
|
229
230
|
"div",
|
|
230
231
|
{
|
|
231
|
-
ref:
|
|
232
|
+
ref: w,
|
|
232
233
|
className: "flex flex-col items-center w-full h-full overflow-auto py-8 px-4",
|
|
233
234
|
children: [
|
|
234
235
|
o && /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: o }) }),
|
|
235
236
|
!o && /* @__PURE__ */ e(
|
|
236
|
-
|
|
237
|
+
ge,
|
|
237
238
|
{
|
|
238
239
|
file: r,
|
|
239
|
-
onLoadSuccess:
|
|
240
|
+
onLoadSuccess: u,
|
|
240
241
|
onLoadError: v,
|
|
241
242
|
loading: /* @__PURE__ */ e("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ e("div", { className: "w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin" }) }),
|
|
242
|
-
children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-4", children: Array.from(new Array(d), (
|
|
243
|
-
const k =
|
|
244
|
-
return /* @__PURE__ */
|
|
243
|
+
children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-4", children: Array.from(new Array(d), (x, m) => {
|
|
244
|
+
const k = m + 1;
|
|
245
|
+
return /* @__PURE__ */ f(
|
|
245
246
|
"div",
|
|
246
247
|
{
|
|
247
|
-
ref: (T) =>
|
|
248
|
+
ref: (T) => l(k, T),
|
|
248
249
|
className: "relative",
|
|
249
250
|
children: [
|
|
250
251
|
/* @__PURE__ */ e(
|
|
251
|
-
|
|
252
|
+
be,
|
|
252
253
|
{
|
|
253
254
|
pageNumber: k,
|
|
254
255
|
scale: t,
|
|
@@ -266,7 +267,7 @@ const Te = ({
|
|
|
266
267
|
}) })
|
|
267
268
|
}
|
|
268
269
|
),
|
|
269
|
-
d > 0 && /* @__PURE__ */
|
|
270
|
+
d > 0 && /* @__PURE__ */ f("div", { className: "sticky bottom-4 mt-8 bg-black/60 backdrop-blur-xl text-white px-6 py-3 rounded-full text-sm font-medium shadow-2xl border border-white/10", children: [
|
|
270
271
|
"第 ",
|
|
271
272
|
n,
|
|
272
273
|
" 页 / 共 ",
|
|
@@ -276,8 +277,8 @@ const Te = ({
|
|
|
276
277
|
]
|
|
277
278
|
}
|
|
278
279
|
);
|
|
279
|
-
},
|
|
280
|
-
const [t, n] =
|
|
280
|
+
}, De = ({ url: r }) => {
|
|
281
|
+
const [t, n] = b(""), [i, c] = b(!0), [d, s] = b(null);
|
|
281
282
|
return M(() => {
|
|
282
283
|
(async () => {
|
|
283
284
|
c(!0), s(null), n("");
|
|
@@ -285,8 +286,8 @@ const Te = ({
|
|
|
285
286
|
const a = await fetch(r);
|
|
286
287
|
if (!a.ok)
|
|
287
288
|
throw new Error("文件加载失败");
|
|
288
|
-
const
|
|
289
|
-
n(
|
|
289
|
+
const w = await a.arrayBuffer(), p = await ve.convertToHtml({ arrayBuffer: w });
|
|
290
|
+
n(p.value);
|
|
290
291
|
} catch (a) {
|
|
291
292
|
console.error("Docx 解析错误:", a), s("Word 文档解析失败");
|
|
292
293
|
} finally {
|
|
@@ -305,22 +306,22 @@ const Te = ({
|
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
) });
|
|
308
|
-
},
|
|
309
|
-
const [t, n] =
|
|
309
|
+
}, Ee = ({ url: r }) => {
|
|
310
|
+
const [t, n] = b([]), [i, c] = b(0), [d, s] = b(!0), [o, a] = b(null);
|
|
310
311
|
if (M(() => {
|
|
311
312
|
(async () => {
|
|
312
313
|
s(!0), a(null), n([]);
|
|
313
314
|
try {
|
|
314
|
-
const
|
|
315
|
-
if (!
|
|
315
|
+
const u = await fetch(r);
|
|
316
|
+
if (!u.ok)
|
|
316
317
|
throw new Error("文件加载失败");
|
|
317
|
-
const v = await
|
|
318
|
-
const
|
|
319
|
-
return { name:
|
|
318
|
+
const v = await u.arrayBuffer(), h = V.read(v, { type: "array" }), l = h.SheetNames.map((x) => {
|
|
319
|
+
const m = h.Sheets[x], k = V.utils.sheet_to_json(m, { header: 1 });
|
|
320
|
+
return { name: x, data: k };
|
|
320
321
|
});
|
|
321
|
-
n(
|
|
322
|
-
} catch (
|
|
323
|
-
console.error("Excel 解析错误:",
|
|
322
|
+
n(l), c(0);
|
|
323
|
+
} catch (u) {
|
|
324
|
+
console.error("Excel 解析错误:", u), a("Excel 文件解析失败");
|
|
324
325
|
} finally {
|
|
325
326
|
s(!1);
|
|
326
327
|
}
|
|
@@ -329,38 +330,38 @@ const Te = ({
|
|
|
329
330
|
return /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin" }) });
|
|
330
331
|
if (o)
|
|
331
332
|
return /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: o }) }) });
|
|
332
|
-
const
|
|
333
|
-
return /* @__PURE__ */
|
|
334
|
-
t.length > 1 && /* @__PURE__ */ e("div", { className: "flex gap-2 p-4 bg-black/20 backdrop-blur-sm overflow-x-auto border-b border-white/10", children: t.map((
|
|
333
|
+
const w = t[i];
|
|
334
|
+
return /* @__PURE__ */ f("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
335
|
+
t.length > 1 && /* @__PURE__ */ e("div", { className: "flex gap-2 p-4 bg-black/20 backdrop-blur-sm overflow-x-auto border-b border-white/10", children: t.map((p, u) => /* @__PURE__ */ e(
|
|
335
336
|
"button",
|
|
336
337
|
{
|
|
337
|
-
onClick: () => c(
|
|
338
|
-
className: `px-4 py-2 rounded-lg text-sm font-medium transition-all ${i ===
|
|
339
|
-
children:
|
|
338
|
+
onClick: () => c(u),
|
|
339
|
+
className: `px-4 py-2 rounded-lg text-sm font-medium transition-all ${i === u ? "bg-gradient-to-r from-purple-500 to-pink-500 text-white shadow-lg" : "bg-white/10 text-white hover:bg-white/20"}`,
|
|
340
|
+
children: p.name
|
|
340
341
|
},
|
|
341
|
-
|
|
342
|
+
u
|
|
342
343
|
)) }),
|
|
343
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto p-8", children: /* @__PURE__ */ e("div", { className: "inline-block min-w-full bg-gradient-to-br from-gray-800/90 to-gray-900/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden border border-white/10", children: /* @__PURE__ */ e("table", { className: "min-w-full divide-y divide-white/10", children: /* @__PURE__ */ e("tbody", { className: "divide-y divide-white/10", children:
|
|
344
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto p-8", children: /* @__PURE__ */ e("div", { className: "inline-block min-w-full bg-gradient-to-br from-gray-800/90 to-gray-900/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden border border-white/10", children: /* @__PURE__ */ e("table", { className: "min-w-full divide-y divide-white/10", children: /* @__PURE__ */ e("tbody", { className: "divide-y divide-white/10", children: w == null ? void 0 : w.data.map((p, u) => /* @__PURE__ */ e(
|
|
344
345
|
"tr",
|
|
345
346
|
{
|
|
346
|
-
className: `transition-colors ${
|
|
347
|
-
children:
|
|
347
|
+
className: `transition-colors ${u === 0 ? "bg-gradient-to-r from-purple-500/20 to-pink-500/20 font-semibold" : "hover:bg-white/5"}`,
|
|
348
|
+
children: p.map((v, h) => /* @__PURE__ */ e(
|
|
348
349
|
"td",
|
|
349
350
|
{
|
|
350
351
|
className: "px-6 py-4 whitespace-nowrap text-sm text-gray-200 border-r border-white/10",
|
|
351
352
|
children: String(v ?? "")
|
|
352
353
|
},
|
|
353
|
-
|
|
354
|
+
h
|
|
354
355
|
))
|
|
355
356
|
},
|
|
356
|
-
|
|
357
|
+
u
|
|
357
358
|
)) }) }) }) })
|
|
358
359
|
] });
|
|
359
|
-
},
|
|
360
|
-
const [t, n] =
|
|
360
|
+
}, ze = ({ url: r }) => {
|
|
361
|
+
const [t, n] = b(!0), [i, c] = b(null), d = S(null), s = S(null), o = S(null), a = S(null), w = S(null), p = S({ width: 0, height: 0 }), u = C(() => {
|
|
361
362
|
if (!d.current) return { width: 960, height: 540 };
|
|
362
|
-
const
|
|
363
|
-
return console.log("计算尺寸:", { width:
|
|
363
|
+
const h = d.current.clientWidth, l = Math.floor(h * 9 / 16);
|
|
364
|
+
return console.log("计算尺寸:", { width: h, height: l }), { width: h, height: l };
|
|
364
365
|
}, []), v = C(async () => {
|
|
365
366
|
if (!(!d.current || !a.current)) {
|
|
366
367
|
console.log("重新初始化预览器...");
|
|
@@ -368,53 +369,53 @@ const Te = ({
|
|
|
368
369
|
if (s.current)
|
|
369
370
|
try {
|
|
370
371
|
s.current.destroy();
|
|
371
|
-
} catch (
|
|
372
|
-
console.error("销毁预览器失败:",
|
|
372
|
+
} catch (x) {
|
|
373
|
+
console.error("销毁预览器失败:", x);
|
|
373
374
|
}
|
|
374
375
|
d.current.innerHTML = "";
|
|
375
|
-
const
|
|
376
|
-
console.log("重新初始化使用尺寸:",
|
|
377
|
-
const
|
|
378
|
-
width:
|
|
379
|
-
height:
|
|
376
|
+
const h = u();
|
|
377
|
+
console.log("重新初始化使用尺寸:", h);
|
|
378
|
+
const l = X(d.current, {
|
|
379
|
+
width: h.width,
|
|
380
|
+
height: h.height
|
|
380
381
|
});
|
|
381
|
-
s.current =
|
|
382
|
-
} catch (
|
|
383
|
-
console.error("重新初始化失败:",
|
|
382
|
+
s.current = l, await l.preview(a.current), console.log("重新初始化成功");
|
|
383
|
+
} catch (h) {
|
|
384
|
+
console.error("重新初始化失败:", h);
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
|
-
}, [
|
|
387
|
+
}, [u]);
|
|
387
388
|
return M(() => {
|
|
388
389
|
if (!d.current) return;
|
|
389
|
-
let
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
392
|
-
|
|
393
|
-
const L =
|
|
394
|
-
|
|
390
|
+
let h = !0;
|
|
391
|
+
const l = () => {
|
|
392
|
+
if (h) {
|
|
393
|
+
h = !1;
|
|
394
|
+
const L = u();
|
|
395
|
+
p.current = L;
|
|
395
396
|
return;
|
|
396
397
|
}
|
|
397
|
-
const
|
|
398
|
+
const x = u(), m = p.current, k = Math.abs(m.width - x.width), T = Math.abs(m.height - x.height);
|
|
398
399
|
if (k < 10 && T < 10) {
|
|
399
400
|
console.log("尺寸变化太小,忽略");
|
|
400
401
|
return;
|
|
401
402
|
}
|
|
402
403
|
console.log("检测到尺寸变化:", {
|
|
403
|
-
old:
|
|
404
|
-
new:
|
|
404
|
+
old: m,
|
|
405
|
+
new: x,
|
|
405
406
|
diff: { width: k, height: T }
|
|
406
|
-
}),
|
|
407
|
+
}), p.current = x, w.current && clearTimeout(w.current), w.current = window.setTimeout(() => {
|
|
407
408
|
s.current && a.current && (console.log("尺寸变化,准备重新初始化"), v());
|
|
408
409
|
}, 800);
|
|
409
410
|
};
|
|
410
411
|
return o.current = new ResizeObserver(() => {
|
|
411
|
-
|
|
412
|
+
l();
|
|
412
413
|
}), o.current.observe(d.current), () => {
|
|
413
|
-
o.current && o.current.disconnect(),
|
|
414
|
+
o.current && o.current.disconnect(), w.current && clearTimeout(w.current);
|
|
414
415
|
};
|
|
415
|
-
}, [
|
|
416
|
-
let
|
|
417
|
-
const
|
|
416
|
+
}, [u, v]), M(() => {
|
|
417
|
+
let h = !0;
|
|
418
|
+
const l = async () => {
|
|
418
419
|
if (!d.current) {
|
|
419
420
|
console.log("Container ref not ready");
|
|
420
421
|
return;
|
|
@@ -422,48 +423,48 @@ const Te = ({
|
|
|
422
423
|
n(!0), c(null);
|
|
423
424
|
try {
|
|
424
425
|
console.log("开始加载 PPTX:", r);
|
|
425
|
-
const
|
|
426
|
-
if (!
|
|
426
|
+
const m = await fetch(r);
|
|
427
|
+
if (!m.ok)
|
|
427
428
|
throw new Error("文件加载失败");
|
|
428
|
-
const k = await
|
|
429
|
-
if (a.current = k, console.log("文件加载成功,大小:", k.byteLength), !
|
|
429
|
+
const k = await m.arrayBuffer();
|
|
430
|
+
if (a.current = k, console.log("文件加载成功,大小:", k.byteLength), !h) return;
|
|
430
431
|
d.current && (d.current.innerHTML = "");
|
|
431
|
-
const T =
|
|
432
|
+
const T = u();
|
|
432
433
|
console.log("使用尺寸:", T), console.log("初始化预览器...");
|
|
433
|
-
const L =
|
|
434
|
+
const L = X(d.current, {
|
|
434
435
|
width: T.width,
|
|
435
436
|
height: T.height
|
|
436
437
|
});
|
|
437
438
|
s.current = L, console.log("开始预览..."), L.preview(k).then(() => {
|
|
438
|
-
console.log("预览成功"),
|
|
439
|
+
console.log("预览成功"), h && n(!1);
|
|
439
440
|
}).catch((P) => {
|
|
440
|
-
console.error("预览失败:", P),
|
|
441
|
+
console.error("预览失败:", P), h && (c("PPT 文件预览失败"), n(!1));
|
|
441
442
|
});
|
|
442
|
-
} catch (
|
|
443
|
-
console.error("PPTX 解析错误:",
|
|
443
|
+
} catch (m) {
|
|
444
|
+
console.error("PPTX 解析错误:", m), h && (c(m instanceof Error ? m.message : "PPT 文件解析失败"), n(!1));
|
|
444
445
|
}
|
|
445
|
-
},
|
|
446
|
-
|
|
446
|
+
}, x = setTimeout(() => {
|
|
447
|
+
l();
|
|
447
448
|
}, 100);
|
|
448
449
|
return () => {
|
|
449
|
-
if (
|
|
450
|
+
if (h = !1, clearTimeout(x), a.current = null, s.current)
|
|
450
451
|
try {
|
|
451
452
|
s.current.destroy();
|
|
452
|
-
} catch (
|
|
453
|
-
console.error("销毁预览器失败:",
|
|
453
|
+
} catch (m) {
|
|
454
|
+
console.error("销毁预览器失败:", m);
|
|
454
455
|
}
|
|
455
456
|
s.current = null;
|
|
456
457
|
};
|
|
457
|
-
}, [r,
|
|
458
|
-
t && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-2xl", children: /* @__PURE__ */
|
|
458
|
+
}, [r, u]), /* @__PURE__ */ f("div", { className: "relative flex flex-col items-center w-full h-full pt-[8px]", children: [
|
|
459
|
+
t && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-2xl", children: /* @__PURE__ */ f("div", { className: "text-center", children: [
|
|
459
460
|
/* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-3 border-4 border-white/20 border-t-white rounded-full animate-spin" }),
|
|
460
461
|
/* @__PURE__ */ e("p", { className: "text-sm text-white/70 font-medium", children: "加载 PPT 中..." })
|
|
461
462
|
] }) }),
|
|
462
|
-
i && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-2xl", children: /* @__PURE__ */
|
|
463
|
-
/* @__PURE__ */ e("div", { className: "w-32 h-32 mx-auto mb-6 rounded-3xl bg-gradient-to-br from-orange-500 via-red-500 to-pink-500 flex items-center justify-center shadow-2xl", children: /* @__PURE__ */ e(
|
|
463
|
+
i && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-2xl", children: /* @__PURE__ */ f("div", { className: "text-center max-w-md", children: [
|
|
464
|
+
/* @__PURE__ */ e("div", { className: "w-32 h-32 mx-auto mb-6 rounded-3xl bg-gradient-to-br from-orange-500 via-red-500 to-pink-500 flex items-center justify-center shadow-2xl", children: /* @__PURE__ */ e(Q, { className: "w-16 h-16 text-white" }) }),
|
|
464
465
|
/* @__PURE__ */ e("p", { className: "text-xl text-white/90 mb-3 font-medium", children: "PPT 预览" }),
|
|
465
466
|
/* @__PURE__ */ e("p", { className: "text-sm text-white/60 mb-6", children: i || "浏览器暂不支持直接预览 PPT 文件" }),
|
|
466
|
-
/* @__PURE__ */
|
|
467
|
+
/* @__PURE__ */ f(
|
|
467
468
|
"a",
|
|
468
469
|
{
|
|
469
470
|
href: r,
|
|
@@ -485,7 +486,7 @@ const Te = ({
|
|
|
485
486
|
}
|
|
486
487
|
)
|
|
487
488
|
] });
|
|
488
|
-
},
|
|
489
|
+
}, Fe = (r) => {
|
|
489
490
|
var i;
|
|
490
491
|
const t = ((i = r.split(".").pop()) == null ? void 0 : i.toLowerCase().split("?")[0]) || "";
|
|
491
492
|
return {
|
|
@@ -501,13 +502,13 @@ const Te = ({
|
|
|
501
502
|
"3gp": "video/3gpp",
|
|
502
503
|
flv: "video/x-flv"
|
|
503
504
|
}[t] || "video/mp4";
|
|
504
|
-
},
|
|
505
|
-
const [t, n] =
|
|
505
|
+
}, We = ({ url: r }) => {
|
|
506
|
+
const [t, n] = b(null), [i, c] = b(!0), d = S(null), s = S(null);
|
|
506
507
|
return M(() => {
|
|
507
508
|
if (!s.current && d.current) {
|
|
508
509
|
const o = document.createElement("video-js");
|
|
509
510
|
o.classList.add("vjs-big-play-centered", "vjs-theme-apple"), d.current.appendChild(o);
|
|
510
|
-
const a =
|
|
511
|
+
const a = Fe(r), p = ye(o, {
|
|
511
512
|
controls: !0,
|
|
512
513
|
responsive: !0,
|
|
513
514
|
fluid: !0,
|
|
@@ -541,24 +542,24 @@ const Te = ({
|
|
|
541
542
|
// 备用方案
|
|
542
543
|
] : [{ src: r, type: a }]
|
|
543
544
|
});
|
|
544
|
-
|
|
545
|
+
p.on("loadeddata", () => {
|
|
545
546
|
c(!1);
|
|
546
|
-
}),
|
|
547
|
-
const
|
|
548
|
-
console.error("Video.js error:",
|
|
549
|
-
}), s.current =
|
|
547
|
+
}), p.on("error", () => {
|
|
548
|
+
const u = p.error();
|
|
549
|
+
console.error("Video.js error:", u), n(`视频加载失败: ${(u == null ? void 0 : u.message) || "未知错误"}`), c(!1);
|
|
550
|
+
}), s.current = p;
|
|
550
551
|
}
|
|
551
552
|
}, [r]), M(() => {
|
|
552
553
|
const o = s.current;
|
|
553
554
|
return () => {
|
|
554
555
|
o && !o.isDisposed() && (o.dispose(), s.current = null);
|
|
555
556
|
};
|
|
556
|
-
}, []), t ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */
|
|
557
|
+
}, []), t ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ f("div", { className: "text-center", children: [
|
|
557
558
|
/* @__PURE__ */ e("div", { className: "w-16 h-16 mx-auto mb-4 rounded-full bg-red-500/10 flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-8 h-8 text-red-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }) }),
|
|
558
559
|
/* @__PURE__ */ e("p", { className: "text-lg font-medium text-white/90 mb-2", children: "视频加载失败" }),
|
|
559
560
|
/* @__PURE__ */ e("p", { className: "text-sm text-white/60", children: t })
|
|
560
|
-
] }) }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full p-8", children: /* @__PURE__ */
|
|
561
|
-
i && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/20 backdrop-blur-sm rounded-2xl z-10", children: /* @__PURE__ */
|
|
561
|
+
] }) }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full p-8", children: /* @__PURE__ */ f("div", { className: "w-full max-w-5xl relative", children: [
|
|
562
|
+
i && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/20 backdrop-blur-sm rounded-2xl z-10", children: /* @__PURE__ */ f("div", { className: "text-center", children: [
|
|
562
563
|
/* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-3 border-3 border-white/20 border-t-white rounded-full animate-spin" }),
|
|
563
564
|
/* @__PURE__ */ e("p", { className: "text-sm text-white/70 font-medium", children: "加载视频中..." })
|
|
564
565
|
] }) }),
|
|
@@ -573,48 +574,48 @@ const Te = ({
|
|
|
573
574
|
}
|
|
574
575
|
)
|
|
575
576
|
] }) });
|
|
576
|
-
},
|
|
577
|
-
const [n, i] =
|
|
577
|
+
}, $e = ({ url: r, fileName: t }) => {
|
|
578
|
+
const [n, i] = b(null), [c, d] = b(!1), [s, o] = b(0), [a, w] = b(0), [p, u] = b(1), [v, h] = b(!1), l = S(null);
|
|
578
579
|
M(() => {
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
580
|
+
const g = l.current;
|
|
581
|
+
if (!g) return;
|
|
581
582
|
const j = () => {
|
|
582
|
-
isNaN(
|
|
583
|
+
isNaN(g.currentTime) || o(g.currentTime);
|
|
583
584
|
}, N = () => {
|
|
584
|
-
!isNaN(
|
|
585
|
-
},
|
|
586
|
-
return
|
|
587
|
-
|
|
585
|
+
!isNaN(g.duration) && isFinite(g.duration) && w(g.duration);
|
|
586
|
+
}, D = () => d(!1), R = () => N();
|
|
587
|
+
return g.addEventListener("timeupdate", j), g.addEventListener("loadedmetadata", N), g.addEventListener("durationchange", N), g.addEventListener("canplay", R), g.addEventListener("ended", D), g.readyState >= 1 && N(), () => {
|
|
588
|
+
g.removeEventListener("timeupdate", j), g.removeEventListener("loadedmetadata", N), g.removeEventListener("durationchange", N), g.removeEventListener("canplay", R), g.removeEventListener("ended", D);
|
|
588
589
|
};
|
|
589
590
|
}, []);
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
},
|
|
593
|
-
const j = parseFloat(
|
|
594
|
-
o(j),
|
|
595
|
-
}, k = (
|
|
596
|
-
const j = parseFloat(
|
|
597
|
-
|
|
591
|
+
const x = () => {
|
|
592
|
+
l.current && (c ? l.current.pause() : l.current.play(), d(!c));
|
|
593
|
+
}, m = (g) => {
|
|
594
|
+
const j = parseFloat(g.target.value);
|
|
595
|
+
o(j), l.current && (l.current.currentTime = j);
|
|
596
|
+
}, k = (g) => {
|
|
597
|
+
const j = parseFloat(g.target.value);
|
|
598
|
+
u(j), l.current && (l.current.volume = j), j > 0 && h(!1);
|
|
598
599
|
}, T = () => {
|
|
599
|
-
|
|
600
|
-
}, L = (
|
|
601
|
-
|
|
602
|
-
}, P = (
|
|
603
|
-
if (!isFinite(
|
|
604
|
-
const j = Math.floor(
|
|
600
|
+
l.current && (l.current.muted = !v, h(!v));
|
|
601
|
+
}, L = (g) => {
|
|
602
|
+
l.current && (l.current.currentTime += g);
|
|
603
|
+
}, P = (g) => {
|
|
604
|
+
if (!isFinite(g) || isNaN(g) || g < 0) return "0:00";
|
|
605
|
+
const j = Math.floor(g / 60), N = Math.floor(g % 60);
|
|
605
606
|
return `${j}:${N.toString().padStart(2, "0")}`;
|
|
606
607
|
}, z = () => {
|
|
607
608
|
i("音频加载失败");
|
|
608
609
|
};
|
|
609
|
-
return n ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: n }) }) }) : /* @__PURE__ */
|
|
610
|
-
/* @__PURE__ */ e("div", { className: "w-64 h-64 rounded-3xl bg-gradient-to-br from-purple-500 via-pink-500 to-rose-500 flex items-center justify-center shadow-2xl backdrop-blur-xl", children: /* @__PURE__ */ e(
|
|
611
|
-
/* @__PURE__ */
|
|
610
|
+
return n ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: n }) }) }) : /* @__PURE__ */ f("div", { className: "flex flex-col items-center justify-center w-full h-full p-8 gap-8", children: [
|
|
611
|
+
/* @__PURE__ */ e("div", { className: "w-64 h-64 rounded-3xl bg-gradient-to-br from-purple-500 via-pink-500 to-rose-500 flex items-center justify-center shadow-2xl backdrop-blur-xl", children: /* @__PURE__ */ e(J, { className: "w-32 h-32 text-white" }) }),
|
|
612
|
+
/* @__PURE__ */ f("div", { className: "text-white text-center max-w-md", children: [
|
|
612
613
|
/* @__PURE__ */ e("p", { className: "text-2xl font-medium mb-1", children: t }),
|
|
613
614
|
/* @__PURE__ */ e("p", { className: "text-sm text-white/60", children: "音频文件" })
|
|
614
615
|
] }),
|
|
615
|
-
/* @__PURE__ */
|
|
616
|
-
/* @__PURE__ */
|
|
617
|
-
/* @__PURE__ */
|
|
616
|
+
/* @__PURE__ */ f("div", { className: "w-full max-w-md bg-white/10 backdrop-blur-xl rounded-2xl p-6 border border-white/20", children: [
|
|
617
|
+
/* @__PURE__ */ f("div", { className: "mb-4", children: [
|
|
618
|
+
/* @__PURE__ */ f("div", { className: "relative h-4 flex items-center", children: [
|
|
618
619
|
/* @__PURE__ */ e("div", { className: "absolute w-full h-[6px] bg-white/20 rounded-full" }),
|
|
619
620
|
/* @__PURE__ */ e(
|
|
620
621
|
"div",
|
|
@@ -632,31 +633,31 @@ const Te = ({
|
|
|
632
633
|
min: "0",
|
|
633
634
|
max: a > 0 ? a : 100 + (s > 100 ? s % 100 : 0),
|
|
634
635
|
value: s,
|
|
635
|
-
onChange:
|
|
636
|
+
onChange: m,
|
|
636
637
|
className: "audio-slider absolute w-full"
|
|
637
638
|
}
|
|
638
639
|
)
|
|
639
640
|
] }),
|
|
640
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ f("div", { className: "flex justify-between text-xs text-white/60 mt-3", children: [
|
|
641
642
|
/* @__PURE__ */ e("span", { children: P(s) }),
|
|
642
643
|
/* @__PURE__ */ e("span", { children: P(a) })
|
|
643
644
|
] })
|
|
644
645
|
] }),
|
|
645
|
-
/* @__PURE__ */
|
|
646
|
+
/* @__PURE__ */ f("div", { className: "flex items-center justify-center gap-4 mb-4", children: [
|
|
646
647
|
/* @__PURE__ */ e(
|
|
647
648
|
"button",
|
|
648
649
|
{
|
|
649
650
|
onClick: () => L(-10),
|
|
650
651
|
className: "w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center text-white transition-all",
|
|
651
|
-
children: /* @__PURE__ */ e(
|
|
652
|
+
children: /* @__PURE__ */ e(ee, { className: "w-5 h-5" })
|
|
652
653
|
}
|
|
653
654
|
),
|
|
654
655
|
/* @__PURE__ */ e(
|
|
655
656
|
"button",
|
|
656
657
|
{
|
|
657
|
-
onClick:
|
|
658
|
+
onClick: x,
|
|
658
659
|
className: "w-14 h-14 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 hover:scale-105 flex items-center justify-center text-white transition-all shadow-lg",
|
|
659
|
-
children: c ? /* @__PURE__ */ e(
|
|
660
|
+
children: c ? /* @__PURE__ */ e(te, { className: "w-6 h-6" }) : /* @__PURE__ */ e(re, { className: "w-6 h-6 ml-1" })
|
|
660
661
|
}
|
|
661
662
|
),
|
|
662
663
|
/* @__PURE__ */ e(
|
|
@@ -664,27 +665,27 @@ const Te = ({
|
|
|
664
665
|
{
|
|
665
666
|
onClick: () => L(10),
|
|
666
667
|
className: "w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center text-white transition-all",
|
|
667
|
-
children: /* @__PURE__ */ e(
|
|
668
|
+
children: /* @__PURE__ */ e(oe, { className: "w-5 h-5" })
|
|
668
669
|
}
|
|
669
670
|
)
|
|
670
671
|
] }),
|
|
671
|
-
/* @__PURE__ */
|
|
672
|
+
/* @__PURE__ */ f("div", { className: "flex items-center gap-3", children: [
|
|
672
673
|
/* @__PURE__ */ e(
|
|
673
674
|
"button",
|
|
674
675
|
{
|
|
675
676
|
onClick: T,
|
|
676
677
|
className: "text-white/80 hover:text-white transition-colors",
|
|
677
|
-
children: v ||
|
|
678
|
+
children: v || p === 0 ? /* @__PURE__ */ e(ne, { className: "w-5 h-5" }) : /* @__PURE__ */ e(le, { className: "w-5 h-5" })
|
|
678
679
|
}
|
|
679
680
|
),
|
|
680
|
-
/* @__PURE__ */
|
|
681
|
+
/* @__PURE__ */ f("div", { className: "flex-1 relative h-3 flex items-center", children: [
|
|
681
682
|
/* @__PURE__ */ e("div", { className: "absolute w-full h-[4px] bg-white/20 rounded-full" }),
|
|
682
683
|
/* @__PURE__ */ e(
|
|
683
684
|
"div",
|
|
684
685
|
{
|
|
685
686
|
className: "absolute h-[4px] bg-purple-500 rounded-full transition-all duration-100 pointer-events-none",
|
|
686
687
|
style: {
|
|
687
|
-
width: `${(v ? 0 :
|
|
688
|
+
width: `${(v ? 0 : p) * 100}%`
|
|
688
689
|
}
|
|
689
690
|
}
|
|
690
691
|
),
|
|
@@ -695,7 +696,7 @@ const Te = ({
|
|
|
695
696
|
min: "0",
|
|
696
697
|
max: "1",
|
|
697
698
|
step: "0.01",
|
|
698
|
-
value: v ? 0 :
|
|
699
|
+
value: v ? 0 : p,
|
|
699
700
|
onChange: k,
|
|
700
701
|
className: "volume-slider absolute w-full"
|
|
701
702
|
}
|
|
@@ -706,14 +707,14 @@ const Te = ({
|
|
|
706
707
|
/* @__PURE__ */ e(
|
|
707
708
|
"audio",
|
|
708
709
|
{
|
|
709
|
-
ref:
|
|
710
|
+
ref: l,
|
|
710
711
|
src: r,
|
|
711
712
|
onError: z,
|
|
712
713
|
className: "hidden"
|
|
713
714
|
}
|
|
714
715
|
)
|
|
715
716
|
] });
|
|
716
|
-
},
|
|
717
|
+
}, G = {
|
|
717
718
|
'pre[class*="language-"]': {
|
|
718
719
|
color: "#d4d4d4",
|
|
719
720
|
fontSize: "13px",
|
|
@@ -994,8 +995,8 @@ const Te = ({
|
|
|
994
995
|
boxShadow: "inset 5px 0 0 #f7d87c",
|
|
995
996
|
zIndex: "0"
|
|
996
997
|
}
|
|
997
|
-
},
|
|
998
|
-
const [t, n] =
|
|
998
|
+
}, Be = ({ url: r }) => {
|
|
999
|
+
const [t, n] = b(""), [i, c] = b(!0), [d, s] = b(null);
|
|
999
1000
|
return M(() => {
|
|
1000
1001
|
(async () => {
|
|
1001
1002
|
try {
|
|
@@ -1003,8 +1004,8 @@ const Te = ({
|
|
|
1003
1004
|
const a = await fetch(r);
|
|
1004
1005
|
if (!a.ok)
|
|
1005
1006
|
throw new Error("加载失败");
|
|
1006
|
-
const
|
|
1007
|
-
n(
|
|
1007
|
+
const w = await a.text();
|
|
1008
|
+
n(w);
|
|
1008
1009
|
} catch (a) {
|
|
1009
1010
|
s("Markdown 文件加载失败"), console.error(a);
|
|
1010
1011
|
} finally {
|
|
@@ -1012,23 +1013,23 @@ const Te = ({
|
|
|
1012
1013
|
}
|
|
1013
1014
|
})();
|
|
1014
1015
|
}, [r]), i ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin" }) }) : d ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: d }) }) }) : /* @__PURE__ */ e("div", { className: "w-full h-full overflow-auto p-8", children: /* @__PURE__ */ e("div", { className: "max-w-4xl mx-auto bg-white/5 backdrop-blur-sm rounded-2xl p-8 border border-white/10", children: /* @__PURE__ */ e("div", { className: "prose prose-invert prose-lg max-w-none", children: /* @__PURE__ */ e(
|
|
1015
|
-
|
|
1016
|
+
Ne,
|
|
1016
1017
|
{
|
|
1017
|
-
remarkPlugins: [
|
|
1018
|
+
remarkPlugins: [ke],
|
|
1018
1019
|
components: {
|
|
1019
|
-
code({ node: o, inline: a, className:
|
|
1020
|
-
const v = /language-(\w+)/.exec(
|
|
1020
|
+
code({ node: o, inline: a, className: w, children: p, ...u }) {
|
|
1021
|
+
const v = /language-(\w+)/.exec(w || "");
|
|
1021
1022
|
return !a && v ? /* @__PURE__ */ e(
|
|
1022
|
-
|
|
1023
|
+
_,
|
|
1023
1024
|
{
|
|
1024
|
-
style:
|
|
1025
|
+
style: G,
|
|
1025
1026
|
language: v[1],
|
|
1026
1027
|
PreTag: "div",
|
|
1027
1028
|
className: "rounded-lg",
|
|
1028
|
-
...
|
|
1029
|
-
children: String(
|
|
1029
|
+
...u,
|
|
1030
|
+
children: String(p).replace(/\n$/, "")
|
|
1030
1031
|
}
|
|
1031
|
-
) : /* @__PURE__ */ e("code", { className: "bg-white/10 px-1.5 py-0.5 rounded text-sm", ...
|
|
1032
|
+
) : /* @__PURE__ */ e("code", { className: "bg-white/10 px-1.5 py-0.5 rounded text-sm", ...u, children: p });
|
|
1032
1033
|
},
|
|
1033
1034
|
h1: ({ children: o }) => /* @__PURE__ */ e("h1", { className: "text-4xl font-bold mb-4 text-white border-b border-white/20 pb-2", children: o }),
|
|
1034
1035
|
h2: ({ children: o }) => /* @__PURE__ */ e("h2", { className: "text-3xl font-bold mb-3 text-white mt-8", children: o }),
|
|
@@ -1057,7 +1058,7 @@ const Te = ({
|
|
|
1057
1058
|
children: t
|
|
1058
1059
|
}
|
|
1059
1060
|
) }) }) });
|
|
1060
|
-
},
|
|
1061
|
+
}, He = (r) => {
|
|
1061
1062
|
var i;
|
|
1062
1063
|
const t = ((i = r.split(".").pop()) == null ? void 0 : i.toLowerCase()) || "";
|
|
1063
1064
|
return {
|
|
@@ -1096,34 +1097,34 @@ const Te = ({
|
|
|
1096
1097
|
md: "markdown",
|
|
1097
1098
|
txt: "text"
|
|
1098
1099
|
}[t] || "text";
|
|
1099
|
-
},
|
|
1100
|
-
const [n, i] =
|
|
1100
|
+
}, Ae = ({ url: r, fileName: t }) => {
|
|
1101
|
+
const [n, i] = b(""), [c, d] = b(!0), [s, o] = b(null), a = He(t);
|
|
1101
1102
|
return M(() => {
|
|
1102
1103
|
(async () => {
|
|
1103
1104
|
try {
|
|
1104
1105
|
d(!0), o(null);
|
|
1105
|
-
const
|
|
1106
|
-
if (!
|
|
1106
|
+
const p = await fetch(r);
|
|
1107
|
+
if (!p.ok)
|
|
1107
1108
|
throw new Error("加载失败");
|
|
1108
|
-
const
|
|
1109
|
-
i(
|
|
1110
|
-
} catch (
|
|
1111
|
-
o("文本文件加载失败"), console.error(
|
|
1109
|
+
const u = await p.text();
|
|
1110
|
+
i(u);
|
|
1111
|
+
} catch (p) {
|
|
1112
|
+
o("文本文件加载失败"), console.error(p);
|
|
1112
1113
|
} finally {
|
|
1113
1114
|
d(!1);
|
|
1114
1115
|
}
|
|
1115
1116
|
})();
|
|
1116
|
-
}, [r]), c ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin" }) }) : s ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: s }) }) }) : /* @__PURE__ */ e("div", { className: "w-full h-full overflow-auto p-8", children: /* @__PURE__ */
|
|
1117
|
-
/* @__PURE__ */
|
|
1118
|
-
/* @__PURE__ */ e(
|
|
1117
|
+
}, [r]), c ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin" }) }) : s ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: s }) }) }) : /* @__PURE__ */ e("div", { className: "w-full h-full overflow-auto p-8", children: /* @__PURE__ */ f("div", { className: "max-w-6xl mx-auto bg-white/5 backdrop-blur-sm rounded-2xl border border-white/10 overflow-hidden", children: [
|
|
1118
|
+
/* @__PURE__ */ f("div", { className: "flex items-center gap-3 px-6 py-4 bg-white/5 border-b border-white/10", children: [
|
|
1119
|
+
/* @__PURE__ */ e(ae, { className: "w-5 h-5 text-white/70" }),
|
|
1119
1120
|
/* @__PURE__ */ e("span", { className: "text-white font-medium", children: t }),
|
|
1120
1121
|
/* @__PURE__ */ e("span", { className: "ml-auto text-xs text-white/50 uppercase", children: a })
|
|
1121
1122
|
] }),
|
|
1122
1123
|
/* @__PURE__ */ e("div", { className: "text-sm", children: a === "text" ? /* @__PURE__ */ e("pre", { className: "p-6 text-white/90 font-mono whitespace-pre-wrap break-words", children: n }) : /* @__PURE__ */ e(
|
|
1123
|
-
|
|
1124
|
+
_,
|
|
1124
1125
|
{
|
|
1125
1126
|
language: a,
|
|
1126
|
-
style:
|
|
1127
|
+
style: G,
|
|
1127
1128
|
showLineNumbers: !0,
|
|
1128
1129
|
customStyle: {
|
|
1129
1130
|
margin: 0,
|
|
@@ -1141,32 +1142,32 @@ const Te = ({
|
|
|
1141
1142
|
}
|
|
1142
1143
|
) })
|
|
1143
1144
|
] }) });
|
|
1144
|
-
},
|
|
1145
|
+
}, Oe = ({
|
|
1145
1146
|
fileName: r,
|
|
1146
1147
|
fileType: t,
|
|
1147
1148
|
onDownload: n
|
|
1148
|
-
}) => /* @__PURE__ */
|
|
1149
|
-
/* @__PURE__ */ e("div", { className: "w-32 h-32 rounded-full bg-white/10 flex items-center justify-center", children: /* @__PURE__ */ e(
|
|
1150
|
-
/* @__PURE__ */
|
|
1149
|
+
}) => /* @__PURE__ */ f("div", { className: "flex flex-col items-center justify-center w-full h-full p-8 gap-6", children: [
|
|
1150
|
+
/* @__PURE__ */ e("div", { className: "w-32 h-32 rounded-full bg-white/10 flex items-center justify-center", children: /* @__PURE__ */ e(se, { className: "w-16 h-16 text-white/70" }) }),
|
|
1151
|
+
/* @__PURE__ */ f("div", { className: "text-white text-center", children: [
|
|
1151
1152
|
/* @__PURE__ */ e("p", { className: "text-xl font-medium mb-2", children: r }),
|
|
1152
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ f("p", { className: "text-white/70", children: [
|
|
1153
1154
|
"不支持预览此文件类型 (",
|
|
1154
1155
|
t,
|
|
1155
1156
|
")"
|
|
1156
1157
|
] })
|
|
1157
1158
|
] }),
|
|
1158
|
-
/* @__PURE__ */
|
|
1159
|
+
/* @__PURE__ */ f(
|
|
1159
1160
|
"button",
|
|
1160
1161
|
{
|
|
1161
1162
|
onClick: n,
|
|
1162
1163
|
className: "flex items-center gap-2 px-6 py-3 bg-white/10 hover:bg-white/20 backdrop-blur-sm rounded-lg text-white font-medium transition-all",
|
|
1163
1164
|
children: [
|
|
1164
|
-
/* @__PURE__ */ e(
|
|
1165
|
+
/* @__PURE__ */ e(Z, { className: "w-5 h-5" }),
|
|
1165
1166
|
"下载文件查看"
|
|
1166
1167
|
]
|
|
1167
1168
|
}
|
|
1168
1169
|
)
|
|
1169
|
-
] }),
|
|
1170
|
+
] }), Ue = (r) => {
|
|
1170
1171
|
var c;
|
|
1171
1172
|
const t = ((c = r.name.split(".").pop()) == null ? void 0 : c.toLowerCase()) || "", n = r.type.toLowerCase();
|
|
1172
1173
|
if (n.startsWith("image/") || ["jpg", "jpeg", "png", "gif", "webp", "svg"].includes(t))
|
|
@@ -1223,170 +1224,170 @@ const Te = ({
|
|
|
1223
1224
|
"sql"
|
|
1224
1225
|
];
|
|
1225
1226
|
return n.startsWith("text/") || i.includes(t) ? "text" : "unsupported";
|
|
1226
|
-
},
|
|
1227
|
+
}, tt = ({
|
|
1227
1228
|
files: r,
|
|
1228
1229
|
currentIndex: t,
|
|
1229
1230
|
isOpen: n,
|
|
1230
1231
|
onClose: i,
|
|
1231
|
-
onNavigate: c
|
|
1232
|
+
onNavigate: c,
|
|
1233
|
+
customRenderers: d = []
|
|
1232
1234
|
}) => {
|
|
1233
|
-
const [
|
|
1235
|
+
const [s, o] = b(1), [a, w] = b(0), [p, u] = b(1), [, v] = b(1), h = U(() => Me(r), [r]), l = h[t], x = U(() => l ? d.find((y) => y.test(l)) : null, [l, d]), m = l ? Ue(l) : "unsupported";
|
|
1234
1236
|
M(() => {
|
|
1235
|
-
|
|
1237
|
+
o(1), w(0), u(1), v(1);
|
|
1236
1238
|
}, [t]), M(() => {
|
|
1237
1239
|
if (n) {
|
|
1238
|
-
const
|
|
1239
|
-
return document.body.style.overflow = "hidden",
|
|
1240
|
-
document.body.style.overflow =
|
|
1240
|
+
const y = document.body.style.overflow, W = document.body.style.paddingRight, O = window.innerWidth - document.documentElement.clientWidth;
|
|
1241
|
+
return document.body.style.overflow = "hidden", O > 0 && (document.body.style.paddingRight = `${O}px`), () => {
|
|
1242
|
+
document.body.style.overflow = y, document.body.style.paddingRight = W;
|
|
1241
1243
|
};
|
|
1242
1244
|
}
|
|
1243
1245
|
}, [n]), M(() => {
|
|
1244
1246
|
if (!n) return;
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1247
|
+
const y = (W) => {
|
|
1248
|
+
W.key === "Escape" ? i() : W.key === "ArrowLeft" && t > 0 ? c == null || c(t - 1) : W.key === "ArrowRight" && t < h.length - 1 && (c == null || c(t + 1));
|
|
1247
1249
|
};
|
|
1248
|
-
return window.addEventListener("keydown",
|
|
1249
|
-
}, [n, t,
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
}, []), y = C(() => {
|
|
1253
|
-
s((b) => Math.max(b - 0.25, 0.5));
|
|
1254
|
-
}, []), k = C(() => {
|
|
1255
|
-
a((b) => b + 90);
|
|
1250
|
+
return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
|
|
1251
|
+
}, [n, t, h.length, i, c]);
|
|
1252
|
+
const k = C(() => {
|
|
1253
|
+
o((y) => Math.min(y + 0.25, 5));
|
|
1256
1254
|
}, []), T = C(() => {
|
|
1257
|
-
|
|
1255
|
+
o((y) => Math.max(y - 0.25, 0.5));
|
|
1258
1256
|
}, []), L = C(() => {
|
|
1259
|
-
|
|
1257
|
+
w((y) => y + 90);
|
|
1260
1258
|
}, []), P = C(() => {
|
|
1261
|
-
|
|
1262
|
-
}, []), z = C((
|
|
1263
|
-
|
|
1264
|
-
}, []),
|
|
1265
|
-
|
|
1266
|
-
}, []), j = C(() => {
|
|
1259
|
+
w((y) => y - 90);
|
|
1260
|
+
}, []), z = C(() => {
|
|
1261
|
+
o(1), w(0);
|
|
1262
|
+
}, []), g = C(() => {
|
|
1263
|
+
o(1);
|
|
1264
|
+
}, []), j = C((y) => {
|
|
1265
|
+
o(y);
|
|
1266
|
+
}, []), N = C(() => {
|
|
1267
|
+
o(1), w(0);
|
|
1268
|
+
}, []), D = C(() => {
|
|
1267
1269
|
if (!l) return;
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1270
|
+
const y = document.createElement("a");
|
|
1271
|
+
y.href = l.url, y.download = l.name, y.click();
|
|
1270
1272
|
}, [l]);
|
|
1271
1273
|
if (!n || !l) return null;
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
F.div,
|
|
1274
|
+
const R = m === "image" || m === "pdf", F = m === "image", I = /* @__PURE__ */ e(K, { children: n && /* @__PURE__ */ e(
|
|
1275
|
+
B.div,
|
|
1275
1276
|
{
|
|
1276
1277
|
initial: { opacity: 0 },
|
|
1277
1278
|
animate: { opacity: 1 },
|
|
1278
1279
|
exit: { opacity: 0 },
|
|
1279
|
-
className: "fixed inset-0 z-
|
|
1280
|
+
className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-md overflow-hidden",
|
|
1280
1281
|
onClick: i,
|
|
1281
|
-
onWheel: (
|
|
1282
|
-
children: /* @__PURE__ */
|
|
1282
|
+
onWheel: (y) => y.stopPropagation(),
|
|
1283
|
+
children: /* @__PURE__ */ f(
|
|
1283
1284
|
"div",
|
|
1284
1285
|
{
|
|
1285
1286
|
className: "relative w-full h-full flex flex-col overflow-hidden",
|
|
1286
|
-
onClick: (
|
|
1287
|
+
onClick: (y) => y.stopPropagation(),
|
|
1287
1288
|
children: [
|
|
1288
1289
|
/* @__PURE__ */ e(
|
|
1289
|
-
|
|
1290
|
+
B.div,
|
|
1290
1291
|
{
|
|
1291
1292
|
initial: { y: -100 },
|
|
1292
1293
|
animate: { y: 0 },
|
|
1293
1294
|
exit: { y: -100 },
|
|
1294
1295
|
className: "absolute top-0 left-0 right-0 z-10 p-4",
|
|
1295
|
-
children: /* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
1296
|
+
children: /* @__PURE__ */ f("div", { className: "max-w-7xl mx-auto flex items-center justify-between bg-black/40 backdrop-blur-xl rounded-2xl px-6 py-4 shadow-2xl border border-white/10", children: [
|
|
1297
|
+
/* @__PURE__ */ f("div", { className: "flex-1 min-w-0", children: [
|
|
1297
1298
|
/* @__PURE__ */ e("h2", { className: "text-white font-medium text-lg truncate", children: l.name }),
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
+
/* @__PURE__ */ f("p", { className: "text-white/60 text-sm", children: [
|
|
1299
1300
|
t + 1,
|
|
1300
1301
|
" / ",
|
|
1301
|
-
|
|
1302
|
+
h.length
|
|
1302
1303
|
] })
|
|
1303
1304
|
] }),
|
|
1304
|
-
/* @__PURE__ */
|
|
1305
|
-
|
|
1305
|
+
/* @__PURE__ */ f("div", { className: "flex items-center gap-2 ml-4", children: [
|
|
1306
|
+
R && /* @__PURE__ */ f($, { children: [
|
|
1306
1307
|
/* @__PURE__ */ e(
|
|
1307
|
-
|
|
1308
|
+
E,
|
|
1308
1309
|
{
|
|
1309
|
-
icon: /* @__PURE__ */ e(
|
|
1310
|
+
icon: /* @__PURE__ */ e(ie, { className: "w-5 h-5" }),
|
|
1310
1311
|
label: "缩小",
|
|
1311
|
-
onClick:
|
|
1312
|
-
disabled:
|
|
1312
|
+
onClick: T,
|
|
1313
|
+
disabled: s <= 0.5
|
|
1313
1314
|
}
|
|
1314
1315
|
),
|
|
1315
|
-
/* @__PURE__ */
|
|
1316
|
-
Math.round(
|
|
1316
|
+
/* @__PURE__ */ f("span", { className: "text-white/70 text-sm min-w-[4rem] text-center font-medium", children: [
|
|
1317
|
+
Math.round(s * 100),
|
|
1317
1318
|
"%"
|
|
1318
1319
|
] }),
|
|
1319
1320
|
/* @__PURE__ */ e(
|
|
1320
|
-
|
|
1321
|
+
E,
|
|
1321
1322
|
{
|
|
1322
|
-
icon: /* @__PURE__ */ e(
|
|
1323
|
+
icon: /* @__PURE__ */ e(ce, { className: "w-5 h-5" }),
|
|
1323
1324
|
label: "放大",
|
|
1324
|
-
onClick:
|
|
1325
|
-
disabled:
|
|
1325
|
+
onClick: k,
|
|
1326
|
+
disabled: s >= 5
|
|
1326
1327
|
}
|
|
1327
1328
|
),
|
|
1328
1329
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" }),
|
|
1329
1330
|
/* @__PURE__ */ e(
|
|
1330
|
-
|
|
1331
|
+
E,
|
|
1331
1332
|
{
|
|
1332
|
-
icon: /* @__PURE__ */ e(
|
|
1333
|
+
icon: /* @__PURE__ */ e(de, { className: "w-5 h-5" }),
|
|
1333
1334
|
label: "适应窗口",
|
|
1334
|
-
onClick:
|
|
1335
|
+
onClick: z
|
|
1335
1336
|
}
|
|
1336
1337
|
),
|
|
1337
1338
|
/* @__PURE__ */ e(
|
|
1338
|
-
|
|
1339
|
+
E,
|
|
1339
1340
|
{
|
|
1340
|
-
icon: /* @__PURE__ */ e(
|
|
1341
|
+
icon: /* @__PURE__ */ e(me, { className: "w-5 h-5" }),
|
|
1341
1342
|
label: "原始尺寸",
|
|
1342
|
-
onClick:
|
|
1343
|
+
onClick: g
|
|
1343
1344
|
}
|
|
1344
1345
|
),
|
|
1345
1346
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" })
|
|
1346
1347
|
] }),
|
|
1347
|
-
|
|
1348
|
+
F && /* @__PURE__ */ f($, { children: [
|
|
1348
1349
|
/* @__PURE__ */ e(
|
|
1349
|
-
|
|
1350
|
+
E,
|
|
1350
1351
|
{
|
|
1351
|
-
icon: /* @__PURE__ */ e(
|
|
1352
|
+
icon: /* @__PURE__ */ e(ue, { className: "w-5 h-5" }),
|
|
1352
1353
|
label: "向左旋转",
|
|
1353
|
-
onClick:
|
|
1354
|
+
onClick: P
|
|
1354
1355
|
}
|
|
1355
1356
|
),
|
|
1356
1357
|
/* @__PURE__ */ e(
|
|
1357
|
-
|
|
1358
|
+
E,
|
|
1358
1359
|
{
|
|
1359
|
-
icon: /* @__PURE__ */ e(
|
|
1360
|
+
icon: /* @__PURE__ */ e(he, { className: "w-5 h-5" }),
|
|
1360
1361
|
label: "向右旋转",
|
|
1361
|
-
onClick:
|
|
1362
|
+
onClick: L
|
|
1362
1363
|
}
|
|
1363
1364
|
),
|
|
1364
1365
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" })
|
|
1365
1366
|
] }),
|
|
1366
|
-
(
|
|
1367
|
+
(R || F) && /* @__PURE__ */ f($, { children: [
|
|
1367
1368
|
/* @__PURE__ */ e(
|
|
1368
|
-
|
|
1369
|
+
E,
|
|
1369
1370
|
{
|
|
1370
|
-
icon: /* @__PURE__ */ e(
|
|
1371
|
+
icon: /* @__PURE__ */ e(pe, { className: "w-5 h-5" }),
|
|
1371
1372
|
label: "复原",
|
|
1372
|
-
onClick:
|
|
1373
|
+
onClick: N
|
|
1373
1374
|
}
|
|
1374
1375
|
),
|
|
1375
1376
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" })
|
|
1376
1377
|
] }),
|
|
1377
1378
|
/* @__PURE__ */ e(
|
|
1378
|
-
|
|
1379
|
+
E,
|
|
1379
1380
|
{
|
|
1380
|
-
icon: /* @__PURE__ */ e(
|
|
1381
|
+
icon: /* @__PURE__ */ e(Z, { className: "w-5 h-5" }),
|
|
1381
1382
|
label: "下载",
|
|
1382
|
-
onClick:
|
|
1383
|
+
onClick: D
|
|
1383
1384
|
}
|
|
1384
1385
|
),
|
|
1385
1386
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" }),
|
|
1386
1387
|
/* @__PURE__ */ e(
|
|
1387
|
-
|
|
1388
|
+
E,
|
|
1388
1389
|
{
|
|
1389
|
-
icon: /* @__PURE__ */ e(
|
|
1390
|
+
icon: /* @__PURE__ */ e(fe, { className: "w-5 h-5" }),
|
|
1390
1391
|
label: "关闭",
|
|
1391
1392
|
onClick: i
|
|
1392
1393
|
}
|
|
@@ -1395,63 +1396,66 @@ const Te = ({
|
|
|
1395
1396
|
] })
|
|
1396
1397
|
}
|
|
1397
1398
|
),
|
|
1398
|
-
/* @__PURE__ */
|
|
1399
|
+
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center justify-center pt-24 pb-8 overflow-auto", children: x ? (
|
|
1400
|
+
// 使用自定义渲染器
|
|
1401
|
+
x.render(l)
|
|
1402
|
+
) : /* @__PURE__ */ f($, { children: [
|
|
1399
1403
|
m === "image" && /* @__PURE__ */ e(
|
|
1400
|
-
|
|
1404
|
+
Te,
|
|
1401
1405
|
{
|
|
1402
1406
|
url: l.url,
|
|
1403
|
-
zoom:
|
|
1404
|
-
rotation:
|
|
1405
|
-
onZoomChange:
|
|
1407
|
+
zoom: s,
|
|
1408
|
+
rotation: a,
|
|
1409
|
+
onZoomChange: j
|
|
1406
1410
|
}
|
|
1407
1411
|
),
|
|
1408
1412
|
m === "pdf" && /* @__PURE__ */ e(
|
|
1409
|
-
|
|
1413
|
+
Re,
|
|
1410
1414
|
{
|
|
1411
1415
|
url: l.url,
|
|
1412
|
-
zoom:
|
|
1413
|
-
currentPage:
|
|
1416
|
+
zoom: s,
|
|
1417
|
+
currentPage: p,
|
|
1414
1418
|
onPageChange: u,
|
|
1415
|
-
onTotalPagesChange:
|
|
1419
|
+
onTotalPagesChange: v
|
|
1416
1420
|
}
|
|
1417
1421
|
),
|
|
1418
|
-
m === "docx" && /* @__PURE__ */ e(
|
|
1419
|
-
m === "xlsx" && /* @__PURE__ */ e(
|
|
1420
|
-
m === "pptx" && /* @__PURE__ */ e(
|
|
1421
|
-
m === "video" && /* @__PURE__ */ e(
|
|
1422
|
-
m === "audio" && /* @__PURE__ */ e(
|
|
1423
|
-
m === "markdown" && /* @__PURE__ */ e(
|
|
1424
|
-
m === "text" && /* @__PURE__ */ e(
|
|
1422
|
+
m === "docx" && /* @__PURE__ */ e(De, { url: l.url }),
|
|
1423
|
+
m === "xlsx" && /* @__PURE__ */ e(Ee, { url: l.url }),
|
|
1424
|
+
m === "pptx" && /* @__PURE__ */ e(ze, { url: l.url }),
|
|
1425
|
+
m === "video" && /* @__PURE__ */ e(We, { url: l.url }),
|
|
1426
|
+
m === "audio" && /* @__PURE__ */ e($e, { url: l.url, fileName: l.name }),
|
|
1427
|
+
m === "markdown" && /* @__PURE__ */ e(Be, { url: l.url }),
|
|
1428
|
+
m === "text" && /* @__PURE__ */ e(Ae, { url: l.url, fileName: l.name }),
|
|
1425
1429
|
m === "unsupported" && /* @__PURE__ */ e(
|
|
1426
|
-
|
|
1430
|
+
Oe,
|
|
1427
1431
|
{
|
|
1428
1432
|
fileName: l.name,
|
|
1429
1433
|
fileType: l.type,
|
|
1430
|
-
onDownload:
|
|
1434
|
+
onDownload: D
|
|
1431
1435
|
}
|
|
1432
1436
|
)
|
|
1433
|
-
] }),
|
|
1434
|
-
|
|
1437
|
+
] }) }),
|
|
1438
|
+
h.length > 1 && /* @__PURE__ */ f($, { children: [
|
|
1435
1439
|
t > 0 && /* @__PURE__ */ e(
|
|
1436
|
-
|
|
1440
|
+
B.button,
|
|
1437
1441
|
{
|
|
1438
1442
|
initial: { x: -100, opacity: 0 },
|
|
1439
1443
|
animate: { x: 0, opacity: 1 },
|
|
1440
1444
|
exit: { x: -100, opacity: 0 },
|
|
1441
1445
|
onClick: () => c == null ? void 0 : c(t - 1),
|
|
1442
1446
|
className: "absolute left-4 top-1/2 -translate-y-1/2 w-12 h-12 rounded-full bg-black/40 backdrop-blur-xl border border-white/10 flex items-center justify-center text-white hover:bg-black/60 transition-all shadow-2xl",
|
|
1443
|
-
children: /* @__PURE__ */ e(
|
|
1447
|
+
children: /* @__PURE__ */ e(xe, { className: "w-6 h-6" })
|
|
1444
1448
|
}
|
|
1445
1449
|
),
|
|
1446
|
-
t <
|
|
1447
|
-
|
|
1450
|
+
t < h.length - 1 && /* @__PURE__ */ e(
|
|
1451
|
+
B.button,
|
|
1448
1452
|
{
|
|
1449
1453
|
initial: { x: 100, opacity: 0 },
|
|
1450
1454
|
animate: { x: 0, opacity: 1 },
|
|
1451
1455
|
exit: { x: 100, opacity: 0 },
|
|
1452
1456
|
onClick: () => c == null ? void 0 : c(t + 1),
|
|
1453
1457
|
className: "absolute right-4 top-1/2 -translate-y-1/2 w-12 h-12 rounded-full bg-black/40 backdrop-blur-xl border border-white/10 flex items-center justify-center text-white hover:bg-black/60 transition-all shadow-2xl",
|
|
1454
|
-
children: /* @__PURE__ */ e(
|
|
1458
|
+
children: /* @__PURE__ */ e(we, { className: "w-6 h-6" })
|
|
1455
1459
|
}
|
|
1456
1460
|
)
|
|
1457
1461
|
] })
|
|
@@ -1460,7 +1464,8 @@ const Te = ({
|
|
|
1460
1464
|
)
|
|
1461
1465
|
}
|
|
1462
1466
|
) });
|
|
1463
|
-
|
|
1467
|
+
return Y(I, document.body);
|
|
1468
|
+
}, E = ({ icon: r, label: t, onClick: n, disabled: i }) => /* @__PURE__ */ e(
|
|
1464
1469
|
"button",
|
|
1465
1470
|
{
|
|
1466
1471
|
onClick: n,
|
|
@@ -1471,8 +1476,8 @@ const Te = ({
|
|
|
1471
1476
|
}
|
|
1472
1477
|
);
|
|
1473
1478
|
export {
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1479
|
+
tt as FilePreviewModal,
|
|
1480
|
+
Ce as normalizeFile,
|
|
1481
|
+
Me as normalizeFiles
|
|
1477
1482
|
};
|
|
1478
1483
|
//# sourceMappingURL=index.mjs.map
|