@eternalheart/react-file-preview 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/lib/index.mjs CHANGED
@@ -1,32 +1,32 @@
1
- import { jsxs as f, jsx as e, Fragment as W } from "react/jsx-runtime";
2
- import { useState as b, useRef as P, useEffect as C, useCallback as M, useMemo as O } from "react";
3
- import { createPortal as I } from "react-dom";
4
- import { motion as H, AnimatePresence as Y } from "framer-motion";
5
- import { Presentation as J, Music as K, SkipBack as Q, Pause as ee, Play as te, SkipForward as re, VolumeX as oe, Volume2 as ne, FileText as le, FileQuestion as ae, Download as q, ZoomOut as se, ZoomIn as ie, Minimize2 as ce, Maximize2 as de, RotateCcw as me, RotateCw as ue, RefreshCw as he, X as pe, ChevronLeft as fe, ChevronRight as xe } from "lucide-react";
6
- import { pdfjs as B, Document as we, Page as ge } from "react-pdf";
7
- import { pdfjs as nt } from "react-pdf";
8
- import be from "mammoth";
9
- import * as V from "xlsx";
10
- import { init as X } from "pptx-preview";
11
- import ve from "video.js";
12
- import ye from "react-markdown";
13
- import Ne from "remark-gfm";
14
- import { Prism as Z } from "react-syntax-highlighter";
15
- const ke = "1.0.2", je = {
16
- version: ke
1
+ import { jsxs as d, jsx as e, Fragment as $ } from "react/jsx-runtime";
2
+ import { useState as f, useRef as R, useEffect as L, useCallback as M, useMemo as q } from "react";
3
+ import { createPortal as le } from "react-dom";
4
+ import { motion as B, AnimatePresence as ne } from "framer-motion";
5
+ import { Presentation as se, Music as ae, SkipBack as ie, Pause as ce, Play as de, SkipForward as me, VolumeX as ue, Volume2 as he, FileText as pe, FileQuestion as fe, Download as Y, X as Z, ZoomOut as xe, ZoomIn as we, Minimize2 as ge, Maximize2 as be, RotateCcw as ve, RotateCw as ye, RefreshCw as Ne, ChevronLeft as ke, ChevronRight as je } from "lucide-react";
6
+ import { pdfjs as W, Document as Te, Page as Me } from "react-pdf";
7
+ import { pdfjs as ut } from "react-pdf";
8
+ import Ce from "mammoth";
9
+ import * as _ from "xlsx";
10
+ import { init as G } from "pptx-preview";
11
+ import Se from "video.js";
12
+ import Le from "react-markdown";
13
+ import Pe from "remark-gfm";
14
+ import { Prism as J } from "react-syntax-highlighter";
15
+ const Re = "1.0.3", Ee = {
16
+ version: Re
17
17
  };
18
- function Me(t) {
18
+ function De(r) {
19
19
  try {
20
- const s = new URL(t).pathname.split("/").pop() || "file";
21
- return decodeURIComponent(s);
20
+ const a = new URL(r).pathname.split("/").pop() || "file";
21
+ return decodeURIComponent(a);
22
22
  } catch {
23
- const r = t.split("/").pop() || "file";
24
- return decodeURIComponent(r);
23
+ const t = r.split("/").pop() || "file";
24
+ return decodeURIComponent(t);
25
25
  }
26
26
  }
27
- function A(t) {
28
- var s;
29
- const r = ((s = t.split(".").pop()) == null ? void 0 : s.toLowerCase()) || "";
27
+ function U(r) {
28
+ var a;
29
+ const t = ((a = r.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "";
30
30
  return {
31
31
  // 图片
32
32
  jpg: "image/jpeg",
@@ -83,107 +83,107 @@ function A(t) {
83
83
  rs: "text/x-rust",
84
84
  yaml: "text/yaml",
85
85
  yml: "text/yaml"
86
- }[r] || "application/octet-stream";
86
+ }[t] || "application/octet-stream";
87
87
  }
88
- function Ce(t, r = 0) {
89
- if (t instanceof File)
88
+ function ze(r, t = 0) {
89
+ if (r instanceof File)
90
90
  return {
91
- id: `file-${Date.now()}-${r}`,
92
- name: t.name,
93
- url: URL.createObjectURL(t),
94
- type: t.type || A(t.name),
95
- size: t.size
91
+ id: `file-${Date.now()}-${t}`,
92
+ name: r.name,
93
+ url: URL.createObjectURL(r),
94
+ type: r.type || U(r.name),
95
+ size: r.size
96
96
  };
97
- if (typeof t == "string") {
98
- const n = Me(t);
97
+ if (typeof r == "string") {
98
+ const l = De(r);
99
99
  return {
100
- id: `url-${Date.now()}-${r}`,
101
- name: n,
102
- url: t,
103
- type: A(n)
100
+ id: `url-${Date.now()}-${t}`,
101
+ name: l,
102
+ url: r,
103
+ type: U(l)
104
104
  };
105
105
  }
106
106
  return {
107
- id: t.id || `link-${Date.now()}-${r}`,
108
- name: t.name,
109
- url: t.url,
110
- type: t.type || A(t.name),
111
- size: t.size
107
+ id: r.id || `link-${Date.now()}-${t}`,
108
+ name: r.name,
109
+ url: r.url,
110
+ type: r.type || U(r.name),
111
+ size: r.size
112
112
  };
113
113
  }
114
- function Te(t) {
115
- return t.map((r, n) => Ce(r, n));
114
+ function Fe(r) {
115
+ return r.map((t, l) => ze(t, l));
116
116
  }
117
- const Le = ({
118
- url: t,
119
- zoom: r,
120
- rotation: n,
121
- onZoomChange: s
117
+ const $e = ({
118
+ url: r,
119
+ zoom: t,
120
+ rotation: l,
121
+ onZoomChange: a
122
122
  }) => {
123
- const [c, d] = b(!1), [i, 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 = P(null);
124
- C(() => {
125
- d(!1), o(null), w({ x: 0, y: 0 }), x(1);
126
- }, [t]), C(() => {
127
- x(r);
128
- }, [r]), C(() => {
123
+ const [n, c] = f(!1), [i, o] = f(null), [s, w] = f({ x: 0, y: 0 }), [h, m] = f(!1), [N, x] = f({ x: 0, y: 0 }), [b, p] = f(1), y = R(null);
124
+ L(() => {
125
+ c(!1), o(null), w({ x: 0, y: 0 }), p(1);
126
+ }, [r]), L(() => {
127
+ p(t);
128
+ }, [t]), L(() => {
129
129
  w({ x: 0, y: 0 });
130
- }, [r, n]);
130
+ }, [t, l]);
131
131
  const k = () => {
132
- d(!0);
133
- }, T = () => {
134
- o("图片加载失败"), d(!0);
135
- }, L = () => {
132
+ c(!0);
133
+ }, j = () => {
134
+ o("图片加载失败"), c(!0);
135
+ }, u = () => {
136
136
  w({ x: 0, y: 0 });
137
- }, R = M((N) => {
138
- N.preventDefault(), N.stopPropagation();
139
- const D = N.deltaY > 0 ? -0.1 : 0.1;
140
- x((S) => {
141
- const F = Math.max(0.5, Math.min(5, S + D));
142
- return s && s(F), F;
137
+ }, P = M((T) => {
138
+ T.preventDefault(), T.stopPropagation();
139
+ const z = T.deltaY > 0 ? -0.1 : 0.1;
140
+ p((D) => {
141
+ const H = Math.max(0.5, Math.min(5, D + z));
142
+ return a && a(H), H;
143
143
  });
144
- }, [s]), z = M((N) => {
145
- N.button === 0 && (u(!0), h({
146
- x: N.clientX - a.x,
147
- y: N.clientY - a.y
144
+ }, [a]), C = M((T) => {
145
+ T.button === 0 && (m(!0), x({
146
+ x: T.clientX - s.x,
147
+ y: T.clientY - s.y
148
148
  }));
149
- }, [a]), g = M((N) => {
150
- p && w({
151
- x: N.clientX - v.x,
152
- y: N.clientY - v.y
149
+ }, [s]), g = M((T) => {
150
+ h && w({
151
+ x: T.clientX - N.x,
152
+ y: T.clientY - N.y
153
153
  });
154
- }, [p, v]), j = M(() => {
155
- u(!1);
154
+ }, [h, N]), S = M(() => {
155
+ m(!1);
156
156
  }, []);
157
- return /* @__PURE__ */ f(
157
+ return /* @__PURE__ */ d(
158
158
  "div",
159
159
  {
160
- ref: m,
160
+ ref: y,
161
161
  className: "flex items-center justify-center w-full h-full overflow-hidden",
162
- onWheel: R,
163
- onMouseDown: z,
162
+ onWheel: P,
163
+ onMouseDown: C,
164
164
  onMouseMove: g,
165
- onMouseUp: j,
166
- onMouseLeave: j,
167
- style: { cursor: p ? "grabbing" : "grab" },
165
+ onMouseUp: S,
166
+ onMouseLeave: S,
167
+ style: { cursor: h ? "grabbing" : "grab" },
168
168
  children: [
169
- !c && !i && /* @__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" }) }),
169
+ !n && !i && /* @__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" }) }),
170
170
  i && /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: i }) }),
171
171
  /* @__PURE__ */ e(
172
- H.img,
172
+ B.img,
173
173
  {
174
- src: t,
174
+ src: r,
175
175
  alt: "Preview",
176
- className: `max-w-none select-none ${c ? "" : "hidden"}`,
176
+ className: `max-w-none select-none ${n ? "" : "hidden"}`,
177
177
  style: {
178
- transform: `translate(${a.x}px, ${a.y}px) scale(${l}) rotate(${n}deg)`,
178
+ transform: `translate(${s.x}px, ${s.y}px) scale(${b}) rotate(${l}deg)`,
179
179
  transformOrigin: "center",
180
- transition: p ? "none" : "transform 0.3s ease-out"
180
+ transition: h ? "none" : "transform 0.3s ease-out"
181
181
  },
182
182
  onLoad: k,
183
- onError: T,
184
- onDoubleClick: L,
183
+ onError: j,
184
+ onDoubleClick: u,
185
185
  initial: { opacity: 0 },
186
- animate: { opacity: c ? 1 : 0 },
186
+ animate: { opacity: n ? 1 : 0 },
187
187
  transition: { duration: 0.3 },
188
188
  draggable: !1
189
189
  }
@@ -192,75 +192,75 @@ const Le = ({
192
192
  }
193
193
  );
194
194
  };
195
- function Pe(t) {
195
+ function We(r) {
196
196
  if (typeof window > "u") return;
197
197
  const {
198
- workerSrc: r = `https://unpkg.com/pdfjs-dist@${B.version}/build/pdf.worker.min.mjs`,
199
- cMapUrl: n = `https://unpkg.com/pdfjs-dist@${B.version}/cmaps/`,
200
- cMapPacked: s = !0
201
- } = t || {};
202
- B.GlobalWorkerOptions.workerSrc = r, B.GlobalWorkerOptions.cMapUrl = n, B.GlobalWorkerOptions.cMapPacked = s;
198
+ workerSrc: t = `https://unpkg.com/pdfjs-dist@${W.version}/build/pdf.worker.min.mjs`,
199
+ cMapUrl: l = `https://unpkg.com/pdfjs-dist@${W.version}/cmaps/`,
200
+ cMapPacked: a = !0
201
+ } = r || {};
202
+ W.GlobalWorkerOptions.workerSrc = t, W.GlobalWorkerOptions.cMapUrl = l, W.GlobalWorkerOptions.cMapPacked = a;
203
203
  }
204
- Pe();
205
- const Re = ({
206
- url: t,
207
- zoom: r,
208
- currentPage: n,
209
- onPageChange: s,
210
- onTotalPagesChange: c
204
+ We();
205
+ const Be = ({
206
+ url: r,
207
+ zoom: t,
208
+ currentPage: l,
209
+ onPageChange: a,
210
+ onTotalPagesChange: n
211
211
  }) => {
212
- const [d, i] = b(0), [o, a] = b(null), w = P(null), p = P(/* @__PURE__ */ new Map());
213
- C(() => {
214
- a(null);
215
- }, [t]);
216
- const u = ({ numPages: x }) => {
217
- i(x), c(x), s(1);
218
- }, v = (x) => {
219
- console.error("PDF 加载错误:", x), a("PDF 文件加载失败");
220
- }, h = M(() => {
212
+ const [c, i] = f(0), [o, s] = f(null), w = R(null), h = R(/* @__PURE__ */ new Map());
213
+ L(() => {
214
+ s(null);
215
+ }, [r]);
216
+ const m = ({ numPages: p }) => {
217
+ i(p), n(p), a(1);
218
+ }, N = (p) => {
219
+ console.error("PDF 加载错误:", p), s("PDF 文件加载失败");
220
+ }, x = M(() => {
221
221
  if (!w.current) return;
222
- const x = w.current, m = x.scrollTop, k = x.clientHeight, T = m + k / 2;
223
- let L = 1, R = 1 / 0;
224
- p.current.forEach((z, g) => {
225
- const j = z.getBoundingClientRect(), N = x.getBoundingClientRect(), D = j.top - N.top + j.height / 2 + m, S = Math.abs(D - T);
226
- S < R && (R = S, L = g);
227
- }), L !== n && s(L);
228
- }, [n, s]);
229
- C(() => {
230
- const x = w.current;
231
- if (x)
232
- return x.addEventListener("scroll", h), () => x.removeEventListener("scroll", h);
233
- }, [h]);
234
- const l = M((x, m) => {
235
- m ? p.current.set(x, m) : p.current.delete(x);
222
+ const p = w.current, y = p.scrollTop, k = p.clientHeight, j = y + k / 2;
223
+ let u = 1, P = 1 / 0;
224
+ h.current.forEach((C, g) => {
225
+ const S = C.getBoundingClientRect(), T = p.getBoundingClientRect(), z = S.top - T.top + S.height / 2 + y, D = Math.abs(z - j);
226
+ D < P && (P = D, u = g);
227
+ }), u !== l && a(u);
228
+ }, [l, a]);
229
+ L(() => {
230
+ const p = w.current;
231
+ if (p)
232
+ return p.addEventListener("scroll", x), () => p.removeEventListener("scroll", x);
233
+ }, [x]);
234
+ const b = M((p, y) => {
235
+ y ? h.current.set(p, y) : h.current.delete(p);
236
236
  }, []);
237
- return /* @__PURE__ */ f(
237
+ return /* @__PURE__ */ d(
238
238
  "div",
239
239
  {
240
240
  ref: w,
241
- className: "flex flex-col items-center w-full h-full overflow-auto py-8 px-4",
241
+ className: "flex flex-col items-center w-full h-full overflow-auto py-4 md:py-8 px-2 md:px-4",
242
242
  children: [
243
243
  o && /* @__PURE__ */ e("div", { className: "text-white/70 text-center", children: /* @__PURE__ */ e("p", { className: "text-lg", children: o }) }),
244
244
  !o && /* @__PURE__ */ e(
245
- we,
245
+ Te,
246
246
  {
247
- file: t,
248
- onLoadSuccess: u,
249
- onLoadError: v,
247
+ file: r,
248
+ onLoadSuccess: m,
249
+ onLoadError: N,
250
250
  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" }) }),
251
- children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-4", children: Array.from(new Array(d), (x, m) => {
252
- const k = m + 1;
253
- return /* @__PURE__ */ f(
251
+ children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-4", children: Array.from(new Array(c), (p, y) => {
252
+ const k = y + 1;
253
+ return /* @__PURE__ */ d(
254
254
  "div",
255
255
  {
256
- ref: (T) => l(k, T),
256
+ ref: (j) => b(k, j),
257
257
  className: "relative",
258
258
  children: [
259
259
  /* @__PURE__ */ e(
260
- ge,
260
+ Me,
261
261
  {
262
262
  pageNumber: k,
263
- scale: r,
263
+ scale: t,
264
264
  loading: /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8 bg-white/5 rounded-lg min-h-[600px]", children: /* @__PURE__ */ e("div", { className: "w-8 h-8 border-4 border-white/20 border-t-white rounded-full animate-spin" }) }),
265
265
  renderTextLayer: !0,
266
266
  renderAnnotationLayer: !0,
@@ -275,38 +275,38 @@ const Re = ({
275
275
  }) })
276
276
  }
277
277
  ),
278
- 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: [
278
+ c > 0 && /* @__PURE__ */ d("div", { className: "sticky bottom-2 md:bottom-4 mt-4 md:mt-8 bg-black/60 backdrop-blur-xl text-white px-4 py-2 md:px-6 md:py-3 rounded-full text-xs md:text-sm font-medium shadow-2xl border border-white/10", children: [
279
279
  "第 ",
280
- n,
280
+ l,
281
281
  " 页 / 共 ",
282
- d,
282
+ c,
283
283
  " 页"
284
284
  ] })
285
285
  ]
286
286
  }
287
287
  );
288
- }, Se = ({ url: t }) => {
289
- const [r, n] = b(""), [s, c] = b(!0), [d, i] = b(null);
290
- return C(() => {
288
+ }, He = ({ url: r }) => {
289
+ const [t, l] = f(""), [a, n] = f(!0), [c, i] = f(null);
290
+ return L(() => {
291
291
  (async () => {
292
- c(!0), i(null), n("");
292
+ n(!0), i(null), l("");
293
293
  try {
294
- const a = await fetch(t);
295
- if (!a.ok)
294
+ const s = await fetch(r);
295
+ if (!s.ok)
296
296
  throw new Error("文件加载失败");
297
- const w = await a.arrayBuffer(), p = await be.convertToHtml({ arrayBuffer: w });
298
- n(p.value);
299
- } catch (a) {
300
- console.error("Docx 解析错误:", a), i("Word 文档解析失败");
297
+ const w = await s.arrayBuffer(), h = await Ce.convertToHtml({ arrayBuffer: w });
298
+ l(h.value);
299
+ } catch (s) {
300
+ console.error("Docx 解析错误:", s), i("Word 文档解析失败");
301
301
  } finally {
302
- c(!1);
302
+ n(!1);
303
303
  }
304
304
  })();
305
- }, [t]), s ? /* @__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(
305
+ }, [r]), a ? /* @__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" }) }) : c ? /* @__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: c }) }) }) : /* @__PURE__ */ e("div", { className: "w-full h-full overflow-auto p-4 md:p-8", children: /* @__PURE__ */ e(
306
306
  "div",
307
307
  {
308
- className: "max-w-4xl mx-auto bg-white rounded-lg shadow-2xl p-12",
309
- dangerouslySetInnerHTML: { __html: r },
308
+ className: "max-w-full md:max-w-4xl mx-auto bg-white rounded-lg shadow-2xl p-6 md:p-12",
309
+ dangerouslySetInnerHTML: { __html: t },
310
310
  style: {
311
311
  fontFamily: "system-ui, -apple-system, sans-serif",
312
312
  lineHeight: "1.6",
@@ -314,189 +314,189 @@ const Re = ({
314
314
  }
315
315
  }
316
316
  ) });
317
- }, De = ({ url: t }) => {
318
- const [r, n] = b([]), [s, c] = b(0), [d, i] = b(!0), [o, a] = b(null);
319
- if (C(() => {
317
+ }, Ae = ({ url: r }) => {
318
+ const [t, l] = f([]), [a, n] = f(0), [c, i] = f(!0), [o, s] = f(null);
319
+ if (L(() => {
320
320
  (async () => {
321
- i(!0), a(null), n([]);
321
+ i(!0), s(null), l([]);
322
322
  try {
323
- const u = await fetch(t);
324
- if (!u.ok)
323
+ const m = await fetch(r);
324
+ if (!m.ok)
325
325
  throw new Error("文件加载失败");
326
- const v = await u.arrayBuffer(), h = V.read(v, { type: "array" }), l = h.SheetNames.map((x) => {
327
- const m = h.Sheets[x], k = V.utils.sheet_to_json(m, { header: 1 });
328
- return { name: x, data: k };
326
+ const N = await m.arrayBuffer(), x = _.read(N, { type: "array" }), b = x.SheetNames.map((p) => {
327
+ const y = x.Sheets[p], k = _.utils.sheet_to_json(y, { header: 1 });
328
+ return { name: p, data: k };
329
329
  });
330
- n(l), c(0);
331
- } catch (u) {
332
- console.error("Excel 解析错误:", u), a("Excel 文件解析失败");
330
+ l(b), n(0);
331
+ } catch (m) {
332
+ console.error("Excel 解析错误:", m), s("Excel 文件解析失败");
333
333
  } finally {
334
334
  i(!1);
335
335
  }
336
336
  })();
337
- }, [t]), d)
337
+ }, [r]), c)
338
338
  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" }) });
339
339
  if (o)
340
340
  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 }) }) });
341
- const w = r[s];
342
- return /* @__PURE__ */ f("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
343
- r.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: r.map((p, u) => /* @__PURE__ */ e(
341
+ const w = t[a];
342
+ return /* @__PURE__ */ d("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
343
+ t.length > 1 && /* @__PURE__ */ e("div", { className: "flex gap-1 md:gap-2 p-2 md:p-4 bg-black/20 backdrop-blur-sm overflow-x-auto border-b border-white/10 scrollbar-hide", children: t.map((h, m) => /* @__PURE__ */ e(
344
344
  "button",
345
345
  {
346
- onClick: () => c(u),
347
- className: `px-4 py-2 rounded-lg text-sm font-medium transition-all ${s === u ? "bg-gradient-to-r from-purple-500 to-pink-500 text-white shadow-lg" : "bg-white/10 text-white hover:bg-white/20"}`,
348
- children: p.name
346
+ onClick: () => n(m),
347
+ className: `px-3 py-1.5 md:px-4 md:py-2 rounded-lg text-xs md:text-sm font-medium transition-all flex-shrink-0 ${a === m ? "bg-gradient-to-r from-purple-500 to-pink-500 text-white shadow-lg" : "bg-white/10 text-white hover:bg-white/20"}`,
348
+ children: h.name
349
349
  },
350
- u
350
+ m
351
351
  )) }),
352
- /* @__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(
352
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-auto p-2 md: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-xl md: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((h, m) => /* @__PURE__ */ e(
353
353
  "tr",
354
354
  {
355
- className: `transition-colors ${u === 0 ? "bg-gradient-to-r from-purple-500/20 to-pink-500/20 font-semibold" : "hover:bg-white/5"}`,
356
- children: p.map((v, h) => /* @__PURE__ */ e(
355
+ className: `transition-colors ${m === 0 ? "bg-gradient-to-r from-purple-500/20 to-pink-500/20 font-semibold" : "hover:bg-white/5"}`,
356
+ children: h.map((N, x) => /* @__PURE__ */ e(
357
357
  "td",
358
358
  {
359
- className: "px-6 py-4 whitespace-nowrap text-sm text-gray-200 border-r border-white/10",
360
- children: String(v ?? "")
359
+ className: "px-3 py-2 md:px-6 md:py-4 whitespace-nowrap text-xs md:text-sm text-gray-200 border-r border-white/10",
360
+ children: String(N ?? "")
361
361
  },
362
- h
362
+ x
363
363
  ))
364
364
  },
365
- u
365
+ m
366
366
  )) }) }) }) })
367
367
  ] });
368
- }, Ee = ({ url: t }) => {
369
- const [r, n] = b(!0), [s, c] = b(null), d = P(null), i = P(null), o = P(null), a = P(null), w = P(null), p = P({ width: 0, height: 0 }), u = M(() => {
370
- if (!d.current) return { width: 960, height: 540 };
371
- const h = d.current.clientWidth, l = Math.floor(h * 9 / 16);
372
- return console.log("计算尺寸:", { width: h, height: l }), { width: h, height: l };
373
- }, []), v = M(async () => {
374
- if (!(!d.current || !a.current)) {
368
+ }, Ue = ({ url: r }) => {
369
+ const [t, l] = f(!0), [a, n] = f(null), c = R(null), i = R(null), o = R(null), s = R(null), w = R(null), h = R({ width: 0, height: 0 }), m = M(() => {
370
+ if (!c.current) return { width: 960, height: 540 };
371
+ const x = c.current.clientWidth, b = Math.floor(x * 9 / 16);
372
+ return console.log("计算尺寸:", { width: x, height: b }), { width: x, height: b };
373
+ }, []), N = M(async () => {
374
+ if (!(!c.current || !s.current)) {
375
375
  console.log("重新初始化预览器...");
376
376
  try {
377
377
  if (i.current)
378
378
  try {
379
379
  i.current.destroy();
380
- } catch (x) {
381
- console.error("销毁预览器失败:", x);
380
+ } catch (p) {
381
+ console.error("销毁预览器失败:", p);
382
382
  }
383
- d.current.innerHTML = "";
384
- const h = u();
385
- console.log("重新初始化使用尺寸:", h);
386
- const l = X(d.current, {
387
- width: h.width,
388
- height: h.height
383
+ c.current.innerHTML = "";
384
+ const x = m();
385
+ console.log("重新初始化使用尺寸:", x);
386
+ const b = G(c.current, {
387
+ width: x.width,
388
+ height: x.height
389
389
  });
390
- i.current = l, await l.preview(a.current), console.log("重新初始化成功");
391
- } catch (h) {
392
- console.error("重新初始化失败:", h);
390
+ i.current = b, await b.preview(s.current), console.log("重新初始化成功");
391
+ } catch (x) {
392
+ console.error("重新初始化失败:", x);
393
393
  }
394
394
  }
395
- }, [u]);
396
- return C(() => {
397
- if (!d.current) return;
398
- let h = !0;
399
- const l = () => {
400
- if (h) {
401
- h = !1;
402
- const L = u();
403
- p.current = L;
395
+ }, [m]);
396
+ return L(() => {
397
+ if (!c.current) return;
398
+ let x = !0;
399
+ const b = () => {
400
+ if (x) {
401
+ x = !1;
402
+ const u = m();
403
+ h.current = u;
404
404
  return;
405
405
  }
406
- const x = u(), m = p.current, k = Math.abs(m.width - x.width), T = Math.abs(m.height - x.height);
407
- if (k < 10 && T < 10) {
406
+ const p = m(), y = h.current, k = Math.abs(y.width - p.width), j = Math.abs(y.height - p.height);
407
+ if (k < 10 && j < 10) {
408
408
  console.log("尺寸变化太小,忽略");
409
409
  return;
410
410
  }
411
411
  console.log("检测到尺寸变化:", {
412
- old: m,
413
- new: x,
414
- diff: { width: k, height: T }
415
- }), p.current = x, w.current && clearTimeout(w.current), w.current = window.setTimeout(() => {
416
- i.current && a.current && (console.log("尺寸变化,准备重新初始化"), v());
412
+ old: y,
413
+ new: p,
414
+ diff: { width: k, height: j }
415
+ }), h.current = p, w.current && clearTimeout(w.current), w.current = window.setTimeout(() => {
416
+ i.current && s.current && (console.log("尺寸变化,准备重新初始化"), N());
417
417
  }, 800);
418
418
  };
419
419
  return o.current = new ResizeObserver(() => {
420
- l();
421
- }), o.current.observe(d.current), () => {
420
+ b();
421
+ }), o.current.observe(c.current), () => {
422
422
  o.current && o.current.disconnect(), w.current && clearTimeout(w.current);
423
423
  };
424
- }, [u, v]), C(() => {
425
- let h = !0;
426
- const l = async () => {
427
- if (!d.current) {
424
+ }, [m, N]), L(() => {
425
+ let x = !0;
426
+ const b = async () => {
427
+ if (!c.current) {
428
428
  console.log("Container ref not ready");
429
429
  return;
430
430
  }
431
- n(!0), c(null);
431
+ l(!0), n(null);
432
432
  try {
433
- console.log("开始加载 PPTX:", t);
434
- const m = await fetch(t);
435
- if (!m.ok)
433
+ console.log("开始加载 PPTX:", r);
434
+ const y = await fetch(r);
435
+ if (!y.ok)
436
436
  throw new Error("文件加载失败");
437
- const k = await m.arrayBuffer();
438
- if (a.current = k, console.log("文件加载成功,大小:", k.byteLength), !h) return;
439
- d.current && (d.current.innerHTML = "");
440
- const T = u();
441
- console.log("使用尺寸:", T), console.log("初始化预览器...");
442
- const L = X(d.current, {
443
- width: T.width,
444
- height: T.height
437
+ const k = await y.arrayBuffer();
438
+ if (s.current = k, console.log("文件加载成功,大小:", k.byteLength), !x) return;
439
+ c.current && (c.current.innerHTML = "");
440
+ const j = m();
441
+ console.log("使用尺寸:", j), console.log("初始化预览器...");
442
+ const u = G(c.current, {
443
+ width: j.width,
444
+ height: j.height
445
445
  });
446
- i.current = L, console.log("开始预览..."), L.preview(k).then(() => {
447
- console.log("预览成功"), h && n(!1);
448
- }).catch((R) => {
449
- console.error("预览失败:", R), h && (c("PPT 文件预览失败"), n(!1));
446
+ i.current = u, console.log("开始预览..."), u.preview(k).then(() => {
447
+ console.log("预览成功"), x && l(!1);
448
+ }).catch((P) => {
449
+ console.error("预览失败:", P), x && (n("PPT 文件预览失败"), l(!1));
450
450
  });
451
- } catch (m) {
452
- console.error("PPTX 解析错误:", m), h && (c(m instanceof Error ? m.message : "PPT 文件解析失败"), n(!1));
451
+ } catch (y) {
452
+ console.error("PPTX 解析错误:", y), x && (n(y instanceof Error ? y.message : "PPT 文件解析失败"), l(!1));
453
453
  }
454
- }, x = setTimeout(() => {
455
- l();
454
+ }, p = setTimeout(() => {
455
+ b();
456
456
  }, 100);
457
457
  return () => {
458
- if (h = !1, clearTimeout(x), a.current = null, i.current)
458
+ if (x = !1, clearTimeout(p), s.current = null, i.current)
459
459
  try {
460
460
  i.current.destroy();
461
- } catch (m) {
462
- console.error("销毁预览器失败:", m);
461
+ } catch (y) {
462
+ console.error("销毁预览器失败:", y);
463
463
  }
464
464
  i.current = null;
465
465
  };
466
- }, [t, u]), /* @__PURE__ */ f("div", { className: "relative flex flex-col items-center w-full h-full pt-[8px]", children: [
467
- r && /* @__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: [
468
- /* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-3 border-4 border-white/20 border-t-white rounded-full animate-spin" }),
469
- /* @__PURE__ */ e("p", { className: "text-sm text-white/70 font-medium", children: "加载 PPT 中..." })
466
+ }, [r, m]), /* @__PURE__ */ d("div", { className: "relative flex flex-col items-center w-full h-full pt-2 px-2 md:px-4", children: [
467
+ t && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-xl md:rounded-2xl", children: /* @__PURE__ */ d("div", { className: "text-center", children: [
468
+ /* @__PURE__ */ e("div", { className: "w-10 h-10 md:w-12 md:h-12 mx-auto mb-3 border-4 border-white/20 border-t-white rounded-full animate-spin" }),
469
+ /* @__PURE__ */ e("p", { className: "text-xs md:text-sm text-white/70 font-medium", children: "加载 PPT 中..." })
470
470
  ] }) }),
471
- s && /* @__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: [
472
- /* @__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(J, { className: "w-16 h-16 text-white" }) }),
473
- /* @__PURE__ */ e("p", { className: "text-xl text-white/90 mb-3 font-medium", children: "PPT 预览" }),
474
- /* @__PURE__ */ e("p", { className: "text-sm text-white/60 mb-6", children: s || "浏览器暂不支持直接预览 PPT 文件" }),
475
- /* @__PURE__ */ f(
471
+ a && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-10 rounded-xl md:rounded-2xl", children: /* @__PURE__ */ d("div", { className: "text-center max-w-sm md:max-w-md px-4", children: [
472
+ /* @__PURE__ */ e("div", { className: "w-24 h-24 md:w-32 md:h-32 mx-auto mb-4 md:mb-6 rounded-2xl md: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(se, { className: "w-12 h-12 md:w-16 md:h-16 text-white" }) }),
473
+ /* @__PURE__ */ e("p", { className: "text-lg md:text-xl text-white/90 mb-2 md:mb-3 font-medium", children: "PPT 预览" }),
474
+ /* @__PURE__ */ e("p", { className: "text-xs md:text-sm text-white/60 mb-4 md:mb-6", children: a || "浏览器暂不支持直接预览 PPT 文件" }),
475
+ /* @__PURE__ */ d(
476
476
  "a",
477
477
  {
478
- href: t,
478
+ href: r,
479
479
  download: !0,
480
- className: "inline-flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-purple-500 to-pink-500 text-white rounded-xl hover:scale-105 transition-all shadow-lg",
480
+ className: "inline-flex items-center gap-2 px-4 py-2 md:px-6 md:py-3 bg-gradient-to-r from-purple-500 to-pink-500 text-white text-sm md:text-base rounded-lg md:rounded-xl hover:scale-105 transition-all shadow-lg",
481
481
  children: [
482
- /* @__PURE__ */ e("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) }),
482
+ /* @__PURE__ */ e("svg", { className: "w-4 h-4 md:w-5 md:h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) }),
483
483
  "下载文件"
484
484
  ]
485
485
  }
486
486
  ),
487
- /* @__PURE__ */ e("p", { className: "text-xs text-white/40 mt-4", children: "提示:可以使用 Microsoft PowerPoint 或 WPS 打开" })
487
+ /* @__PURE__ */ e("p", { className: "text-xs text-white/40 mt-3 md:mt-4", children: "提示:可以使用 Microsoft PowerPoint 或 WPS 打开" })
488
488
  ] }) }),
489
489
  /* @__PURE__ */ e(
490
490
  "div",
491
491
  {
492
- ref: d,
493
- className: "pptx-wrapper w-full max-w-6xl"
492
+ ref: c,
493
+ className: "pptx-wrapper w-full max-w-full md:max-w-6xl"
494
494
  }
495
495
  )
496
496
  ] });
497
- }, ze = (t) => {
498
- var s;
499
- const r = ((s = t.split(".").pop()) == null ? void 0 : s.toLowerCase().split("?")[0]) || "";
497
+ }, Xe = (r) => {
498
+ var a;
499
+ const t = ((a = r.split(".").pop()) == null ? void 0 : a.toLowerCase().split("?")[0]) || "";
500
500
  return {
501
501
  mp4: "video/mp4",
502
502
  webm: "video/webm",
@@ -509,14 +509,14 @@ const Re = ({
509
509
  m4v: "video/mp4",
510
510
  "3gp": "video/3gpp",
511
511
  flv: "video/x-flv"
512
- }[r] || "video/mp4";
513
- }, Fe = ({ url: t }) => {
514
- const [r, n] = b(null), [s, c] = b(!0), d = P(null), i = P(null);
515
- return C(() => {
516
- if (!i.current && d.current) {
512
+ }[t] || "video/mp4";
513
+ }, Oe = ({ url: r }) => {
514
+ const [t, l] = f(null), [a, n] = f(!0), c = R(null), i = R(null);
515
+ return L(() => {
516
+ if (!i.current && c.current) {
517
517
  const o = document.createElement("video-js");
518
- o.classList.add("vjs-big-play-centered", "vjs-theme-apple"), d.current.appendChild(o);
519
- const a = ze(t), p = ve(o, {
518
+ o.classList.add("vjs-big-play-centered", "vjs-theme-apple"), c.current.appendChild(o);
519
+ const s = Xe(r), h = Se(o, {
520
520
  controls: !0,
521
521
  responsive: !0,
522
522
  fluid: !0,
@@ -544,37 +544,37 @@ const Re = ({
544
544
  nativeAudioTracks: !1,
545
545
  nativeTextTracks: !1
546
546
  },
547
- sources: a === "video/quicktime" ? [
548
- { src: t, type: "video/quicktime" },
549
- { src: t, type: "video/mp4" }
547
+ sources: s === "video/quicktime" ? [
548
+ { src: r, type: "video/quicktime" },
549
+ { src: r, type: "video/mp4" }
550
550
  // 备用方案
551
- ] : [{ src: t, type: a }]
551
+ ] : [{ src: r, type: s }]
552
552
  });
553
- p.on("loadeddata", () => {
554
- c(!1);
555
- }), p.on("error", () => {
556
- const u = p.error();
557
- console.error("Video.js error:", u), n(`视频加载失败: ${(u == null ? void 0 : u.message) || "未知错误"}`), c(!1);
558
- }), i.current = p;
553
+ h.on("loadeddata", () => {
554
+ n(!1);
555
+ }), h.on("error", () => {
556
+ const m = h.error();
557
+ console.error("Video.js error:", m), l(`视频加载失败: ${(m == null ? void 0 : m.message) || "未知错误"}`), n(!1);
558
+ }), i.current = h;
559
559
  }
560
- }, [t]), C(() => {
560
+ }, [r]), L(() => {
561
561
  const o = i.current;
562
562
  return () => {
563
563
  o && !o.isDisposed() && (o.dispose(), i.current = null);
564
564
  };
565
- }, []), r ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ f("div", { className: "text-center", children: [
565
+ }, []), t ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ d("div", { className: "text-center", children: [
566
566
  /* @__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" }) }) }),
567
567
  /* @__PURE__ */ e("p", { className: "text-lg font-medium text-white/90 mb-2", children: "视频加载失败" }),
568
- /* @__PURE__ */ e("p", { className: "text-sm text-white/60", children: r })
569
- ] }) }) : /* @__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: [
570
- s && /* @__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: [
568
+ /* @__PURE__ */ e("p", { className: "text-sm text-white/60", children: t })
569
+ ] }) }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-full h-full p-4 md:p-8", children: /* @__PURE__ */ d("div", { className: "w-full max-w-full md:max-w-5xl relative", children: [
570
+ a && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/20 backdrop-blur-sm rounded-2xl z-10", children: /* @__PURE__ */ d("div", { className: "text-center", children: [
571
571
  /* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-3 border-3 border-white/20 border-t-white rounded-full animate-spin" }),
572
572
  /* @__PURE__ */ e("p", { className: "text-sm text-white/70 font-medium", children: "加载视频中..." })
573
573
  ] }) }),
574
574
  /* @__PURE__ */ e(
575
575
  "div",
576
576
  {
577
- ref: d,
577
+ ref: c,
578
578
  className: "overflow-hidden",
579
579
  style: {
580
580
  boxShadow: "0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)"
@@ -582,55 +582,55 @@ const Re = ({
582
582
  }
583
583
  )
584
584
  ] }) });
585
- }, $e = ({ url: t, fileName: r }) => {
586
- const [n, s] = b(null), [c, d] = b(!1), [i, o] = b(0), [a, w] = b(0), [p, u] = b(1), [v, h] = b(!1), l = P(null);
587
- C(() => {
588
- const g = l.current;
585
+ }, Ve = ({ url: r, fileName: t }) => {
586
+ const [l, a] = f(null), [n, c] = f(!1), [i, o] = f(0), [s, w] = f(0), [h, m] = f(1), [N, x] = f(!1), b = R(null);
587
+ L(() => {
588
+ const g = b.current;
589
589
  if (!g) return;
590
- const j = () => {
590
+ const S = () => {
591
591
  isNaN(g.currentTime) || o(g.currentTime);
592
- }, N = () => {
592
+ }, T = () => {
593
593
  !isNaN(g.duration) && isFinite(g.duration) && w(g.duration);
594
- }, D = () => d(!1), S = () => N();
595
- return g.addEventListener("timeupdate", j), g.addEventListener("loadedmetadata", N), g.addEventListener("durationchange", N), g.addEventListener("canplay", S), g.addEventListener("ended", D), g.readyState >= 1 && N(), () => {
596
- g.removeEventListener("timeupdate", j), g.removeEventListener("loadedmetadata", N), g.removeEventListener("durationchange", N), g.removeEventListener("canplay", S), g.removeEventListener("ended", D);
594
+ }, z = () => c(!1), D = () => T();
595
+ return g.addEventListener("timeupdate", S), g.addEventListener("loadedmetadata", T), g.addEventListener("durationchange", T), g.addEventListener("canplay", D), g.addEventListener("ended", z), g.readyState >= 1 && T(), () => {
596
+ g.removeEventListener("timeupdate", S), g.removeEventListener("loadedmetadata", T), g.removeEventListener("durationchange", T), g.removeEventListener("canplay", D), g.removeEventListener("ended", z);
597
597
  };
598
598
  }, []);
599
- const x = () => {
600
- l.current && (c ? l.current.pause() : l.current.play(), d(!c));
601
- }, m = (g) => {
602
- const j = parseFloat(g.target.value);
603
- o(j), l.current && (l.current.currentTime = j);
599
+ const p = () => {
600
+ b.current && (n ? b.current.pause() : b.current.play(), c(!n));
601
+ }, y = (g) => {
602
+ const S = parseFloat(g.target.value);
603
+ o(S), b.current && (b.current.currentTime = S);
604
604
  }, k = (g) => {
605
- const j = parseFloat(g.target.value);
606
- u(j), l.current && (l.current.volume = j), j > 0 && h(!1);
607
- }, T = () => {
608
- l.current && (l.current.muted = !v, h(!v));
609
- }, L = (g) => {
610
- l.current && (l.current.currentTime += g);
611
- }, R = (g) => {
605
+ const S = parseFloat(g.target.value);
606
+ m(S), b.current && (b.current.volume = S), S > 0 && x(!1);
607
+ }, j = () => {
608
+ b.current && (b.current.muted = !N, x(!N));
609
+ }, u = (g) => {
610
+ b.current && (b.current.currentTime += g);
611
+ }, P = (g) => {
612
612
  if (!isFinite(g) || isNaN(g) || g < 0) return "0:00";
613
- const j = Math.floor(g / 60), N = Math.floor(g % 60);
614
- return `${j}:${N.toString().padStart(2, "0")}`;
615
- }, z = () => {
616
- s("音频加载失败");
613
+ const S = Math.floor(g / 60), T = Math.floor(g % 60);
614
+ return `${S}:${T.toString().padStart(2, "0")}`;
615
+ }, C = () => {
616
+ a("音频加载失败");
617
617
  };
618
- 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: [
619
- /* @__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(K, { className: "w-32 h-32 text-white" }) }),
620
- /* @__PURE__ */ f("div", { className: "text-white text-center max-w-md", children: [
621
- /* @__PURE__ */ e("p", { className: "text-2xl font-medium mb-1", children: r }),
622
- /* @__PURE__ */ e("p", { className: "text-sm text-white/60", children: "音频文件" })
618
+ return l ? /* @__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: l }) }) }) : /* @__PURE__ */ d("div", { className: "flex flex-col items-center justify-center w-full h-full p-4 md:p-8 gap-4 md:gap-8", children: [
619
+ /* @__PURE__ */ e("div", { className: "w-48 h-48 md:w-64 md: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(ae, { className: "w-24 h-24 md:w-32 md:h-32 text-white" }) }),
620
+ /* @__PURE__ */ d("div", { className: "text-white text-center max-w-sm md:max-w-md px-4", children: [
621
+ /* @__PURE__ */ e("p", { className: "text-xl md:text-2xl font-medium mb-1 truncate", children: t }),
622
+ /* @__PURE__ */ e("p", { className: "text-xs md:text-sm text-white/60", children: "音频文件" })
623
623
  ] }),
624
- /* @__PURE__ */ f("div", { className: "w-full max-w-md bg-white/10 backdrop-blur-xl rounded-2xl p-6 border border-white/20", children: [
625
- /* @__PURE__ */ f("div", { className: "mb-4", children: [
626
- /* @__PURE__ */ f("div", { className: "relative h-4 flex items-center", children: [
624
+ /* @__PURE__ */ d("div", { className: "w-full max-w-sm md:max-w-md bg-white/10 backdrop-blur-xl rounded-2xl p-4 md:p-6 border border-white/20", children: [
625
+ /* @__PURE__ */ d("div", { className: "mb-4", children: [
626
+ /* @__PURE__ */ d("div", { className: "relative h-4 flex items-center", children: [
627
627
  /* @__PURE__ */ e("div", { className: "absolute w-full h-[6px] bg-white/20 rounded-full" }),
628
628
  /* @__PURE__ */ e(
629
629
  "div",
630
630
  {
631
631
  className: "absolute h-[6px] bg-gradient-to-r from-purple-500 to-pink-500 rounded-full transition-all duration-100 ease-linear pointer-events-none",
632
632
  style: {
633
- width: `${a > 0 ? i / a * 100 : i > 100 ? 100 : i}%`
633
+ width: `${s > 0 ? i / s * 100 : i > 100 ? 100 : i}%`
634
634
  }
635
635
  }
636
636
  ),
@@ -639,61 +639,61 @@ const Re = ({
639
639
  {
640
640
  type: "range",
641
641
  min: "0",
642
- max: a > 0 ? a : 100 + (i > 100 ? i % 100 : 0),
642
+ max: s > 0 ? s : 100 + (i > 100 ? i % 100 : 0),
643
643
  value: i,
644
- onChange: m,
644
+ onChange: y,
645
645
  className: "audio-slider absolute w-full"
646
646
  }
647
647
  )
648
648
  ] }),
649
- /* @__PURE__ */ f("div", { className: "flex justify-between text-xs text-white/60 mt-3", children: [
650
- /* @__PURE__ */ e("span", { children: R(i) }),
651
- /* @__PURE__ */ e("span", { children: R(a) })
649
+ /* @__PURE__ */ d("div", { className: "flex justify-between text-xs text-white/60 mt-3", children: [
650
+ /* @__PURE__ */ e("span", { children: P(i) }),
651
+ /* @__PURE__ */ e("span", { children: P(s) })
652
652
  ] })
653
653
  ] }),
654
- /* @__PURE__ */ f("div", { className: "flex items-center justify-center gap-4 mb-4", children: [
654
+ /* @__PURE__ */ d("div", { className: "flex items-center justify-center gap-4 mb-4", children: [
655
655
  /* @__PURE__ */ e(
656
656
  "button",
657
657
  {
658
- onClick: () => L(-10),
658
+ onClick: () => u(-10),
659
659
  className: "w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center text-white transition-all",
660
- children: /* @__PURE__ */ e(Q, { className: "w-5 h-5" })
660
+ children: /* @__PURE__ */ e(ie, { className: "w-5 h-5" })
661
661
  }
662
662
  ),
663
663
  /* @__PURE__ */ e(
664
664
  "button",
665
665
  {
666
- onClick: x,
666
+ onClick: p,
667
667
  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",
668
- children: c ? /* @__PURE__ */ e(ee, { className: "w-6 h-6" }) : /* @__PURE__ */ e(te, { className: "w-6 h-6 ml-1" })
668
+ children: n ? /* @__PURE__ */ e(ce, { className: "w-6 h-6" }) : /* @__PURE__ */ e(de, { className: "w-6 h-6 ml-1" })
669
669
  }
670
670
  ),
671
671
  /* @__PURE__ */ e(
672
672
  "button",
673
673
  {
674
- onClick: () => L(10),
674
+ onClick: () => u(10),
675
675
  className: "w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center text-white transition-all",
676
- children: /* @__PURE__ */ e(re, { className: "w-5 h-5" })
676
+ children: /* @__PURE__ */ e(me, { className: "w-5 h-5" })
677
677
  }
678
678
  )
679
679
  ] }),
680
- /* @__PURE__ */ f("div", { className: "flex items-center gap-3", children: [
680
+ /* @__PURE__ */ d("div", { className: "flex items-center gap-3", children: [
681
681
  /* @__PURE__ */ e(
682
682
  "button",
683
683
  {
684
- onClick: T,
684
+ onClick: j,
685
685
  className: "text-white/80 hover:text-white transition-colors",
686
- children: v || p === 0 ? /* @__PURE__ */ e(oe, { className: "w-5 h-5" }) : /* @__PURE__ */ e(ne, { className: "w-5 h-5" })
686
+ children: N || h === 0 ? /* @__PURE__ */ e(ue, { className: "w-5 h-5" }) : /* @__PURE__ */ e(he, { className: "w-5 h-5" })
687
687
  }
688
688
  ),
689
- /* @__PURE__ */ f("div", { className: "flex-1 relative h-3 flex items-center", children: [
689
+ /* @__PURE__ */ d("div", { className: "flex-1 relative h-3 flex items-center", children: [
690
690
  /* @__PURE__ */ e("div", { className: "absolute w-full h-[4px] bg-white/20 rounded-full" }),
691
691
  /* @__PURE__ */ e(
692
692
  "div",
693
693
  {
694
694
  className: "absolute h-[4px] bg-purple-500 rounded-full transition-all duration-100 pointer-events-none",
695
695
  style: {
696
- width: `${(v ? 0 : p) * 100}%`
696
+ width: `${(N ? 0 : h) * 100}%`
697
697
  }
698
698
  }
699
699
  ),
@@ -704,7 +704,7 @@ const Re = ({
704
704
  min: "0",
705
705
  max: "1",
706
706
  step: "0.01",
707
- value: v ? 0 : p,
707
+ value: N ? 0 : h,
708
708
  onChange: k,
709
709
  className: "volume-slider absolute w-full"
710
710
  }
@@ -715,14 +715,14 @@ const Re = ({
715
715
  /* @__PURE__ */ e(
716
716
  "audio",
717
717
  {
718
- ref: l,
719
- src: t,
720
- onError: z,
718
+ ref: b,
719
+ src: r,
720
+ onError: C,
721
721
  className: "hidden"
722
722
  }
723
723
  )
724
724
  ] });
725
- }, _ = {
725
+ }, K = {
726
726
  'pre[class*="language-"]': {
727
727
  color: "#d4d4d4",
728
728
  fontSize: "13px",
@@ -1003,54 +1003,54 @@ const Re = ({
1003
1003
  boxShadow: "inset 5px 0 0 #f7d87c",
1004
1004
  zIndex: "0"
1005
1005
  }
1006
- }, We = ({ url: t }) => {
1007
- const [r, n] = b(""), [s, c] = b(!0), [d, i] = b(null);
1008
- return C(() => {
1006
+ }, qe = ({ url: r }) => {
1007
+ const [t, l] = f(""), [a, n] = f(!0), [c, i] = f(null);
1008
+ return L(() => {
1009
1009
  (async () => {
1010
1010
  try {
1011
- c(!0), i(null);
1012
- const a = await fetch(t);
1013
- if (!a.ok)
1011
+ n(!0), i(null);
1012
+ const s = await fetch(r);
1013
+ if (!s.ok)
1014
1014
  throw new Error("加载失败");
1015
- const w = await a.text();
1016
- n(w);
1017
- } catch (a) {
1018
- i("Markdown 文件加载失败"), console.error(a);
1015
+ const w = await s.text();
1016
+ l(w);
1017
+ } catch (s) {
1018
+ i("Markdown 文件加载失败"), console.error(s);
1019
1019
  } finally {
1020
- c(!1);
1020
+ n(!1);
1021
1021
  }
1022
1022
  })();
1023
- }, [t]), s ? /* @__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(
1024
- ye,
1023
+ }, [r]), a ? /* @__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" }) }) : c ? /* @__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: c }) }) }) : /* @__PURE__ */ e("div", { className: "w-full h-full overflow-auto p-4 md:p-8", children: /* @__PURE__ */ e("div", { className: "max-w-full md:max-w-4xl mx-auto bg-white/5 backdrop-blur-sm rounded-2xl p-4 md:p-8 border border-white/10", children: /* @__PURE__ */ e("div", { className: "prose prose-invert prose-sm md:prose-lg max-w-none", children: /* @__PURE__ */ e(
1024
+ Le,
1025
1025
  {
1026
- remarkPlugins: [Ne],
1026
+ remarkPlugins: [Pe],
1027
1027
  components: {
1028
- code({ node: o, inline: a, className: w, children: p, ...u }) {
1029
- const v = /language-(\w+)/.exec(w || "");
1030
- return !a && v ? /* @__PURE__ */ e(
1031
- Z,
1028
+ code({ node: o, inline: s, className: w, children: h, ...m }) {
1029
+ const N = /language-(\w+)/.exec(w || "");
1030
+ return !s && N ? /* @__PURE__ */ e(
1031
+ J,
1032
1032
  {
1033
- style: _,
1034
- language: v[1],
1033
+ style: K,
1034
+ language: N[1],
1035
1035
  PreTag: "div",
1036
1036
  className: "rounded-lg",
1037
- ...u,
1038
- children: String(p).replace(/\n$/, "")
1037
+ ...m,
1038
+ children: String(h).replace(/\n$/, "")
1039
1039
  }
1040
- ) : /* @__PURE__ */ e("code", { className: "bg-white/10 px-1.5 py-0.5 rounded text-sm", ...u, children: p });
1040
+ ) : /* @__PURE__ */ e("code", { className: "bg-white/10 px-1.5 py-0.5 rounded text-sm", ...m, children: h });
1041
1041
  },
1042
1042
  h1: ({ children: o }) => /* @__PURE__ */ e("h1", { className: "text-4xl font-bold mb-4 text-white border-b border-white/20 pb-2", children: o }),
1043
1043
  h2: ({ children: o }) => /* @__PURE__ */ e("h2", { className: "text-3xl font-bold mb-3 text-white mt-8", children: o }),
1044
1044
  h3: ({ children: o }) => /* @__PURE__ */ e("h3", { className: "text-2xl font-bold mb-2 text-white mt-6", children: o }),
1045
1045
  p: ({ children: o }) => /* @__PURE__ */ e("p", { className: "text-white/90 mb-4 leading-relaxed", children: o }),
1046
- a: ({ href: o, children: a }) => /* @__PURE__ */ e(
1046
+ a: ({ href: o, children: s }) => /* @__PURE__ */ e(
1047
1047
  "a",
1048
1048
  {
1049
1049
  href: o,
1050
1050
  className: "text-blue-400 hover:text-blue-300 underline",
1051
1051
  target: "_blank",
1052
1052
  rel: "noopener noreferrer",
1053
- children: a
1053
+ children: s
1054
1054
  }
1055
1055
  ),
1056
1056
  ul: ({ children: o }) => /* @__PURE__ */ e("ul", { className: "list-disc list-inside mb-4 text-white/90", children: o }),
@@ -1061,14 +1061,14 @@ const Re = ({
1061
1061
  th: ({ children: o }) => /* @__PURE__ */ e("th", { className: "border border-white/20 px-4 py-2 bg-white/10 text-white font-semibold", children: o }),
1062
1062
  td: ({ children: o }) => /* @__PURE__ */ e("td", { className: "border border-white/20 px-4 py-2 text-white/90", children: o }),
1063
1063
  hr: () => /* @__PURE__ */ e("hr", { className: "border-white/20 my-6" }),
1064
- img: ({ src: o, alt: a }) => /* @__PURE__ */ e("img", { src: o, alt: a, className: "rounded-lg max-w-full h-auto my-4" })
1064
+ img: ({ src: o, alt: s }) => /* @__PURE__ */ e("img", { src: o, alt: s, className: "rounded-lg max-w-full h-auto my-4" })
1065
1065
  },
1066
- children: r
1066
+ children: t
1067
1067
  }
1068
1068
  ) }) }) });
1069
- }, Be = (t) => {
1070
- var s;
1071
- const r = ((s = t.split(".").pop()) == null ? void 0 : s.toLowerCase()) || "";
1069
+ }, Ze = (r) => {
1070
+ var a;
1071
+ const t = ((a = r.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "";
1072
1072
  return {
1073
1073
  js: "javascript",
1074
1074
  jsx: "jsx",
@@ -1104,35 +1104,35 @@ const Re = ({
1104
1104
  conf: "nginx",
1105
1105
  md: "markdown",
1106
1106
  txt: "text"
1107
- }[r] || "text";
1108
- }, He = ({ url: t, fileName: r }) => {
1109
- const [n, s] = b(""), [c, d] = b(!0), [i, o] = b(null), a = Be(r);
1110
- return C(() => {
1107
+ }[t] || "text";
1108
+ }, _e = ({ url: r, fileName: t }) => {
1109
+ const [l, a] = f(""), [n, c] = f(!0), [i, o] = f(null), s = Ze(t);
1110
+ return L(() => {
1111
1111
  (async () => {
1112
1112
  try {
1113
- d(!0), o(null);
1114
- const p = await fetch(t);
1115
- if (!p.ok)
1113
+ c(!0), o(null);
1114
+ const h = await fetch(r);
1115
+ if (!h.ok)
1116
1116
  throw new Error("加载失败");
1117
- const u = await p.text();
1118
- s(u);
1119
- } catch (p) {
1120
- o("文本文件加载失败"), console.error(p);
1117
+ const m = await h.text();
1118
+ a(m);
1119
+ } catch (h) {
1120
+ o("文本文件加载失败"), console.error(h);
1121
1121
  } finally {
1122
- d(!1);
1122
+ c(!1);
1123
1123
  }
1124
1124
  })();
1125
- }, [t]), 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" }) }) : i ? /* @__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: i }) }) }) : /* @__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: [
1126
- /* @__PURE__ */ f("div", { className: "flex items-center gap-3 px-6 py-4 bg-white/5 border-b border-white/10", children: [
1127
- /* @__PURE__ */ e(le, { className: "w-5 h-5 text-white/70" }),
1128
- /* @__PURE__ */ e("span", { className: "text-white font-medium", children: r }),
1129
- /* @__PURE__ */ e("span", { className: "ml-auto text-xs text-white/50 uppercase", children: a })
1125
+ }, [r]), n ? /* @__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" }) }) : i ? /* @__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: i }) }) }) : /* @__PURE__ */ e("div", { className: "w-full h-full overflow-auto p-4 md:p-8", children: /* @__PURE__ */ d("div", { className: "max-w-full md:max-w-6xl mx-auto bg-white/5 backdrop-blur-sm rounded-2xl border border-white/10 overflow-hidden", children: [
1126
+ /* @__PURE__ */ d("div", { className: "flex items-center gap-2 md:gap-3 px-4 py-3 md:px-6 md:py-4 bg-white/5 border-b border-white/10", children: [
1127
+ /* @__PURE__ */ e(pe, { className: "w-4 h-4 md:w-5 md:h-5 text-white/70 flex-shrink-0" }),
1128
+ /* @__PURE__ */ e("span", { className: "text-white font-medium text-sm md:text-base truncate", children: t }),
1129
+ /* @__PURE__ */ e("span", { className: "ml-auto text-xs text-white/50 uppercase flex-shrink-0", children: s })
1130
1130
  ] }),
1131
- /* @__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(
1132
- Z,
1131
+ /* @__PURE__ */ e("div", { className: "text-sm", children: s === "text" ? /* @__PURE__ */ e("pre", { className: "p-6 text-white/90 font-mono whitespace-pre-wrap break-words", children: l }) : /* @__PURE__ */ e(
1132
+ J,
1133
1133
  {
1134
- language: a,
1135
- style: _,
1134
+ language: s,
1135
+ style: K,
1136
1136
  showLineNumbers: !0,
1137
1137
  customStyle: {
1138
1138
  margin: 0,
@@ -1146,55 +1146,55 @@ const Re = ({
1146
1146
  color: "rgba(255, 255, 255, 0.3)",
1147
1147
  userSelect: "none"
1148
1148
  },
1149
- children: n
1149
+ children: l
1150
1150
  }
1151
1151
  ) })
1152
1152
  ] }) });
1153
- }, Ae = ({
1154
- fileName: t,
1155
- fileType: r,
1156
- onDownload: n
1157
- }) => /* @__PURE__ */ f("div", { className: "flex flex-col items-center justify-center w-full h-full p-8 gap-6", children: [
1158
- /* @__PURE__ */ e("div", { className: "w-32 h-32 rounded-full bg-white/10 flex items-center justify-center", children: /* @__PURE__ */ e(ae, { className: "w-16 h-16 text-white/70" }) }),
1159
- /* @__PURE__ */ f("div", { className: "text-white text-center", children: [
1160
- /* @__PURE__ */ e("p", { className: "text-xl font-medium mb-2", children: t }),
1161
- /* @__PURE__ */ f("p", { className: "text-white/70", children: [
1153
+ }, Ge = ({
1154
+ fileName: r,
1155
+ fileType: t,
1156
+ onDownload: l
1157
+ }) => /* @__PURE__ */ d("div", { className: "flex flex-col items-center justify-center w-full h-full p-8 gap-6", children: [
1158
+ /* @__PURE__ */ e("div", { className: "w-32 h-32 rounded-full bg-white/10 flex items-center justify-center", children: /* @__PURE__ */ e(fe, { className: "w-16 h-16 text-white/70" }) }),
1159
+ /* @__PURE__ */ d("div", { className: "text-white text-center", children: [
1160
+ /* @__PURE__ */ e("p", { className: "text-xl font-medium mb-2", children: r }),
1161
+ /* @__PURE__ */ d("p", { className: "text-white/70", children: [
1162
1162
  "不支持预览此文件类型 (",
1163
- r,
1163
+ t,
1164
1164
  ")"
1165
1165
  ] })
1166
1166
  ] }),
1167
- /* @__PURE__ */ f(
1167
+ /* @__PURE__ */ d(
1168
1168
  "button",
1169
1169
  {
1170
- onClick: n,
1170
+ onClick: l,
1171
1171
  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",
1172
1172
  children: [
1173
- /* @__PURE__ */ e(q, { className: "w-5 h-5" }),
1173
+ /* @__PURE__ */ e(Y, { className: "w-5 h-5" }),
1174
1174
  "下载文件查看"
1175
1175
  ]
1176
1176
  }
1177
1177
  )
1178
- ] }), Ue = (t) => {
1179
- var c;
1180
- const r = ((c = t.name.split(".").pop()) == null ? void 0 : c.toLowerCase()) || "", n = t.type.toLowerCase();
1181
- if (n.startsWith("image/") || ["jpg", "jpeg", "png", "gif", "webp", "svg"].includes(r))
1178
+ ] }), Ye = (r) => {
1179
+ var n;
1180
+ const t = ((n = r.name.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "", l = r.type.toLowerCase();
1181
+ if (l.startsWith("image/") || ["jpg", "jpeg", "png", "gif", "webp", "svg"].includes(t))
1182
1182
  return "image";
1183
- if (n.includes("pdf") || r === "pdf")
1183
+ if (l.includes("pdf") || t === "pdf")
1184
1184
  return "pdf";
1185
- if (n.includes("wordprocessingml") || r === "docx")
1185
+ if (l.includes("wordprocessingml") || t === "docx")
1186
1186
  return "docx";
1187
- if (n.includes("spreadsheetml") || r === "xlsx")
1187
+ if (l.includes("spreadsheetml") || t === "xlsx")
1188
1188
  return "xlsx";
1189
- if (n.includes("presentationml") || r === "pptx" || r === "ppt")
1189
+ if (l.includes("presentationml") || t === "pptx" || t === "ppt")
1190
1190
  return "pptx";
1191
- if (n.startsWith("video/") || ["mp4", "webm", "ogg", "ogv", "mov", "avi", "mkv", "m4v", "3gp", "flv"].includes(r))
1191
+ if (l.startsWith("video/") || ["mp4", "webm", "ogg", "ogv", "mov", "avi", "mkv", "m4v", "3gp", "flv"].includes(t))
1192
1192
  return "video";
1193
- if (n.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac", "aac"].includes(r))
1193
+ if (l.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac", "aac"].includes(t))
1194
1194
  return "audio";
1195
- if (r === "md" || r === "markdown")
1195
+ if (t === "md" || t === "markdown")
1196
1196
  return "markdown";
1197
- const s = [
1197
+ const a = [
1198
1198
  "txt",
1199
1199
  "log",
1200
1200
  "csv",
@@ -1231,106 +1231,124 @@ const Re = ({
1231
1231
  "zsh",
1232
1232
  "sql"
1233
1233
  ];
1234
- return n.startsWith("text/") || s.includes(r) ? "text" : "unsupported";
1235
- }, et = ({
1236
- files: t,
1237
- currentIndex: r,
1238
- isOpen: n,
1239
- onClose: s,
1240
- onNavigate: c,
1241
- customRenderers: d = []
1234
+ return l.startsWith("text/") || a.includes(t) ? "text" : "unsupported";
1235
+ }, it = ({
1236
+ files: r,
1237
+ currentIndex: t,
1238
+ isOpen: l,
1239
+ onClose: a,
1240
+ onNavigate: n,
1241
+ customRenderers: c = []
1242
1242
  }) => {
1243
- const [i, o] = b(1), [a, w] = b(0), [p, u] = b(1), [, v] = b(1), h = O(() => Te(t), [t]), l = h[r], x = O(() => l ? d.find((y) => y.test(l)) : null, [l, d]), m = l ? Ue(l) : "unsupported";
1244
- C(() => {
1245
- o(1), w(0), u(1), v(1);
1246
- }, [r]), C(() => {
1247
- if (n) {
1248
- const y = document.body.style.overflow, $ = document.body.style.paddingRight, U = window.innerWidth - document.documentElement.clientWidth;
1249
- return document.body.style.overflow = "hidden", U > 0 && (document.body.style.paddingRight = `${U}px`), () => {
1250
- document.body.style.overflow = y, document.body.style.paddingRight = $;
1243
+ const [i, o] = f(1), [s, w] = f(0), [h, m] = f(1), [, N] = f(1), [x, b] = f(null), [p, y] = f(null), k = 50, j = q(() => Fe(r), [r]), u = j[t], P = q(() => u ? c.find((v) => v.test(u)) : null, [u, c]), C = u ? Ye(u) : "unsupported";
1244
+ L(() => {
1245
+ o(1), w(0), m(1), N(1);
1246
+ }, [t]), L(() => {
1247
+ if (l) {
1248
+ const v = document.body.style.overflow, F = document.body.style.paddingRight, A = window.innerWidth - document.documentElement.clientWidth;
1249
+ return document.body.style.overflow = "hidden", A > 0 && (document.body.style.paddingRight = `${A}px`), () => {
1250
+ document.body.style.overflow = v, document.body.style.paddingRight = F;
1251
1251
  };
1252
1252
  }
1253
- }, [n]), C(() => {
1254
- if (!n) return;
1255
- const y = ($) => {
1256
- $.key === "Escape" ? s() : $.key === "ArrowLeft" && r > 0 ? c == null || c(r - 1) : $.key === "ArrowRight" && r < h.length - 1 && (c == null || c(r + 1));
1253
+ }, [l]), L(() => {
1254
+ if (!l) return;
1255
+ const v = (F) => {
1256
+ F.key === "Escape" ? a() : F.key === "ArrowLeft" && t > 0 ? n == null || n(t - 1) : F.key === "ArrowRight" && t < j.length - 1 && (n == null || n(t + 1));
1257
1257
  };
1258
- return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
1259
- }, [n, r, h.length, s, c]);
1260
- const k = M(() => {
1261
- o((y) => Math.min(y + 0.25, 5));
1258
+ return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
1259
+ }, [l, t, j.length, a, n]);
1260
+ const g = M(() => {
1261
+ o((v) => Math.min(v + 0.25, 5));
1262
+ }, []), S = M(() => {
1263
+ o((v) => Math.max(v - 0.25, 0.5));
1262
1264
  }, []), T = M(() => {
1263
- o((y) => Math.max(y - 0.25, 0.5));
1264
- }, []), L = M(() => {
1265
- w((y) => y + 90);
1266
- }, []), R = M(() => {
1267
- w((y) => y - 90);
1265
+ w((v) => v + 90);
1268
1266
  }, []), z = M(() => {
1267
+ w((v) => v - 90);
1268
+ }, []), D = M(() => {
1269
1269
  o(1), w(0);
1270
- }, []), g = M(() => {
1270
+ }, []), H = M(() => {
1271
1271
  o(1);
1272
- }, []), j = M((y) => {
1273
- o(y);
1274
- }, []), N = M(() => {
1272
+ }, []), Q = M((v) => {
1273
+ o(v);
1274
+ }, []), I = M(() => {
1275
1275
  o(1), w(0);
1276
- }, []), D = M(() => {
1277
- if (!l) return;
1278
- const y = document.createElement("a");
1279
- y.href = l.url, y.download = l.name, y.click();
1280
- }, [l]);
1281
- if (!n || !l) return null;
1282
- const S = m === "image" || m === "pdf", F = m === "image", G = /* @__PURE__ */ e(Y, { children: n && /* @__PURE__ */ e(
1283
- H.div,
1276
+ }, []), X = M(() => {
1277
+ if (!u) return;
1278
+ const v = document.createElement("a");
1279
+ v.href = u.url, v.download = u.name, v.click();
1280
+ }, [u]), ee = M((v) => {
1281
+ y(null), b(v.targetTouches[0].clientX);
1282
+ }, []), te = M((v) => {
1283
+ y(v.targetTouches[0].clientX);
1284
+ }, []), re = M(() => {
1285
+ if (!x || !p) return;
1286
+ const v = x - p, F = v > k, A = v < -k;
1287
+ F && t < j.length - 1 && (n == null || n(t + 1)), A && t > 0 && (n == null || n(t - 1));
1288
+ }, [x, p, k, t, j.length, n]);
1289
+ if (!l || !u) return null;
1290
+ const O = C === "image" || C === "pdf", V = C === "image", oe = /* @__PURE__ */ e(ne, { children: l && /* @__PURE__ */ e(
1291
+ B.div,
1284
1292
  {
1285
1293
  initial: { opacity: 0 },
1286
1294
  animate: { opacity: 1 },
1287
1295
  exit: { opacity: 0 },
1288
1296
  className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-md overflow-hidden",
1289
- onClick: s,
1290
- onWheel: (y) => y.stopPropagation(),
1291
- children: /* @__PURE__ */ f(
1297
+ onClick: a,
1298
+ onWheel: (v) => v.stopPropagation(),
1299
+ children: /* @__PURE__ */ d(
1292
1300
  "div",
1293
1301
  {
1294
1302
  className: "relative w-full h-full flex flex-col overflow-hidden",
1295
- onClick: (y) => y.stopPropagation(),
1303
+ onClick: (v) => v.stopPropagation(),
1296
1304
  children: [
1297
1305
  /* @__PURE__ */ e(
1298
- H.div,
1306
+ B.div,
1299
1307
  {
1300
1308
  initial: { y: -100 },
1301
1309
  animate: { y: 0 },
1302
1310
  exit: { y: -100 },
1303
1311
  className: "absolute top-0 left-0 right-0 z-10 p-4",
1304
- 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: [
1305
- /* @__PURE__ */ f("div", { className: "flex-1 min-w-0", children: [
1306
- /* @__PURE__ */ e("h2", { className: "text-white font-medium text-lg truncate", children: l.name }),
1307
- /* @__PURE__ */ f("p", { className: "text-white/60 text-sm", children: [
1308
- r + 1,
1309
- " / ",
1310
- h.length
1311
- ] })
1312
+ children: /* @__PURE__ */ d("div", { className: "max-w-7xl mx-auto flex flex-col md:flex-row md:items-center md:justify-between bg-black/40 backdrop-blur-xl rounded-2xl px-3 md:px-6 py-3 md:py-4 shadow-2xl border border-white/10 gap-2 md:gap-0", children: [
1313
+ /* @__PURE__ */ d("div", { className: "flex items-center justify-between md:flex-1 md:min-w-0 md:mr-4", children: [
1314
+ /* @__PURE__ */ d("div", { className: "flex-1 min-w-0", children: [
1315
+ /* @__PURE__ */ e("h2", { className: "text-white font-medium text-sm md:text-lg truncate", children: u.name }),
1316
+ /* @__PURE__ */ d("p", { className: "text-white/60 text-xs md:text-sm", children: [
1317
+ t + 1,
1318
+ " / ",
1319
+ j.length
1320
+ ] })
1321
+ ] }),
1322
+ /* @__PURE__ */ e("div", { className: "md:hidden ml-2", children: /* @__PURE__ */ e(
1323
+ E,
1324
+ {
1325
+ icon: /* @__PURE__ */ e(Z, { className: "w-5 h-5" }),
1326
+ label: "关闭",
1327
+ onClick: a
1328
+ }
1329
+ ) })
1312
1330
  ] }),
1313
- /* @__PURE__ */ f("div", { className: "flex items-center gap-2 ml-4", children: [
1314
- S && /* @__PURE__ */ f(W, { children: [
1331
+ /* @__PURE__ */ d("div", { className: "flex items-center gap-1 md:gap-2 overflow-x-auto scrollbar-hide flex-shrink-0", children: [
1332
+ O && /* @__PURE__ */ d($, { children: [
1315
1333
  /* @__PURE__ */ e(
1316
1334
  E,
1317
1335
  {
1318
- icon: /* @__PURE__ */ e(se, { className: "w-5 h-5" }),
1336
+ icon: /* @__PURE__ */ e(xe, { className: "w-5 h-5" }),
1319
1337
  label: "缩小",
1320
- onClick: T,
1338
+ onClick: S,
1321
1339
  disabled: i <= 0.5
1322
1340
  }
1323
1341
  ),
1324
- /* @__PURE__ */ f("span", { className: "text-white/70 text-sm min-w-[4rem] text-center font-medium", children: [
1342
+ /* @__PURE__ */ d("span", { className: "text-white/70 text-sm min-w-[4rem] text-center font-medium", children: [
1325
1343
  Math.round(i * 100),
1326
1344
  "%"
1327
1345
  ] }),
1328
1346
  /* @__PURE__ */ e(
1329
1347
  E,
1330
1348
  {
1331
- icon: /* @__PURE__ */ e(ie, { className: "w-5 h-5" }),
1349
+ icon: /* @__PURE__ */ e(we, { className: "w-5 h-5" }),
1332
1350
  label: "放大",
1333
- onClick: k,
1351
+ onClick: g,
1334
1352
  disabled: i >= 5
1335
1353
  }
1336
1354
  ),
@@ -1338,47 +1356,47 @@ const Re = ({
1338
1356
  /* @__PURE__ */ e(
1339
1357
  E,
1340
1358
  {
1341
- icon: /* @__PURE__ */ e(ce, { className: "w-5 h-5" }),
1359
+ icon: /* @__PURE__ */ e(ge, { className: "w-5 h-5" }),
1342
1360
  label: "适应窗口",
1343
- onClick: z
1361
+ onClick: D
1344
1362
  }
1345
1363
  ),
1346
1364
  /* @__PURE__ */ e(
1347
1365
  E,
1348
1366
  {
1349
- icon: /* @__PURE__ */ e(de, { className: "w-5 h-5" }),
1367
+ icon: /* @__PURE__ */ e(be, { className: "w-5 h-5" }),
1350
1368
  label: "原始尺寸",
1351
- onClick: g
1369
+ onClick: H
1352
1370
  }
1353
1371
  ),
1354
1372
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" })
1355
1373
  ] }),
1356
- F && /* @__PURE__ */ f(W, { children: [
1374
+ V && /* @__PURE__ */ d($, { children: [
1357
1375
  /* @__PURE__ */ e(
1358
1376
  E,
1359
1377
  {
1360
- icon: /* @__PURE__ */ e(me, { className: "w-5 h-5" }),
1378
+ icon: /* @__PURE__ */ e(ve, { className: "w-5 h-5" }),
1361
1379
  label: "向左旋转",
1362
- onClick: R
1380
+ onClick: z
1363
1381
  }
1364
1382
  ),
1365
1383
  /* @__PURE__ */ e(
1366
1384
  E,
1367
1385
  {
1368
- icon: /* @__PURE__ */ e(ue, { className: "w-5 h-5" }),
1386
+ icon: /* @__PURE__ */ e(ye, { className: "w-5 h-5" }),
1369
1387
  label: "向右旋转",
1370
- onClick: L
1388
+ onClick: T
1371
1389
  }
1372
1390
  ),
1373
1391
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" })
1374
1392
  ] }),
1375
- (S || F) && /* @__PURE__ */ f(W, { children: [
1393
+ (O || V) && /* @__PURE__ */ d($, { children: [
1376
1394
  /* @__PURE__ */ e(
1377
1395
  E,
1378
1396
  {
1379
- icon: /* @__PURE__ */ e(he, { className: "w-5 h-5" }),
1397
+ icon: /* @__PURE__ */ e(Ne, { className: "w-5 h-5" }),
1380
1398
  label: "复原",
1381
- onClick: N
1399
+ onClick: I
1382
1400
  }
1383
1401
  ),
1384
1402
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" })
@@ -1386,84 +1404,95 @@ const Re = ({
1386
1404
  /* @__PURE__ */ e(
1387
1405
  E,
1388
1406
  {
1389
- icon: /* @__PURE__ */ e(q, { className: "w-5 h-5" }),
1407
+ icon: /* @__PURE__ */ e(Y, { className: "w-5 h-5" }),
1390
1408
  label: "下载",
1391
- onClick: D
1409
+ onClick: X
1392
1410
  }
1393
1411
  ),
1394
- /* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" }),
1395
- /* @__PURE__ */ e(
1396
- E,
1397
- {
1398
- icon: /* @__PURE__ */ e(pe, { className: "w-5 h-5" }),
1399
- label: "关闭",
1400
- onClick: s
1401
- }
1402
- )
1412
+ /* @__PURE__ */ d("div", { className: "hidden md:flex items-center", children: [
1413
+ /* @__PURE__ */ e("div", { className: "w-px h-6 bg-white/20 mx-2" }),
1414
+ /* @__PURE__ */ e(
1415
+ E,
1416
+ {
1417
+ icon: /* @__PURE__ */ e(Z, { className: "w-5 h-5" }),
1418
+ label: "关闭",
1419
+ onClick: a
1420
+ }
1421
+ )
1422
+ ] })
1403
1423
  ] })
1404
1424
  ] })
1405
1425
  }
1406
1426
  ),
1407
- /* @__PURE__ */ e("div", { className: "flex-1 flex items-center justify-center pt-24 pb-8 overflow-auto", children: x ? (
1408
- // 使用自定义渲染器
1409
- x.render(l)
1410
- ) : /* @__PURE__ */ f(W, { children: [
1411
- m === "image" && /* @__PURE__ */ e(
1412
- Le,
1413
- {
1414
- url: l.url,
1415
- zoom: i,
1416
- rotation: a,
1417
- onZoomChange: j
1418
- }
1419
- ),
1420
- m === "pdf" && /* @__PURE__ */ e(
1421
- Re,
1422
- {
1423
- url: l.url,
1424
- zoom: i,
1425
- currentPage: p,
1426
- onPageChange: u,
1427
- onTotalPagesChange: v
1428
- }
1429
- ),
1430
- m === "docx" && /* @__PURE__ */ e(Se, { url: l.url }),
1431
- m === "xlsx" && /* @__PURE__ */ e(De, { url: l.url }),
1432
- m === "pptx" && /* @__PURE__ */ e(Ee, { url: l.url }),
1433
- m === "video" && /* @__PURE__ */ e(Fe, { url: l.url }),
1434
- m === "audio" && /* @__PURE__ */ e($e, { url: l.url, fileName: l.name }),
1435
- m === "markdown" && /* @__PURE__ */ e(We, { url: l.url }),
1436
- m === "text" && /* @__PURE__ */ e(He, { url: l.url, fileName: l.name }),
1437
- m === "unsupported" && /* @__PURE__ */ e(
1438
- Ae,
1439
- {
1440
- fileName: l.name,
1441
- fileType: l.type,
1442
- onDownload: D
1443
- }
1444
- )
1445
- ] }) }),
1446
- h.length > 1 && /* @__PURE__ */ f(W, { children: [
1447
- r > 0 && /* @__PURE__ */ e(
1448
- H.button,
1427
+ /* @__PURE__ */ e(
1428
+ "div",
1429
+ {
1430
+ className: "flex-1 flex items-center justify-center pt-32 md:pt-24 pb-4 md:pb-8 overflow-auto",
1431
+ onTouchStart: ee,
1432
+ onTouchMove: te,
1433
+ onTouchEnd: re,
1434
+ children: P ? (
1435
+ // 使用自定义渲染器
1436
+ P.render(u)
1437
+ ) : /* @__PURE__ */ d($, { children: [
1438
+ C === "image" && /* @__PURE__ */ e(
1439
+ $e,
1440
+ {
1441
+ url: u.url,
1442
+ zoom: i,
1443
+ rotation: s,
1444
+ onZoomChange: Q
1445
+ }
1446
+ ),
1447
+ C === "pdf" && /* @__PURE__ */ e(
1448
+ Be,
1449
+ {
1450
+ url: u.url,
1451
+ zoom: i,
1452
+ currentPage: h,
1453
+ onPageChange: m,
1454
+ onTotalPagesChange: N
1455
+ }
1456
+ ),
1457
+ C === "docx" && /* @__PURE__ */ e(He, { url: u.url }),
1458
+ C === "xlsx" && /* @__PURE__ */ e(Ae, { url: u.url }),
1459
+ C === "pptx" && /* @__PURE__ */ e(Ue, { url: u.url }),
1460
+ C === "video" && /* @__PURE__ */ e(Oe, { url: u.url }),
1461
+ C === "audio" && /* @__PURE__ */ e(Ve, { url: u.url, fileName: u.name }),
1462
+ C === "markdown" && /* @__PURE__ */ e(qe, { url: u.url }),
1463
+ C === "text" && /* @__PURE__ */ e(_e, { url: u.url, fileName: u.name }),
1464
+ C === "unsupported" && /* @__PURE__ */ e(
1465
+ Ge,
1466
+ {
1467
+ fileName: u.name,
1468
+ fileType: u.type,
1469
+ onDownload: X
1470
+ }
1471
+ )
1472
+ ] })
1473
+ }
1474
+ ),
1475
+ j.length > 1 && /* @__PURE__ */ d($, { children: [
1476
+ t > 0 && /* @__PURE__ */ e(
1477
+ B.button,
1449
1478
  {
1450
1479
  initial: { x: -100, opacity: 0 },
1451
1480
  animate: { x: 0, opacity: 1 },
1452
1481
  exit: { x: -100, opacity: 0 },
1453
- onClick: () => c == null ? void 0 : c(r - 1),
1454
- 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",
1455
- children: /* @__PURE__ */ e(fe, { className: "w-6 h-6" })
1482
+ onClick: () => n == null ? void 0 : n(t - 1),
1483
+ className: "absolute left-2 md:left-4 top-1/2 -translate-y-1/2 w-10 h-10 md:w-12 md: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",
1484
+ children: /* @__PURE__ */ e(ke, { className: "w-5 h-5 md:w-6 md:h-6" })
1456
1485
  }
1457
1486
  ),
1458
- r < h.length - 1 && /* @__PURE__ */ e(
1459
- H.button,
1487
+ t < j.length - 1 && /* @__PURE__ */ e(
1488
+ B.button,
1460
1489
  {
1461
1490
  initial: { x: 100, opacity: 0 },
1462
1491
  animate: { x: 0, opacity: 1 },
1463
1492
  exit: { x: 100, opacity: 0 },
1464
- onClick: () => c == null ? void 0 : c(r + 1),
1465
- 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",
1466
- children: /* @__PURE__ */ e(xe, { className: "w-6 h-6" })
1493
+ onClick: () => n == null ? void 0 : n(t + 1),
1494
+ className: "absolute right-2 md:right-4 top-1/2 -translate-y-1/2 w-10 h-10 md:w-12 md: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",
1495
+ children: /* @__PURE__ */ e(je, { className: "w-5 h-5 md:w-6 md:h-6" })
1467
1496
  }
1468
1497
  )
1469
1498
  ] })
@@ -1472,23 +1501,23 @@ const Re = ({
1472
1501
  )
1473
1502
  }
1474
1503
  ) });
1475
- return I(G, document.body);
1476
- }, E = ({ icon: t, label: r, onClick: n, disabled: s }) => /* @__PURE__ */ e(
1504
+ return le(oe, document.body);
1505
+ }, E = ({ icon: r, label: t, onClick: l, disabled: a }) => /* @__PURE__ */ e(
1477
1506
  "button",
1478
1507
  {
1479
- onClick: n,
1480
- disabled: s,
1481
- title: r,
1482
- className: `p-2 rounded-lg transition-all ${s ? "text-white/30 cursor-not-allowed" : "text-white hover:bg-white/10 active:bg-white/20"}`,
1483
- children: t
1508
+ onClick: l,
1509
+ disabled: a,
1510
+ title: t,
1511
+ className: `p-2 rounded-lg transition-all ${a ? "text-white/30 cursor-not-allowed" : "text-white hover:bg-white/10 active:bg-white/20"}`,
1512
+ children: r
1484
1513
  }
1485
- ), tt = je.version;
1514
+ ), ct = Ee.version;
1486
1515
  export {
1487
- et as FilePreviewModal,
1488
- tt as VERSION,
1489
- Pe as configurePdfjs,
1490
- Ce as normalizeFile,
1491
- Te as normalizeFiles,
1492
- nt as pdfjs
1516
+ it as FilePreviewModal,
1517
+ ct as VERSION,
1518
+ We as configurePdfjs,
1519
+ ze as normalizeFile,
1520
+ Fe as normalizeFiles,
1521
+ ut as pdfjs
1493
1522
  };
1494
1523
  //# sourceMappingURL=index.mjs.map