@eternalheart/vue-file-preview 1.3.6 → 1.3.8

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.
Files changed (61) hide show
  1. package/lib/FilePreviewContent.vue.d.ts.map +1 -1
  2. package/lib/FilePreviewEmbed.vue.d.ts.map +1 -1
  3. package/lib/FilePreviewModal.vue.d.ts.map +1 -1
  4. package/lib/chunks/index-5Smm2vx0.mjs +77 -0
  5. package/lib/chunks/index-5Smm2vx0.mjs.map +1 -0
  6. package/lib/chunks/index-BCkcZs4y.mjs +84 -0
  7. package/lib/chunks/index-BCkcZs4y.mjs.map +1 -0
  8. package/lib/chunks/index-BM9FaQUl.mjs +134 -0
  9. package/lib/chunks/index-BM9FaQUl.mjs.map +1 -0
  10. package/lib/chunks/index-BYzQg-jL.mjs +152 -0
  11. package/lib/chunks/index-BYzQg-jL.mjs.map +1 -0
  12. package/lib/chunks/index-BoL1b2w-.mjs +129 -0
  13. package/lib/chunks/index-BoL1b2w-.mjs.map +1 -0
  14. package/lib/chunks/index-Bri7VeRx.mjs +203 -0
  15. package/lib/chunks/index-Bri7VeRx.mjs.map +1 -0
  16. package/lib/chunks/index-C324a7kV.mjs +2017 -0
  17. package/lib/chunks/index-C324a7kV.mjs.map +1 -0
  18. package/lib/chunks/index-C7uOM7XL.mjs +139 -0
  19. package/lib/chunks/index-C7uOM7XL.mjs.map +1 -0
  20. package/lib/chunks/index-CTsscgqY.mjs +136 -0
  21. package/lib/chunks/index-CTsscgqY.mjs.map +1 -0
  22. package/lib/chunks/index-Ch7AEfnk.mjs +116 -0
  23. package/lib/chunks/index-Ch7AEfnk.mjs.map +1 -0
  24. package/lib/chunks/index-D9wf6m37.mjs +249 -0
  25. package/lib/chunks/index-D9wf6m37.mjs.map +1 -0
  26. package/lib/chunks/index-DAEQe-RI.mjs +111 -0
  27. package/lib/chunks/index-DAEQe-RI.mjs.map +1 -0
  28. package/lib/chunks/index-DAo-7spn.mjs +103 -0
  29. package/lib/chunks/index-DAo-7spn.mjs.map +1 -0
  30. package/lib/chunks/index-DXlcF1Dk.mjs +113 -0
  31. package/lib/chunks/index-DXlcF1Dk.mjs.map +1 -0
  32. package/lib/chunks/index-ELyTQZeF.mjs +281 -0
  33. package/lib/chunks/index-ELyTQZeF.mjs.map +1 -0
  34. package/lib/chunks/index-cZn4ih-x.mjs +111 -0
  35. package/lib/chunks/index-cZn4ih-x.mjs.map +1 -0
  36. package/lib/chunks/index-dzB4jd9b.mjs +353 -0
  37. package/lib/chunks/index-dzB4jd9b.mjs.map +1 -0
  38. package/lib/chunks/index-lHlugUBI.mjs +391 -0
  39. package/lib/chunks/index-lHlugUBI.mjs.map +1 -0
  40. package/lib/composables/useResolvedTheme.d.ts +15 -0
  41. package/lib/composables/useResolvedTheme.d.ts.map +1 -0
  42. package/lib/index.cjs +24 -499
  43. package/lib/index.cjs.map +1 -1
  44. package/lib/index.css +1 -1
  45. package/lib/index.mjs +12 -44597
  46. package/lib/index.mjs.map +1 -1
  47. package/lib/renderers/Audio/index.vue.d.ts.map +1 -1
  48. package/lib/renderers/Csv/index.vue.d.ts.map +1 -1
  49. package/lib/renderers/Json/index.vue.d.ts.map +1 -1
  50. package/lib/renderers/Markdown/index.vue.d.ts.map +1 -1
  51. package/lib/renderers/Pptx/index.vue.d.ts.map +1 -1
  52. package/lib/renderers/RendererLoading.vue.d.ts +3 -0
  53. package/lib/renderers/RendererLoading.vue.d.ts.map +1 -0
  54. package/lib/renderers/Text/index.vue.d.ts.map +1 -1
  55. package/lib/renderers/Video/index.vue.d.ts.map +1 -1
  56. package/lib/renderers/Xlsx/index.vue.d.ts.map +1 -1
  57. package/lib/renderers/Xml/index.vue.d.ts.map +1 -1
  58. package/lib/renderers/Zip/index.vue.d.ts.map +1 -1
  59. package/lib/renderers/lazy.d.ts +19 -0
  60. package/lib/renderers/lazy.d.ts.map +1 -0
  61. package/package.json +2 -2
@@ -0,0 +1,281 @@
1
+ import { defineComponent as I, ref as u, computed as S, onMounted as Q, onBeforeUnmount as $, watch as D, openBlock as s, createElementBlock as c, createElementVNode as p, normalizeStyle as R, renderSlot as B, normalizeClass as T, resolveComponent as Y, createVNode as W, unref as C, createBlock as M, resolveDynamicComponent as K, toDisplayString as _, Fragment as F, renderList as O, createCommentVNode as P, defineAsyncComponent as ee, withCtx as N, Teleport as te } from "vue";
2
+ import { _ as V, d as ne, p as le, u as oe, e as H, F as se, v as ae, w as ie, i as re } from "./index-C324a7kV.mjs";
3
+ import { FileImage as fe, FileText as ve, FileCode as de, File as pe, ChevronRight as ue, FolderOpen as ce, Folder as me } from "lucide-vue-next";
4
+ const he = { class: "vfp-flex-1 vfp-min-w-0 vfp-min-h-0 vfp-overflow-hidden" }, we = /* @__PURE__ */ I({
5
+ name: "ResizableSplit",
6
+ __name: "ResizableSplit",
7
+ props: {
8
+ initialLeftWidth: { default: 280 },
9
+ minLeftWidth: { default: 160 },
10
+ maxLeftWidth: { default: 640 },
11
+ minRightWidth: { default: 200 },
12
+ storageKey: {},
13
+ desktopMedia: { default: "(min-width: 768px)" }
14
+ },
15
+ setup(a) {
16
+ const r = a, f = u(null), i = u(
17
+ (() => {
18
+ if (r.storageKey && typeof window < "u") {
19
+ const o = Number(window.localStorage.getItem(r.storageKey));
20
+ if (!isNaN(o) && o > 0) return o;
21
+ }
22
+ return r.initialLeftWidth;
23
+ })()
24
+ ), h = u(!1), g = u(!1);
25
+ let m = null;
26
+ const w = () => {
27
+ m && (g.value = m.matches);
28
+ }, k = S(
29
+ () => g.value ? { width: `${i.value}px` } : void 0
30
+ ), x = (o) => {
31
+ if (!f.value) return;
32
+ const v = f.value.getBoundingClientRect(), d = o.clientX - v.left, z = v.width - r.minRightWidth - 6, U = Math.min(r.maxLeftWidth, z);
33
+ i.value = Math.max(
34
+ r.minLeftWidth,
35
+ Math.min(U, d)
36
+ );
37
+ }, l = () => {
38
+ if (h.value && (h.value = !1, window.removeEventListener("mousemove", x), window.removeEventListener("mouseup", l), document.body.style.cursor = "", document.body.style.userSelect = "", r.storageKey))
39
+ try {
40
+ window.localStorage.setItem(r.storageKey, String(i.value));
41
+ } catch {
42
+ }
43
+ }, e = (o) => {
44
+ o.preventDefault(), h.value = !0, window.addEventListener("mousemove", x), window.addEventListener("mouseup", l), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
45
+ };
46
+ return Q(() => {
47
+ typeof window < "u" && (m = window.matchMedia(r.desktopMedia), w(), m.addEventListener("change", w));
48
+ }), $(() => {
49
+ m && m.removeEventListener("change", w), window.removeEventListener("mousemove", x), window.removeEventListener("mouseup", l), h.value && (document.body.style.cursor = "", document.body.style.userSelect = "");
50
+ }), D(
51
+ () => r.initialLeftWidth,
52
+ (o) => {
53
+ r.storageKey || (i.value = o);
54
+ }
55
+ ), (o, v) => (s(), c("div", {
56
+ ref_key: "containerRef",
57
+ ref: f,
58
+ class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col md:vfp-flex-row vfp-min-h-0 vfp-min-w-0"
59
+ }, [
60
+ p("div", {
61
+ class: "vfp-min-h-0 vfp-min-w-0 vfp-flex-shrink-0 vfp-w-full vfp-max-h-60 md:vfp-h-full md:vfp-max-h-none",
62
+ style: R(k.value)
63
+ }, [
64
+ B(o.$slots, "left", {}, void 0, !0)
65
+ ], 4),
66
+ p("div", {
67
+ role: "separator",
68
+ "aria-orientation": "vertical",
69
+ class: T(["split-divider vfp-hidden md:vfp-block vfp-relative vfp-w-1.5 vfp-flex-shrink-0 vfp-cursor-col-resize vfp-transition-colors", h.value ? "dragging" : ""]),
70
+ onMousedown: e
71
+ }, [...v[0] || (v[0] = [
72
+ p("span", { class: "vfp-absolute vfp-inset-y-0 hit-area" }, null, -1)
73
+ ])], 34),
74
+ p("div", he, [
75
+ B(o.$slots, "right", {}, void 0, !0)
76
+ ])
77
+ ], 512));
78
+ }
79
+ }), xe = /* @__PURE__ */ V(we, [["__scopeId", "data-v-790c366f"]]), ye = { key: 0 }, ge = { class: "vfp-truncate vfp-flex-1 vfp-min-w-0" }, be = { class: "vfp-flex-1 vfp-truncate vfp-min-w-0" }, ke = { class: "vfp-text-xs vfp-text-fg-disabled vfp-flex-shrink-0 vfp-ml-2" }, Le = { name: "ZipTreeItem" }, ze = /* @__PURE__ */ I({
80
+ ...Le,
81
+ props: {
82
+ node: {},
83
+ depth: {},
84
+ selectedPath: {},
85
+ expanded: {}
86
+ },
87
+ emits: ["toggle", "select", "hover", "leave"],
88
+ setup(a, { emit: r }) {
89
+ const f = a, i = r, h = S(() => ({ paddingLeft: `${f.depth * 14 + 10}px` })), g = S(() => f.expanded.has(f.node.path)), m = S(() => f.selectedPath === f.node.path), w = S(() => {
90
+ const l = ne({ name: f.node.name, type: "" });
91
+ return l === "image" ? fe : l === "text" || l === "markdown" || l === "json" || l === "csv" || l === "xml" || l === "subtitle" ? f.node.name.endsWith(".md") || f.node.name.endsWith(".markdown") ? ve : de : pe;
92
+ }), k = (l) => {
93
+ const e = l.currentTarget.getBoundingClientRect();
94
+ i("hover", f.node.name || "/", e);
95
+ }, x = () => i("leave");
96
+ return (l, e) => {
97
+ const o = Y("ZipTreeItem");
98
+ return a.node.isDir ? (s(), c("div", ye, [
99
+ p("button", {
100
+ type: "button",
101
+ class: "tree-row dir-row",
102
+ style: R(h.value),
103
+ onClick: e[0] || (e[0] = (v) => i("toggle", a.node.path)),
104
+ onMouseenter: k,
105
+ onMouseleave: x
106
+ }, [
107
+ W(C(ue), {
108
+ class: T(["vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0 vfp-transition-transform", { "vfp-rotate-90": g.value }])
109
+ }, null, 8, ["class"]),
110
+ (s(), M(K(g.value ? C(ce) : C(me)), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-amber-300/80" })),
111
+ p("span", ge, _(a.node.name || "/"), 1)
112
+ ], 36),
113
+ g.value && a.node.children ? (s(!0), c(F, { key: 0 }, O(a.node.children, (v) => (s(), M(o, {
114
+ key: v.path,
115
+ node: v,
116
+ depth: a.depth + 1,
117
+ "selected-path": a.selectedPath,
118
+ expanded: a.expanded,
119
+ onToggle: e[1] || (e[1] = (d) => i("toggle", d)),
120
+ onSelect: e[2] || (e[2] = (d) => i("select", d)),
121
+ onHover: e[3] || (e[3] = (d, z) => i("hover", d, z)),
122
+ onLeave: e[4] || (e[4] = (d) => i("leave"))
123
+ }, null, 8, ["node", "depth", "selected-path", "expanded"]))), 128)) : P("", !0)
124
+ ])) : (s(), c("button", {
125
+ key: 1,
126
+ type: "button",
127
+ class: T(["tree-row file-row", { selected: m.value }]),
128
+ style: R(h.value),
129
+ onClick: e[5] || (e[5] = (v) => i("select", a.node)),
130
+ onMouseenter: k,
131
+ onMouseleave: x
132
+ }, [
133
+ e[6] || (e[6] = p("span", { class: "vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0" }, null, -1)),
134
+ (s(), M(K(w.value), { class: "vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-fg-tertiary" })),
135
+ p("span", be, _(a.node.name), 1),
136
+ p("span", ke, _(C(le)(a.node.size)), 1)
137
+ ], 38));
138
+ };
139
+ }
140
+ }), Se = /* @__PURE__ */ V(ze, [["__scopeId", "data-v-c8c0f0ee"]]), Ce = {
141
+ key: 0,
142
+ class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
143
+ }, _e = {
144
+ key: 1,
145
+ class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
146
+ }, Ee = { class: "vfp-text-fg-secondary vfp-text-center" }, Me = { class: "vfp-text-lg" }, Re = { class: "vfp-w-full vfp-h-full vfp-overflow-auto" }, $e = { class: "vfp-w-full vfp-h-full vfp-flex vfp-flex-col" }, De = {
147
+ key: 0,
148
+ class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-muted vfp-text-sm vfp-p-6"
149
+ }, Te = {
150
+ key: 1,
151
+ class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center"
152
+ }, We = {
153
+ key: 2,
154
+ class: "vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-secondary"
155
+ }, Fe = {
156
+ key: 3,
157
+ class: "vfp-flex-1 vfp-min-h-0 vfp-overflow-hidden vfp-flex vfp-relative vfp-z-0"
158
+ }, Be = /* @__PURE__ */ I({
159
+ __name: "index",
160
+ props: {
161
+ url: {},
162
+ nestingDepth: { default: 0 }
163
+ },
164
+ emits: ["statsChange"],
165
+ setup(a, { emit: r }) {
166
+ const f = ee(
167
+ () => import("./index-C324a7kV.mjs").then((t) => t.s)
168
+ ), i = a, h = r, { t: g } = oe(), m = u(null), w = u(null), k = u(!0), x = u(null), l = u(/* @__PURE__ */ new Set([""])), e = u(null), o = u(!1), v = u(null), d = u(null), z = () => {
169
+ var t;
170
+ (t = e.value) != null && t.blobUrl && URL.revokeObjectURL(e.value.blobUrl);
171
+ };
172
+ D(() => i.url, async () => {
173
+ z(), e.value = null, k.value = !0, x.value = null;
174
+ try {
175
+ const t = await fetch(i.url);
176
+ if (!t.ok) throw new Error("加载失败");
177
+ const n = await t.arrayBuffer(), y = await se(n), b = ae(y), L = ie(b);
178
+ m.value = y, w.value = L;
179
+ const E = /* @__PURE__ */ new Set([""]);
180
+ if (L.children)
181
+ for (const j of L.children) j.isDir && E.add(j.path);
182
+ l.value = E;
183
+ } catch (t) {
184
+ console.error(t), x.value = g.value("zip.load_failed");
185
+ } finally {
186
+ k.value = !1;
187
+ }
188
+ }, { immediate: !0 }), $(() => {
189
+ z();
190
+ });
191
+ const Z = S(() => {
192
+ if (!w.value) return null;
193
+ let t = 0, n = 0, y = 0;
194
+ const b = (L) => {
195
+ var E;
196
+ L.isDir ? (L.path && n++, (E = L.children) == null || E.forEach(b)) : (t++, y += L.size);
197
+ };
198
+ return b(w.value), { files: t, dirs: n, size: y };
199
+ });
200
+ D(Z, (t) => h("statsChange", t), { immediate: !0 }), $(() => h("statsChange", null));
201
+ const q = (t) => {
202
+ const n = new Set(l.value);
203
+ n.has(t) ? n.delete(t) : n.add(t), l.value = n;
204
+ }, A = (t, n) => {
205
+ d.value = { text: t, x: n.right + 8, y: n.top + n.height / 2 };
206
+ }, X = () => {
207
+ d.value = null;
208
+ }, G = async (t) => {
209
+ if (!(!m.value || t.isDir)) {
210
+ z(), o.value = !0, v.value = null;
211
+ try {
212
+ const n = H(t.name), y = await re(m.value, t.path, n !== "application/octet-stream" ? n : void 0), b = URL.createObjectURL(y);
213
+ e.value = { path: t.path, name: t.name, size: t.size, blobUrl: b };
214
+ } catch (n) {
215
+ console.error(n), v.value = "条目读取失败";
216
+ } finally {
217
+ o.value = !1;
218
+ }
219
+ }
220
+ }, J = S(() => e.value ? [{ name: e.value.name, url: e.value.blobUrl, type: H(e.value.name) }] : []);
221
+ return (t, n) => k.value ? (s(), c("div", Ce, [...n[0] || (n[0] = [
222
+ p("div", { class: "vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)
223
+ ])])) : x.value || !w.value ? (s(), c("div", _e, [
224
+ p("div", Ee, [
225
+ p("p", Me, _(x.value || C(g)("zip.parse_failed")), 1)
226
+ ])
227
+ ])) : (s(), c(F, { key: 2 }, [
228
+ W(xe, {
229
+ "initial-left-width": 280,
230
+ "min-left-width": 180,
231
+ "max-left-width": 560,
232
+ "storage-key": "vfp-zip-split-left"
233
+ }, {
234
+ left: N(() => [
235
+ p("div", Re, [
236
+ (s(!0), c(F, null, O(w.value.children || [], (y) => {
237
+ var b;
238
+ return s(), M(Se, {
239
+ key: y.path,
240
+ node: y,
241
+ depth: 0,
242
+ "selected-path": ((b = e.value) == null ? void 0 : b.path) ?? null,
243
+ expanded: l.value,
244
+ onToggle: q,
245
+ onSelect: G,
246
+ onHover: A,
247
+ onLeave: X
248
+ }, null, 8, ["node", "selected-path", "expanded"]);
249
+ }), 128))
250
+ ])
251
+ ]),
252
+ right: N(() => [
253
+ p("div", $e, [
254
+ e.value ? o.value ? (s(), c("div", Te, [...n[1] || (n[1] = [
255
+ p("div", { class: "vfp-w-8 vfp-h-8 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)
256
+ ])])) : v.value ? (s(), c("div", We, _(v.value), 1)) : (s(), c("div", Fe, [
257
+ W(C(f), {
258
+ mode: "embed",
259
+ files: J.value,
260
+ "current-index": 0,
261
+ "zip-nesting-depth": a.nestingDepth + 1
262
+ }, null, 8, ["files", "zip-nesting-depth"])
263
+ ])) : (s(), c("div", De, " 从左侧选择一个文件以预览 "))
264
+ ])
265
+ ]),
266
+ _: 1
267
+ }),
268
+ (s(), M(te, { to: "body" }, [
269
+ d.value ? (s(), c("div", {
270
+ key: 0,
271
+ class: "vfp-zip-tip",
272
+ style: R({ left: d.value.x + "px", top: d.value.y + "px" })
273
+ }, _(d.value.text), 5)) : P("", !0)
274
+ ]))
275
+ ], 64));
276
+ }
277
+ });
278
+ export {
279
+ Be as default
280
+ };
281
+ //# sourceMappingURL=index-ELyTQZeF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ELyTQZeF.mjs","sources":["../../src/components/ResizableSplit.vue","../../src/renderers/Zip/TreeItem.vue","../../src/renderers/Zip/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, computed, onBeforeUnmount, onMounted, watch } from 'vue';\n\ninterface Props {\n /** 左侧初始宽度(px);传入 storageKey 时会从 localStorage 读取 */\n initialLeftWidth?: number;\n /** 左侧最小宽度(px) */\n minLeftWidth?: number;\n /** 左侧最大宽度(px) */\n maxLeftWidth?: number;\n /** 右侧至少保留的宽度(px) */\n minRightWidth?: number;\n /** localStorage 持久化 key */\n storageKey?: string;\n /** 启用横向拖动的媒体查询 */\n desktopMedia?: string;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n initialLeftWidth: 280,\n minLeftWidth: 160,\n maxLeftWidth: 640,\n minRightWidth: 200,\n desktopMedia: '(min-width: 768px)',\n});\n\ndefineOptions({ name: 'ResizableSplit' });\n\nconst containerRef = ref<HTMLDivElement | null>(null);\nconst leftWidth = ref<number>(\n (() => {\n if (props.storageKey && typeof window !== 'undefined') {\n const saved = Number(window.localStorage.getItem(props.storageKey));\n if (!isNaN(saved) && saved > 0) return saved;\n }\n return props.initialLeftWidth;\n })()\n);\nconst dragging = ref(false);\nconst isDesktop = ref(false);\n\nlet mq: MediaQueryList | null = null;\nconst mqHandler = () => {\n if (mq) isDesktop.value = mq.matches;\n};\n\nconst leftStyle = computed(() =>\n isDesktop.value ? { width: `${leftWidth.value}px` } : undefined\n);\n\nconst onMove = (e: MouseEvent) => {\n if (!containerRef.value) return;\n const rect = containerRef.value.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const cap = rect.width - props.minRightWidth - 6;\n const effectiveMax = Math.min(props.maxLeftWidth, cap);\n leftWidth.value = Math.max(\n props.minLeftWidth,\n Math.min(effectiveMax, x)\n );\n};\n\nconst onUp = () => {\n if (!dragging.value) return;\n dragging.value = false;\n window.removeEventListener('mousemove', onMove);\n window.removeEventListener('mouseup', onUp);\n document.body.style.cursor = '';\n document.body.style.userSelect = '';\n if (props.storageKey) {\n try {\n window.localStorage.setItem(props.storageKey, String(leftWidth.value));\n } catch {\n // ignore\n }\n }\n};\n\nconst onDividerDown = (e: MouseEvent) => {\n e.preventDefault();\n dragging.value = true;\n window.addEventListener('mousemove', onMove);\n window.addEventListener('mouseup', onUp);\n document.body.style.cursor = 'col-resize';\n document.body.style.userSelect = 'none';\n};\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n mq = window.matchMedia(props.desktopMedia);\n mqHandler();\n mq.addEventListener('change', mqHandler);\n }\n});\n\nonBeforeUnmount(() => {\n if (mq) mq.removeEventListener('change', mqHandler);\n window.removeEventListener('mousemove', onMove);\n window.removeEventListener('mouseup', onUp);\n if (dragging.value) {\n document.body.style.cursor = '';\n document.body.style.userSelect = '';\n }\n});\n\nwatch(\n () => props.initialLeftWidth,\n (w) => {\n if (!props.storageKey) leftWidth.value = w;\n }\n);\n</script>\n\n<template>\n <div\n ref=\"containerRef\"\n class=\"vfp-w-full vfp-h-full vfp-flex vfp-flex-col md:vfp-flex-row vfp-min-h-0 vfp-min-w-0\"\n >\n <div\n class=\"vfp-min-h-0 vfp-min-w-0 vfp-flex-shrink-0 vfp-w-full vfp-max-h-60 md:vfp-h-full md:vfp-max-h-none\"\n :style=\"leftStyle\"\n >\n <slot name=\"left\" />\n </div>\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n class=\"split-divider vfp-hidden md:vfp-block vfp-relative vfp-w-1.5 vfp-flex-shrink-0 vfp-cursor-col-resize vfp-transition-colors\"\n :class=\"dragging ? 'dragging' : ''\"\n @mousedown=\"onDividerDown\"\n >\n <span class=\"vfp-absolute vfp-inset-y-0 hit-area\" />\n </div>\n <div class=\"vfp-flex-1 vfp-min-w-0 vfp-min-h-0 vfp-overflow-hidden\">\n <slot name=\"right\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.split-divider {\n background: rgba(255, 255, 255, 0.1);\n}\n.split-divider:hover {\n background: rgba(255, 255, 255, 0.3);\n}\n.split-divider.dragging {\n background: rgba(255, 255, 255, 0.4);\n}\n.hit-area {\n left: -4px;\n right: -4px;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport {\n Folder,\n FolderOpen,\n FileText,\n FileImage,\n FileCode,\n File as FileIcon,\n ChevronRight,\n} from 'lucide-vue-next';\nimport { formatFileSize, getFileType, type ZipTreeNode } from '@eternalheart/file-preview-core';\n\nconst props = defineProps<{\n node: ZipTreeNode;\n depth: number;\n selectedPath: string | null;\n expanded: Set<string>;\n}>();\n\nconst emit = defineEmits<{\n (e: 'toggle', path: string): void;\n (e: 'select', node: ZipTreeNode): void;\n (e: 'hover', text: string, rect: DOMRect): void;\n (e: 'leave'): void;\n}>();\n\nconst padStyle = computed(() => ({ paddingLeft: `${props.depth * 14 + 10}px` }));\nconst isOpen = computed(() => props.expanded.has(props.node.path));\nconst isSelected = computed(() => props.selectedPath === props.node.path);\n\nconst fileIcon = computed(() => {\n const ft = getFileType({ id: '', name: props.node.name, url: '', type: '' });\n if (ft === 'image') return FileImage;\n if (ft === 'text' || ft === 'markdown' || ft === 'json' || ft === 'csv' || ft === 'xml' || ft === 'subtitle') {\n return (props.node.name.endsWith('.md') || props.node.name.endsWith('.markdown')) ? FileText : FileCode;\n }\n return FileIcon;\n});\n\nconst handleEnter = (e: MouseEvent) => {\n const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n emit('hover', props.node.name || '/', rect);\n};\n\nconst handleLeave = () => emit('leave');\n</script>\n\n<template>\n <div v-if=\"node.isDir\">\n <button\n type=\"button\"\n class=\"tree-row dir-row\"\n :style=\"padStyle\"\n @click=\"emit('toggle', node.path)\"\n @mouseenter=\"handleEnter\"\n @mouseleave=\"handleLeave\"\n >\n <ChevronRight\n class=\"vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0 vfp-transition-transform\"\n :class=\"{ 'vfp-rotate-90': isOpen }\"\n />\n <component\n :is=\"isOpen ? FolderOpen : Folder\"\n class=\"vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-amber-300/80\"\n />\n <span class=\"vfp-truncate vfp-flex-1 vfp-min-w-0\">{{ node.name || '/' }}</span>\n </button>\n <template v-if=\"isOpen && node.children\">\n <ZipTreeItem\n v-for=\"child in node.children\"\n :key=\"child.path\"\n :node=\"child\"\n :depth=\"depth + 1\"\n :selected-path=\"selectedPath\"\n :expanded=\"expanded\"\n @toggle=\"(p) => emit('toggle', p)\"\n @select=\"(n) => emit('select', n)\"\n @hover=\"(t, r) => emit('hover', t, r)\"\n @leave=\"emit('leave')\"\n />\n </template>\n </div>\n <button\n v-else\n type=\"button\"\n class=\"tree-row file-row\"\n :class=\"{ selected: isSelected }\"\n :style=\"padStyle\"\n @click=\"emit('select', node)\"\n @mouseenter=\"handleEnter\"\n @mouseleave=\"handleLeave\"\n >\n <span class=\"vfp-w-3.5 vfp-h-3.5 vfp-flex-shrink-0\" />\n <component :is=\"fileIcon\" class=\"vfp-w-4 vfp-h-4 vfp-flex-shrink-0 vfp-text-fg-tertiary\" />\n <span class=\"vfp-flex-1 vfp-truncate vfp-min-w-0\">{{ node.name }}</span>\n <span class=\"vfp-text-xs vfp-text-fg-disabled vfp-flex-shrink-0 vfp-ml-2\">{{ formatFileSize(node.size) }}</span>\n </button>\n</template>\n\n<script lang=\"ts\">\nexport default { name: 'ZipTreeItem' };\n</script>\n\n<style scoped>\n.tree-row {\n width: 100%;\n display: flex;\n align-items: center;\n gap: 0.375rem;\n padding-top: 0.375rem;\n padding-bottom: 0.375rem;\n padding-right: 0.5rem;\n text-align: left;\n font-size: 0.875rem;\n background: transparent;\n border: 0;\n cursor: pointer;\n}\n.dir-row {\n color: var(--fp-fg-secondary);\n}\n.file-row {\n color: var(--fp-fg-secondary);\n}\n.tree-row:hover {\n background: var(--fp-surface-1);\n}\n.file-row.selected {\n background: var(--fp-line);\n color: #fff;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { ref, computed, watch, onBeforeUnmount, defineAsyncComponent } from 'vue';\nimport type JSZip from 'jszip';\nimport {\n loadZip,\n listZipEntries,\n buildZipTree,\n readZipEntryBlob,\n inferMimeType,\n type ZipTreeNode,\n} from '@eternalheart/file-preview-core';\nimport ResizableSplit from '../../components/ResizableSplit.vue';\nimport TreeItem from './TreeItem.vue';\nimport type { ZipToolbarStats } from './toolbar';\nimport { useTranslator } from '../../composables/useTranslator';\n\n// 懒加载 FilePreviewContent 以打破循环依赖\nconst LazyFilePreviewContent = defineAsyncComponent(\n () => import('../../FilePreviewContent.vue')\n);\n\nconst props = withDefaults(defineProps<{\n url: string;\n /** ZIP 嵌套深度(由 FilePreviewContent 传入) */\n nestingDepth?: number;\n}>(), {\n nestingDepth: 0,\n});\n\nconst emit = defineEmits<{\n (e: 'statsChange', stats: ZipToolbarStats | null): void;\n}>();\n\nconst { t } = useTranslator();\n\ninterface SelectedPreview {\n path: string;\n name: string;\n size: number;\n blobUrl: string;\n}\n\ninterface HoverTipState {\n text: string;\n x: number;\n y: number;\n}\n\nconst zip = ref<JSZip | null>(null);\nconst tree = ref<ZipTreeNode | null>(null);\nconst loading = ref(true);\nconst error = ref<string | null>(null);\nconst expanded = ref<Set<string>>(new Set(['']));\nconst selected = ref<SelectedPreview | null>(null);\nconst previewLoading = ref(false);\nconst previewError = ref<string | null>(null);\nconst hoverTip = ref<HoverTipState | null>(null);\n\nconst revokeCurrent = () => {\n if (selected.value?.blobUrl) URL.revokeObjectURL(selected.value.blobUrl);\n};\n\nconst load = async () => {\n revokeCurrent();\n selected.value = null;\n loading.value = true;\n error.value = null;\n try {\n const res = await fetch(props.url);\n if (!res.ok) throw new Error('加载失败');\n const buf = await res.arrayBuffer();\n const z = await loadZip(buf);\n const entries = listZipEntries(z);\n const root = buildZipTree(entries);\n zip.value = z;\n tree.value = root;\n const init = new Set<string>(['']);\n if (root.children) for (const c of root.children) if (c.isDir) init.add(c.path);\n expanded.value = init;\n } catch (err) {\n console.error(err);\n error.value = t.value('zip.load_failed');\n } finally {\n loading.value = false;\n }\n};\n\nwatch(() => props.url, load, { immediate: true });\nonBeforeUnmount(() => { revokeCurrent(); });\n\nconst totalStats = computed<ZipToolbarStats | null>(() => {\n if (!tree.value) return null;\n let files = 0, dirs = 0, size = 0;\n const walk = (n: ZipTreeNode) => {\n if (n.isDir) { if (n.path) dirs++; n.children?.forEach(walk); }\n else { files++; size += n.size; }\n };\n walk(tree.value);\n return { files, dirs, size };\n});\n\nwatch(totalStats, (s) => emit('statsChange', s), { immediate: true });\nonBeforeUnmount(() => emit('statsChange', null));\n\nconst handleToggle = (path: string) => {\n const next = new Set(expanded.value);\n if (next.has(path)) next.delete(path);\n else next.add(path);\n expanded.value = next;\n};\n\nconst handleHover = (text: string, rect: DOMRect) => {\n hoverTip.value = { text, x: rect.right + 8, y: rect.top + rect.height / 2 };\n};\nconst handleLeave = () => { hoverTip.value = null; };\n\nconst handleSelect = async (node: ZipTreeNode) => {\n if (!zip.value || node.isDir) return;\n revokeCurrent();\n previewLoading.value = true;\n previewError.value = null;\n\n try {\n const mime = inferMimeType(node.name);\n const blob = await readZipEntryBlob(zip.value, node.path, mime !== 'application/octet-stream' ? mime : undefined);\n const blobUrl = URL.createObjectURL(blob);\n selected.value = { path: node.path, name: node.name, size: node.size, blobUrl };\n } catch (err) {\n console.error(err);\n previewError.value = '条目读取失败';\n } finally {\n previewLoading.value = false;\n }\n};\n\n/** 为嵌入的 FilePreviewContent 构建 files 数组 */\nconst previewFiles = computed(() => {\n if (!selected.value) return [];\n return [{ name: selected.value.name, url: selected.value.blobUrl, type: inferMimeType(selected.value.name) }];\n});\n</script>\n\n<template>\n <div v-if=\"loading\" class=\"vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full\">\n <div class=\"vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\" />\n </div>\n\n <div v-else-if=\"error || !tree\" class=\"vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full\">\n <div class=\"vfp-text-fg-secondary vfp-text-center\"><p class=\"vfp-text-lg\">{{ error || t('zip.parse_failed') }}</p></div>\n </div>\n\n <template v-else>\n <ResizableSplit\n :initial-left-width=\"280\"\n :min-left-width=\"180\"\n :max-left-width=\"560\"\n storage-key=\"vfp-zip-split-left\"\n >\n <template #left>\n <div class=\"vfp-w-full vfp-h-full vfp-overflow-auto\">\n <TreeItem\n v-for=\"child in tree.children || []\"\n :key=\"child.path\"\n :node=\"child\"\n :depth=\"0\"\n :selected-path=\"selected?.path ?? null\"\n :expanded=\"expanded\"\n @toggle=\"handleToggle\"\n @select=\"handleSelect\"\n @hover=\"handleHover\"\n @leave=\"handleLeave\"\n />\n </div>\n </template>\n\n <template #right>\n <div class=\"vfp-w-full vfp-h-full vfp-flex vfp-flex-col\">\n <div v-if=\"!selected\" class=\"vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-muted vfp-text-sm vfp-p-6\">\n 从左侧选择一个文件以预览\n </div>\n <div v-else-if=\"previewLoading\" class=\"vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center\">\n <div class=\"vfp-w-8 vfp-h-8 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\" />\n </div>\n <div v-else-if=\"previewError\" class=\"vfp-flex-1 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-secondary\">{{ previewError }}</div>\n <template v-else>\n <div class=\"vfp-flex-1 vfp-min-h-0 vfp-overflow-hidden vfp-flex vfp-relative vfp-z-0\">\n <LazyFilePreviewContent\n mode=\"embed\"\n :files=\"previewFiles\"\n :current-index=\"0\"\n :zip-nesting-depth=\"nestingDepth + 1\"\n />\n </div>\n </template>\n </div>\n </template>\n </ResizableSplit>\n\n <!-- 文件名 hover tooltip (teleport 到 body 避免被滚动区裁剪) -->\n <Teleport to=\"body\">\n <div\n v-if=\"hoverTip\"\n class=\"vfp-zip-tip\"\n :style=\"{ left: hoverTip.x + 'px', top: hoverTip.y + 'px' }\"\n >\n {{ hoverTip.text }}\n </div>\n </Teleport>\n </template>\n</template>\n\n<style>\n/* 全局 tooltip(不能 scoped,因 Teleport 到 body) */\n.vfp-zip-tip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n transform: translateY(-50%);\n padding: 4px 8px;\n background: rgba(0, 0, 0, 0.85);\n color: #fff;\n font-size: 12px;\n line-height: 1.5;\n border-radius: 4px;\n white-space: nowrap;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);\n}\n</style>\n"],"names":["props","__props","containerRef","ref","leftWidth","saved","dragging","isDesktop","mq","mqHandler","leftStyle","computed","onMove","e","rect","x","cap","effectiveMax","onUp","onDividerDown","onMounted","onBeforeUnmount","watch","w","_createElementBlock","_createElementVNode","_renderSlot","_ctx","_normalizeClass","_hoisted_1","__default__","emit","__emit","padStyle","isOpen","isSelected","fileIcon","ft","getFileType","FileImage","FileText","FileCode","FileIcon","handleEnter","handleLeave","_cache","$event","_createVNode","_unref","ChevronRight","_createBlock","_resolveDynamicComponent","FolderOpen","Folder","_hoisted_2","_toDisplayString","_openBlock","_Fragment","_renderList","child","_component_ZipTreeItem","p","n","t","r","_hoisted_3","_hoisted_4","LazyFilePreviewContent","defineAsyncComponent","useTranslator","zip","tree","loading","error","expanded","selected","previewLoading","previewError","hoverTip","revokeCurrent","_a","res","buf","z","loadZip","entries","listZipEntries","root","buildZipTree","init","c","err","totalStats","files","dirs","size","walk","s","handleToggle","path","next","handleHover","text","handleSelect","node","mime","inferMimeType","blob","readZipEntryBlob","blobUrl","previewFiles","ResizableSplit","_hoisted_5","TreeItem","_hoisted_6","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_7","_Teleport"],"mappings":";;;;;;;;;;;;;;;AAkBA,UAAMA,IAAQC,GAURC,IAAeC,EAA2B,IAAI,GAC9CC,IAAYD;AAAA,OACf,MAAM;AACL,YAAIH,EAAM,cAAc,OAAO,SAAW,KAAa;AACrD,gBAAMK,IAAQ,OAAO,OAAO,aAAa,QAAQL,EAAM,UAAU,CAAC;AAClE,cAAI,CAAC,MAAMK,CAAK,KAAKA,IAAQ,EAAG,QAAOA;AAAA,QACzC;AACA,eAAOL,EAAM;AAAA,MACf,GAAA;AAAA,IAAG,GAECM,IAAWH,EAAI,EAAK,GACpBI,IAAYJ,EAAI,EAAK;AAE3B,QAAIK,IAA4B;AAChC,UAAMC,IAAY,MAAM;AACtB,MAAID,MAAID,EAAU,QAAQC,EAAG;AAAA,IAC/B,GAEME,IAAYC;AAAA,MAAS,MACzBJ,EAAU,QAAQ,EAAE,OAAO,GAAGH,EAAU,KAAK,SAAS;AAAA,IAAA,GAGlDQ,IAAS,CAACC,MAAkB;AAChC,UAAI,CAACX,EAAa,MAAO;AACzB,YAAMY,IAAOZ,EAAa,MAAM,sBAAA,GAC1Ba,IAAIF,EAAE,UAAUC,EAAK,MACrBE,IAAMF,EAAK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AOzD;AAAA,cAAA;;;;QAKH,SACT,MAkBM;AAAA,UAlBNnB,EAkBM,OAlBNyF,IAkBM;AAAA,YAjBQvC,EAAA,QAGIC,EAAA,SAAhBpB,KAAAhC,EAEM,OAFN2F,IAEM,CAAA,GAAAtE,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA;AAAA,cADJpB,EAA+H,OAAA,EAA1H,OAAM,kHAAA,GAAiH,MAAA,EAAA;AAAA,YAAA,QAE9GoD,EAAA,cAAhBrD,EAA4I,OAA5I4F,IAA4I7D,EAArBsB,EAAA,KAAY,GAAA,CAAA,MAEjIrB,KAAAhC,EAOM,OAPN6F,IAOM;AAAA,cANJtE,EAKEC,EAAAmB,CAAA,GAAA;AAAA,gBAJA,MAAK;AAAA,gBACJ,OAAO2C,EAAA;AAAA,gBACP,iBAAe;AAAA,gBACf,qBAAmB7G,EAAA,eAAY;AAAA,cAAA;wBAbtCuB,EAEM,OAFN8F,IAA4H,gBAE5H;AAAA;;;;YAoBNpE,EAQWqE,IAAA,EARD,IAAG,UAAM;AAAA,QAETzC,EAAA,cADRtD,EAMM,OAAA;AAAA;UAJJ,OAAM;AAAA,UACL,iBAAesD,EAAA,MAAS,IAAC,MAAA,KAAcA,EAAA,MAAS,IAAC,MAAA;AAAA,QAAA,GAE/CvB,EAAAuB,EAAA,MAAS,IAAI,GAAA,CAAA;;;;;"}
@@ -0,0 +1,111 @@
1
+ import { defineComponent as H, ref as x, onMounted as M, watch as S, onBeforeUnmount as j, openBlock as u, createElementBlock as g, createElementVNode as y, toDisplayString as b, createCommentVNode as w, withDirectives as W, vShow as q, nextTick as A } from "vue";
2
+ import { S as F, u as I } from "./index-C324a7kV.mjs";
3
+ import * as D from "pdfjs-dist/build/pdf.mjs";
4
+ const N = {
5
+ key: 0,
6
+ class: "vfp-text-fg-secondary vfp-text-center"
7
+ }, U = { class: "vfp-text-lg" }, G = {
8
+ key: 1,
9
+ class: "vfp-flex vfp-items-center vfp-justify-center vfp-min-h-screen"
10
+ }, J = { class: "pdf-pages vfp-flex vfp-flex-col vfp-gap-4" }, K = {
11
+ key: 2,
12
+ class: "vfp-sticky vfp-bottom-2 md:vfp-bottom-4 vfp-mt-4 md:vfp-mt-8 vfp-bg-surface-nav-hover vfp-backdrop-blur-xl vfp-text-fg-primary vfp-px-4 vfp-py-2 md:vfp-px-6 md:vfp-py-3 vfp-rounded-full vfp-text-xs md:vfp-text-sm vfp-font-medium vfp-shadow-2xl vfp-border vfp-border-line-weak"
13
+ }, X = /* @__PURE__ */ H({
14
+ __name: "index",
15
+ props: {
16
+ url: {},
17
+ zoom: {},
18
+ currentPage: {}
19
+ },
20
+ emits: ["pageChange", "totalPagesChange", "pageWidthChange"],
21
+ setup(C, { emit: R }) {
22
+ F(D);
23
+ const p = C, v = R, { t: V } = I(), l = x(0), i = x(null), r = x(null);
24
+ let n = null;
25
+ const m = [], B = async (e, o, a) => {
26
+ if (!n) return;
27
+ const c = await n.getPage(e), s = c.getViewport({ scale: o }), t = document.createElement("canvas");
28
+ t.width = s.width, t.height = s.height, t.style.maxWidth = "100%", t.style.height = "auto", t.style.borderRadius = "0", t.style.display = "block", t.style.boxShadow = "0 25px 50px -12px rgba(0,0,0,0.25)", t.style.filter = "brightness(0.95) contrast(1.05)";
29
+ const d = t.getContext("2d");
30
+ if (!d) return;
31
+ if (await c.render({ canvasContext: d, viewport: s }).promise, e === 1) {
32
+ const h = c.getViewport({ scale: 1 });
33
+ v("pageWidthChange", h.width);
34
+ }
35
+ a.innerHTML = "", a.appendChild(t);
36
+ const f = document.createElement("div");
37
+ f.textContent = String(e), f.style.cssText = "position:absolute;top:8px;right:8px;background:rgba(0,0,0,0.6);backdrop-filter:blur(4px);color:white;font-size:12px;padding:4px 12px;border-radius:9999px;", a.appendChild(f);
38
+ }, k = async () => {
39
+ if (!n || !r.value) return;
40
+ const e = r.value.querySelector(".pdf-pages");
41
+ if (e) {
42
+ e.innerHTML = "", m.length = 0;
43
+ for (let o = 1; o <= l.value; o++) {
44
+ const a = document.createElement("div");
45
+ a.style.cssText = "position:relative;display:flex;justify-content:center;", e.appendChild(a), m.push(a), await B(o, p.zoom, a);
46
+ }
47
+ }
48
+ }, _ = async () => {
49
+ if (i.value = null, l.value = 0, n) {
50
+ try {
51
+ n.destroy();
52
+ } catch {
53
+ }
54
+ n = null;
55
+ }
56
+ try {
57
+ n = await D.getDocument({ url: p.url }).promise, l.value = n.numPages, v("totalPagesChange", n.numPages), v("pageChange", 1), await A(), await k();
58
+ } catch (e) {
59
+ console.error("PDF 加载错误:", e), i.value = V.value("pdf.load_failed");
60
+ }
61
+ }, P = () => {
62
+ if (!r.value) return;
63
+ const e = r.value, o = e.scrollTop, a = e.clientHeight, c = o + a / 2;
64
+ let s = 1, t = 1 / 0;
65
+ m.forEach((d, f) => {
66
+ const h = f + 1, T = d.getBoundingClientRect(), L = e.getBoundingClientRect(), z = T.top - L.top + T.height / 2 + o, E = Math.abs(z - c);
67
+ E < t && (t = E, s = h);
68
+ }), s !== p.currentPage && v("pageChange", s);
69
+ };
70
+ return M(() => {
71
+ _(), r.value && r.value.addEventListener("scroll", P);
72
+ }), S(
73
+ () => p.url,
74
+ () => {
75
+ _();
76
+ }
77
+ ), S(
78
+ () => p.zoom,
79
+ () => {
80
+ k();
81
+ }
82
+ ), j(() => {
83
+ if (r.value && r.value.removeEventListener("scroll", P), n) {
84
+ try {
85
+ n.destroy();
86
+ } catch {
87
+ }
88
+ n = null;
89
+ }
90
+ }), (e, o) => (u(), g("div", {
91
+ ref_key: "containerRef",
92
+ ref: r,
93
+ class: "vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-4 md:vfp-py-8 vfp-px-2 md:vfp-px-4"
94
+ }, [
95
+ i.value ? (u(), g("div", N, [
96
+ y("p", U, b(i.value), 1)
97
+ ])) : w("", !0),
98
+ !i.value && l.value === 0 ? (u(), g("div", G, [...o[0] || (o[0] = [
99
+ y("div", { class: "vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)
100
+ ])])) : w("", !0),
101
+ W(y("div", J, null, 512), [
102
+ [q, !i.value && l.value > 0]
103
+ ]),
104
+ l.value > 0 ? (u(), g("div", K, " 第 " + b(C.currentPage) + " 页 / 共 " + b(l.value) + " 页 ", 1)) : w("", !0)
105
+ ], 512));
106
+ }
107
+ });
108
+ export {
109
+ X as default
110
+ };
111
+ //# sourceMappingURL=index-cZn4ih-x.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-cZn4ih-x.mjs","sources":["../../src/renderers/Pdf/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';\nimport { configurePdfWorker } from '@eternalheart/file-preview-core';\n// @ts-ignore - pdfjs-dist 类型路径\nimport * as pdfjsLib from 'pdfjs-dist/build/pdf.mjs';\nimport { useTranslator } from '../../composables/useTranslator';\n\n// 在模块加载时配置 PDF.js worker(默认走 CDN)\nconfigurePdfWorker(pdfjsLib);\n\ninterface PdfPageProxy {\n getViewport(opts: { scale: number }): { width: number; height: number };\n render(opts: { canvasContext: CanvasRenderingContext2D; viewport: { width: number; height: number } }): {\n promise: Promise<void>;\n };\n}\n\ninterface PdfDocumentProxy {\n numPages: number;\n getPage(pageNumber: number): Promise<PdfPageProxy>;\n destroy(): void;\n}\n\nconst props = defineProps<{\n url: string;\n zoom: number;\n currentPage: number;\n}>();\n\nconst emit = defineEmits<{\n (e: 'pageChange', page: number): void;\n (e: 'totalPagesChange', total: number): void;\n (e: 'pageWidthChange', width: number): void;\n}>();\n\nconst { t } = useTranslator();\n\nconst numPages = ref(0);\nconst error = ref<string | null>(null);\nconst containerRef = ref<HTMLDivElement | null>(null);\nlet pdfDoc: PdfDocumentProxy | null = null;\nconst pageElements: HTMLDivElement[] = [];\n\nconst renderPage = async (pageNumber: number, scale: number, container: HTMLDivElement) => {\n if (!pdfDoc) return;\n const page = await pdfDoc.getPage(pageNumber);\n const viewport = page.getViewport({ scale });\n\n const canvas = document.createElement('canvas');\n canvas.width = viewport.width;\n canvas.height = viewport.height;\n canvas.style.maxWidth = '100%';\n canvas.style.height = 'auto';\n canvas.style.borderRadius = '0';\n canvas.style.display = 'block';\n canvas.style.boxShadow = '0 25px 50px -12px rgba(0,0,0,0.25)';\n canvas.style.filter = 'brightness(0.95) contrast(1.05)';\n\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n await page.render({ canvasContext: ctx, viewport }).promise;\n\n // 上报第一页原始宽度\n if (pageNumber === 1) {\n const baseViewport = page.getViewport({ scale: 1 });\n emit('pageWidthChange', baseViewport.width);\n }\n\n container.innerHTML = '';\n container.appendChild(canvas);\n\n // 页码标签\n const label = document.createElement('div');\n label.textContent = String(pageNumber);\n label.style.cssText =\n 'position:absolute;top:8px;right:8px;background:rgba(0,0,0,0.6);backdrop-filter:blur(4px);color:white;font-size:12px;padding:4px 12px;border-radius:9999px;';\n container.appendChild(label);\n};\n\nconst renderAll = async () => {\n if (!pdfDoc || !containerRef.value) return;\n const wrapper = containerRef.value.querySelector('.pdf-pages') as HTMLDivElement | null;\n if (!wrapper) return;\n wrapper.innerHTML = '';\n pageElements.length = 0;\n\n for (let i = 1; i <= numPages.value; i++) {\n const pageDiv = document.createElement('div');\n pageDiv.style.cssText = 'position:relative;display:flex;justify-content:center;';\n wrapper.appendChild(pageDiv);\n pageElements.push(pageDiv);\n // eslint-disable-next-line no-await-in-loop\n await renderPage(i, props.zoom, pageDiv);\n }\n};\n\nconst loadPdf = async () => {\n error.value = null;\n numPages.value = 0;\n if (pdfDoc) {\n try {\n pdfDoc.destroy();\n } catch {\n // ignore\n }\n pdfDoc = null;\n }\n\n try {\n const loadingTask = pdfjsLib.getDocument({ url: props.url });\n pdfDoc = (await loadingTask.promise) as PdfDocumentProxy;\n numPages.value = pdfDoc.numPages;\n emit('totalPagesChange', pdfDoc.numPages);\n emit('pageChange', 1);\n await nextTick();\n await renderAll();\n } catch (err) {\n console.error('PDF 加载错误:', err);\n error.value = t.value('pdf.load_failed');\n }\n};\n\nconst handleScroll = () => {\n if (!containerRef.value) return;\n\n const container = containerRef.value;\n const scrollTop = container.scrollTop;\n const containerHeight = container.clientHeight;\n const scrollCenter = scrollTop + containerHeight / 2;\n\n let currentVisiblePage = 1;\n let minDistance = Infinity;\n\n pageElements.forEach((pageEl, idx) => {\n const pageNumber = idx + 1;\n const rect = pageEl.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n const pageCenter = rect.top - containerRect.top + rect.height / 2 + scrollTop;\n const distance = Math.abs(pageCenter - scrollCenter);\n\n if (distance < minDistance) {\n minDistance = distance;\n currentVisiblePage = pageNumber;\n }\n });\n\n if (currentVisiblePage !== props.currentPage) {\n emit('pageChange', currentVisiblePage);\n }\n};\n\nonMounted(() => {\n loadPdf();\n if (containerRef.value) {\n containerRef.value.addEventListener('scroll', handleScroll);\n }\n});\n\nwatch(\n () => props.url,\n () => {\n loadPdf();\n }\n);\n\nwatch(\n () => props.zoom,\n () => {\n renderAll();\n }\n);\n\nonBeforeUnmount(() => {\n if (containerRef.value) {\n containerRef.value.removeEventListener('scroll', handleScroll);\n }\n if (pdfDoc) {\n try {\n pdfDoc.destroy();\n } catch {\n // ignore\n }\n pdfDoc = null;\n }\n});\n</script>\n\n<template>\n <div\n ref=\"containerRef\"\n class=\"vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-4 md:vfp-py-8 vfp-px-2 md:vfp-px-4\"\n >\n <div v-if=\"error\" class=\"vfp-text-fg-secondary vfp-text-center\">\n <p class=\"vfp-text-lg\">{{ error }}</p>\n </div>\n\n <div v-if=\"!error && numPages === 0\" class=\"vfp-flex vfp-items-center vfp-justify-center vfp-min-h-screen\">\n <div\n class=\"vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\"\n />\n </div>\n\n <div v-show=\"!error && numPages > 0\" class=\"pdf-pages vfp-flex vfp-flex-col vfp-gap-4\" />\n\n <div\n v-if=\"numPages > 0\"\n class=\"vfp-sticky vfp-bottom-2 md:vfp-bottom-4 vfp-mt-4 md:vfp-mt-8 vfp-bg-surface-nav-hover vfp-backdrop-blur-xl vfp-text-fg-primary vfp-px-4 vfp-py-2 md:vfp-px-6 md:vfp-py-3 vfp-rounded-full vfp-text-xs md:vfp-text-sm vfp-font-medium vfp-shadow-2xl vfp-border vfp-border-line-weak\"\n >\n 第 {{ currentPage }} 页 / 共 {{ numPages }} 页\n </div>\n </div>\n</template>\n"],"names":["configurePdfWorker","pdfjsLib","props","__props","emit","__emit","t","useTranslator","numPages","ref","error","containerRef","pdfDoc","pageElements","renderPage","pageNumber","scale","container","page","viewport","canvas","ctx","baseViewport","label","renderAll","wrapper","i","pageDiv","loadPdf","nextTick","err","handleScroll","scrollTop","containerHeight","scrollCenter","currentVisiblePage","minDistance","pageEl","idx","rect","containerRect","pageCenter","distance","onMounted","watch","onBeforeUnmount","_createElementBlock","_openBlock","_hoisted_1","_createElementVNode","_hoisted_2","_toDisplayString","_hoisted_3","_cache","_withDirectives","_hoisted_4","_vShow","_hoisted_5"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQAA,IAAAA,EAAmBC,CAAQ;AAe3B,UAAMC,IAAQC,GAMRC,IAAOC,GAMP,EAAE,GAAAC,EAAA,IAAMC,EAAA,GAERC,IAAWC,EAAI,CAAC,GAChBC,IAAQD,EAAmB,IAAI,GAC/BE,IAAeF,EAA2B,IAAI;AACpD,QAAIG,IAAkC;AACtC,UAAMC,IAAiC,CAAA,GAEjCC,IAAa,OAAOC,GAAoBC,GAAeC,MAA8B;AACzF,UAAI,CAACL,EAAQ;AACb,YAAMM,IAAO,MAAMN,EAAO,QAAQG,CAAU,GACtCI,IAAWD,EAAK,YAAY,EAAE,OAAAF,GAAO,GAErCI,IAAS,SAAS,cAAc,QAAQ;AAC9C,MAAAA,EAAO,QAAQ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