@eternalheart/vue-file-preview 1.6.4 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/lib/chunks/{index-CNVufPKA.mjs → index-07rgqwSI.mjs} +1 -1
- package/lib/chunks/{index-BjLnlWld.mjs → index-BF0-zECZ.mjs} +44 -45
- package/lib/chunks/{index-BkpKhifq.mjs → index-BHy2oKCa.mjs} +15 -15
- package/lib/chunks/{index-DHAH_W8y.mjs → index-BV8V9hEs.mjs} +26 -26
- package/lib/chunks/index-BnDCjh8a.mjs +320 -0
- package/lib/chunks/{index-CbEYsjU9.mjs → index-C-hfrxhW.mjs} +50 -50
- package/lib/chunks/{index-RshnMles.mjs → index-CUrAAk7J.mjs} +213 -207
- package/lib/chunks/index-CdsYIxSD.mjs +270 -0
- package/lib/chunks/{index-BW6Z1etg.mjs → index-ChMheVNW.mjs} +20 -20
- package/lib/chunks/index-CksNYAz_.mjs +48 -0
- package/lib/chunks/{index-CAM2s3GD.mjs → index-CybXawTx.mjs} +19 -19
- package/lib/chunks/{index-Ck-FSxNL.mjs → index-D656tL42.mjs} +21 -21
- package/lib/chunks/{index-Ccdi178q.mjs → index-DWWV1OKd.mjs} +77 -77
- package/lib/chunks/index-DXqRgna1.mjs +105 -0
- package/lib/chunks/{index-Cyps3Pjb.mjs → index-DcNc3goP.mjs} +131 -129
- package/lib/chunks/index-Dh91eAMV.mjs +329 -0
- package/lib/chunks/{index-DnmsSoFY.mjs → index-DxBxbEDT.mjs} +1 -1
- package/lib/chunks/{index-Df8-y_Ok.mjs → index-hDUlDDey.mjs} +18 -18
- package/lib/chunks/{index-Dl0SQhkc.mjs → index-lDd0gQfG.mjs} +35 -36
- package/lib/chunks/{index-C9ju7INJ.mjs → index-tOax5IQg.mjs} +26 -26
- package/lib/chunks/index-u7QUztr_.mjs +49 -0
- package/lib/chunks/{index-CeCl4UNc.mjs → index-xY2bzsk7.mjs} +3747 -1100
- package/lib/chunks/{useShikiHighlight-D2eoQi-e.mjs → useShikiHighlight-DwEsf_jW.mjs} +5 -5
- package/lib/index.cjs +74 -55
- package/lib/index.css +1 -1
- package/lib/index.mjs +7 -7
- package/lib/renderers/Doc/index.vue.d.ts +9 -0
- package/lib/renderers/Ppt/index.vue.d.ts +9 -0
- package/lib/renderers/lazy.d.ts +2 -0
- package/package.json +2 -2
- package/lib/chunks/index-Bts2l6ss.mjs +0 -300
- package/lib/chunks/index-CyXt4Rjo.mjs +0 -264
- package/lib/chunks/index-DXECkJ55.mjs +0 -106
- package/lib/chunks/index-ntrMGZWG.mjs +0 -466
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { defineComponent as me, ref as p, watch as ue, onMounted as ce, onBeforeUnmount as ve, openBlock as S, createElementBlock as B, createBlock as Me, createCommentVNode as D, createElementVNode as h, normalizeStyle as W, toDisplayString as Ce, unref as K, createVNode as de, h as N } from "vue";
|
|
2
|
+
import { List as Se, ChevronLeft as Ne, ChevronRight as Re, Minimize2 as ze, Maximize2 as Ae, X as Le } from "lucide-vue-next";
|
|
3
|
+
import "foliate-js/view.js";
|
|
4
|
+
import { u as Fe, b as Pe, _ as $e } from "./index-xY2bzsk7.mjs";
|
|
5
|
+
import { _ as He } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
|
|
6
|
+
import { T as Be } from "./base.types-DaftHyg7.mjs";
|
|
7
|
+
const De = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, We = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-z-10"
|
|
10
|
+
}, je = { class: "vfp-flex vfp-items-center vfp-justify-between vfp-px-4 vfp-py-3 vfp-border-b vfp-border-line-weak vfp-flex-shrink-0" }, Oe = { class: "vfp-text-fg-primary vfp-font-medium vfp-text-sm" }, Ue = { class: "vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1" }, he = me({
|
|
11
|
+
name: "MobiTocList",
|
|
12
|
+
props: {
|
|
13
|
+
items: { type: Array, required: !0 },
|
|
14
|
+
activeHref: { type: String, default: "" },
|
|
15
|
+
depth: { type: Number, default: 0 }
|
|
16
|
+
},
|
|
17
|
+
emits: ["select"],
|
|
18
|
+
render() {
|
|
19
|
+
return N(
|
|
20
|
+
"ul",
|
|
21
|
+
{ style: { listStyle: "none", padding: 0, margin: this.depth > 0 ? "0 0 0 16px" : 0 } },
|
|
22
|
+
this.items.map(
|
|
23
|
+
(l, j) => {
|
|
24
|
+
var R, O, U;
|
|
25
|
+
return N("li", { key: `${l.href ?? l.label}-${j}` }, [
|
|
26
|
+
l.href ? N(
|
|
27
|
+
"button",
|
|
28
|
+
{
|
|
29
|
+
onClick: () => this.$emit("select", l.href),
|
|
30
|
+
class: [
|
|
31
|
+
"vfp-w-full vfp-text-left vfp-py-2 vfp-px-3 vfp-text-sm vfp-rounded vfp-transition-all vfp-truncate",
|
|
32
|
+
this.activeHref === l.href ? "vfp-text-fg-primary vfp-bg-surface-3 vfp-font-medium" : "vfp-text-fg-secondary hover:vfp-text-fg-primary hover:vfp-bg-surface-2"
|
|
33
|
+
],
|
|
34
|
+
title: l.label,
|
|
35
|
+
style: "background: none; border: none; cursor: pointer"
|
|
36
|
+
},
|
|
37
|
+
(R = l.label) == null ? void 0 : R.trim()
|
|
38
|
+
) : N(
|
|
39
|
+
"div",
|
|
40
|
+
{ class: "vfp-w-full vfp-py-2 vfp-px-3 vfp-text-sm vfp-text-fg-tertiary vfp-truncate" },
|
|
41
|
+
(O = l.label) == null ? void 0 : O.trim()
|
|
42
|
+
),
|
|
43
|
+
(U = l.subitems) != null && U.length ? N(he, {
|
|
44
|
+
items: l.subitems,
|
|
45
|
+
activeHref: this.activeHref,
|
|
46
|
+
depth: this.depth + 1,
|
|
47
|
+
onSelect: (G) => this.$emit("select", G)
|
|
48
|
+
}) : null
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}), Ge = { name: "MobiRenderer" }, Ve = /* @__PURE__ */ me({
|
|
55
|
+
...Ge,
|
|
56
|
+
props: {
|
|
57
|
+
url: {}
|
|
58
|
+
},
|
|
59
|
+
setup(l, { expose: j }) {
|
|
60
|
+
const R = `
|
|
61
|
+
@namespace epub "http://www.idpf.org/2007/ops";
|
|
62
|
+
html { color-scheme: light; }
|
|
63
|
+
body {
|
|
64
|
+
background: #ffffff !important;
|
|
65
|
+
color: #1a1a1a !important;
|
|
66
|
+
font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important;
|
|
67
|
+
font-size: 16px !important;
|
|
68
|
+
line-height: 2 !important;
|
|
69
|
+
max-width: 100% !important;
|
|
70
|
+
box-sizing: border-box !important;
|
|
71
|
+
word-break: break-word !important;
|
|
72
|
+
overflow-wrap: break-word !important;
|
|
73
|
+
}
|
|
74
|
+
p, li, blockquote, dd { line-height: 2; text-align: justify; }
|
|
75
|
+
p { text-indent: 2em; margin: 0.8em 0; }
|
|
76
|
+
h1 { text-align: center; margin: 1.5em 0 1em; }
|
|
77
|
+
h2 { margin: 1.2em 0 0.8em; }
|
|
78
|
+
h3 { margin: 1em 0 0.6em; }
|
|
79
|
+
img { max-width: 100% !important; height: auto !important; }
|
|
80
|
+
a { color: #2563eb; text-decoration: none; }
|
|
81
|
+
pre { white-space: pre-wrap !important; }
|
|
82
|
+
`, G = async (o) => {
|
|
83
|
+
var c;
|
|
84
|
+
const t = (c = o.next) == null ? void 0 : c.call(o);
|
|
85
|
+
if (!t) return;
|
|
86
|
+
let a;
|
|
87
|
+
try {
|
|
88
|
+
await Promise.race([
|
|
89
|
+
t,
|
|
90
|
+
new Promise((q, L) => {
|
|
91
|
+
a = window.setTimeout(
|
|
92
|
+
() => L(new Error("MOBI initial render timed out")),
|
|
93
|
+
1e4
|
|
94
|
+
);
|
|
95
|
+
})
|
|
96
|
+
]);
|
|
97
|
+
} finally {
|
|
98
|
+
a !== void 0 && window.clearTimeout(a);
|
|
99
|
+
}
|
|
100
|
+
}, z = l, Q = new Be(), { t: d } = Fe(), be = Pe(), V = p(null);
|
|
101
|
+
let e = null, X = 1;
|
|
102
|
+
const b = p(1), _ = p(1), k = p(!1), g = p(null), x = p([]), n = p(!1), T = p(""), u = p(!1);
|
|
103
|
+
ue([b, _, u, n, k, () => x.value.length], () => {
|
|
104
|
+
Q.notify();
|
|
105
|
+
});
|
|
106
|
+
const A = (o, t) => {
|
|
107
|
+
Number.isFinite(t) && t > 0 && (X = t);
|
|
108
|
+
const a = Number.isFinite(o) ? o : 0;
|
|
109
|
+
b.value = Math.max(1, a + 1), _.value = X;
|
|
110
|
+
}, ge = () => {
|
|
111
|
+
e == null || e.prev().catch(() => {
|
|
112
|
+
});
|
|
113
|
+
}, xe = () => {
|
|
114
|
+
e == null || e.next().catch(() => {
|
|
115
|
+
});
|
|
116
|
+
}, ye = () => {
|
|
117
|
+
n.value = !n.value;
|
|
118
|
+
}, we = () => {
|
|
119
|
+
u.value = !u.value, e != null && e.renderer && e.renderer.setAttribute("max-inline-size", u.value ? "9999" : "720");
|
|
120
|
+
}, _e = (o) => {
|
|
121
|
+
T.value = o, n.value = !1, e == null || e.goTo(o).catch(() => {
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
j({
|
|
125
|
+
getToolbarGroups: () => [
|
|
126
|
+
{
|
|
127
|
+
items: [
|
|
128
|
+
{
|
|
129
|
+
type: "button",
|
|
130
|
+
icon: Se,
|
|
131
|
+
tooltip: d.value("toolbar.toc"),
|
|
132
|
+
action: ye,
|
|
133
|
+
disabled: x.value.length === 0,
|
|
134
|
+
active: n.value
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
items: [
|
|
140
|
+
{
|
|
141
|
+
type: "button",
|
|
142
|
+
icon: Ne,
|
|
143
|
+
tooltip: d.value("toolbar.prev_page"),
|
|
144
|
+
action: ge,
|
|
145
|
+
disabled: b.value <= 1
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
content: `${b.value} / ${_.value}`,
|
|
150
|
+
minWidth: "4rem"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: "button",
|
|
154
|
+
icon: Re,
|
|
155
|
+
tooltip: d.value("toolbar.next_page"),
|
|
156
|
+
action: xe,
|
|
157
|
+
disabled: b.value >= _.value
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
items: [
|
|
163
|
+
{
|
|
164
|
+
type: "button",
|
|
165
|
+
icon: u.value ? ze : Ae,
|
|
166
|
+
tooltip: u.value ? d.value("toolbar.normal_width") : d.value("toolbar.full_width"),
|
|
167
|
+
action: we,
|
|
168
|
+
active: u.value
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
onToolbarChange: (o) => Q.subscribe(o)
|
|
174
|
+
});
|
|
175
|
+
const Y = (o) => {
|
|
176
|
+
var t;
|
|
177
|
+
(t = o.filename) != null && t.includes("paginator") && o.preventDefault();
|
|
178
|
+
};
|
|
179
|
+
ce(() => window.addEventListener("error", Y)), ve(() => window.removeEventListener("error", Y));
|
|
180
|
+
const I = async () => {
|
|
181
|
+
var c, q, L;
|
|
182
|
+
const o = V.value;
|
|
183
|
+
if (!o) return;
|
|
184
|
+
k.value = !0, g.value = null, x.value = [], n.value = !1, T.value = "", X = 1, b.value = 1, _.value = 1, o.replaceChildren(), e = null;
|
|
185
|
+
let t = !1;
|
|
186
|
+
const a = /* @__PURE__ */ new Map();
|
|
187
|
+
try {
|
|
188
|
+
const s = document.createElement("foliate-view");
|
|
189
|
+
o.appendChild(s), e = s, s.addEventListener("relocate", (te) => {
|
|
190
|
+
var ae, re, le, ne, ie, se, fe;
|
|
191
|
+
const i = te.detail;
|
|
192
|
+
if (!i) return;
|
|
193
|
+
const oe = ((ae = e == null ? void 0 : e.book) == null ? void 0 : ae.sections.length) ?? 0, r = e == null ? void 0 : e.renderer, F = ((le = (re = r == null ? void 0 : r.getContents) == null ? void 0 : re.call(r)[0]) == null ? void 0 : le.index) ?? -1;
|
|
194
|
+
if (r && typeof r.page == "number" && Number.isFinite(r.page) && typeof r.pages == "number" && Number.isFinite(r.pages) && r.pages > 2 && F >= 0) {
|
|
195
|
+
t = !0;
|
|
196
|
+
const m = r.pages - 2;
|
|
197
|
+
a.set(F, m);
|
|
198
|
+
let y = 0;
|
|
199
|
+
for (let w = 0; w < F; w++)
|
|
200
|
+
y += a.get(w) ?? 0;
|
|
201
|
+
const E = y + Math.min(m, Math.max(1, r.page)), M = (i.fraction ?? 0) >= 0.999;
|
|
202
|
+
let $;
|
|
203
|
+
if (oe === 1)
|
|
204
|
+
$ = m;
|
|
205
|
+
else if (M)
|
|
206
|
+
$ = E;
|
|
207
|
+
else {
|
|
208
|
+
const w = ((ne = e == null ? void 0 : e.book) == null ? void 0 : ne.sections) ?? [], pe = ((ie = w[F]) == null ? void 0 : ie.size) ?? 0, Te = pe > 0 ? m / pe : 0;
|
|
209
|
+
let J = 0;
|
|
210
|
+
for (let C = 0; C < oe; C++)
|
|
211
|
+
if (a.has(C))
|
|
212
|
+
J += a.get(C);
|
|
213
|
+
else {
|
|
214
|
+
const Ee = ((se = w[C]) == null ? void 0 : se.size) ?? 0;
|
|
215
|
+
J += Math.max(1, Math.round(Ee * Te));
|
|
216
|
+
}
|
|
217
|
+
$ = Math.max(E, J);
|
|
218
|
+
}
|
|
219
|
+
A(E - 1, $);
|
|
220
|
+
const H = i.tocItem;
|
|
221
|
+
H != null && H.href && (T.value = H.href);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const v = i.location;
|
|
225
|
+
if (v && typeof v.current == "number" && Number.isFinite(v.current) && typeof v.total == "number" && Number.isFinite(v.total)) {
|
|
226
|
+
t = !0;
|
|
227
|
+
const y = (i.fraction ?? 0) >= 0.999 ? v.current + 1 : v.total;
|
|
228
|
+
A(v.current, y);
|
|
229
|
+
} else {
|
|
230
|
+
const m = ((fe = e == null ? void 0 : e.book) == null ? void 0 : fe.sections) ?? [], y = i.index ?? 0, E = i.fraction ?? 0, M = Math.max(m.length, 1);
|
|
231
|
+
A(Math.round((y + E) / M * M), M);
|
|
232
|
+
}
|
|
233
|
+
const P = i.tocItem;
|
|
234
|
+
P != null && P.href && (T.value = P.href);
|
|
235
|
+
});
|
|
236
|
+
const Z = await be.value(z.url);
|
|
237
|
+
if (!Z.ok) throw new Error(`请求失败: ${Z.status}`);
|
|
238
|
+
const ke = await Z.blob();
|
|
239
|
+
let ee = "book.mobi";
|
|
240
|
+
try {
|
|
241
|
+
const i = new URL(z.url, window.location.href).pathname.split("/").pop();
|
|
242
|
+
i && (ee = decodeURIComponent(i));
|
|
243
|
+
} catch {
|
|
244
|
+
}
|
|
245
|
+
await s.open(new File([ke], ee));
|
|
246
|
+
const f = s.renderer;
|
|
247
|
+
f && (f.setAttribute("animated", ""), f.setAttribute("max-inline-size", "720"), f.setAttribute("margin", "48"), f.setAttribute("gap", "5%"), await G(f), (c = f.setStyles) == null || c.call(f, R)), x.value = ((q = s.book) == null ? void 0 : q.toc) ?? [], k.value = !1, t || A(0, ((L = s.book) == null ? void 0 : L.sections.length) ?? 1);
|
|
248
|
+
} catch (s) {
|
|
249
|
+
console.error("MOBI/AZW3 加载错误:", s), g.value = d.value("mobi.load_failed"), k.value = !1;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
return ce(() => {
|
|
253
|
+
z.url && I();
|
|
254
|
+
}), ue(() => z.url, (o, t) => {
|
|
255
|
+
o && o !== t && I();
|
|
256
|
+
}), ve(() => {
|
|
257
|
+
var o, t, a, c;
|
|
258
|
+
try {
|
|
259
|
+
(o = e == null ? void 0 : e.close) == null || o.call(e);
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
(a = (t = e == null ? void 0 : e.book) == null ? void 0 : t.destroy) == null || a.call(t);
|
|
264
|
+
} catch {
|
|
265
|
+
}
|
|
266
|
+
e = null, (c = V.value) == null || c.replaceChildren();
|
|
267
|
+
}), (o, t) => (S(), B("div", De, [
|
|
268
|
+
g.value ? (S(), Me(He, {
|
|
269
|
+
key: 0,
|
|
270
|
+
message: g.value,
|
|
271
|
+
class: "vfp-absolute vfp-inset-0"
|
|
272
|
+
}, null, 8, ["message"])) : D("", !0),
|
|
273
|
+
k.value && !g.value ? (S(), B("div", We, [...t[2] || (t[2] = [
|
|
274
|
+
h("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)
|
|
275
|
+
])])) : D("", !0),
|
|
276
|
+
x.value.length > 0 ? (S(), B("div", {
|
|
277
|
+
key: 2,
|
|
278
|
+
class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex vfp-transition-opacity vfp-duration-300",
|
|
279
|
+
style: W({ opacity: n.value ? 1 : 0, pointerEvents: n.value ? "auto" : "none" })
|
|
280
|
+
}, [
|
|
281
|
+
h("div", {
|
|
282
|
+
class: "vfp-w-72 vfp-max-w-[80%] vfp-h-full vfp-bg-surface-overlay vfp-backdrop-blur-xl vfp-border-r vfp-border-line-weak vfp-flex vfp-flex-col vfp-shadow-2xl vfp-transition-transform vfp-duration-300",
|
|
283
|
+
style: W({ transform: n.value ? "translateX(0)" : "translateX(-100%)" })
|
|
284
|
+
}, [
|
|
285
|
+
h("div", je, [
|
|
286
|
+
h("span", Oe, Ce(K(d)("toolbar.toc")), 1),
|
|
287
|
+
h("button", {
|
|
288
|
+
class: "toc-close-btn",
|
|
289
|
+
onClick: t[0] || (t[0] = (a) => n.value = !1)
|
|
290
|
+
}, [
|
|
291
|
+
de(K(Le), { class: "vfp-w-4 vfp-h-4" })
|
|
292
|
+
])
|
|
293
|
+
]),
|
|
294
|
+
h("div", Ue, [
|
|
295
|
+
de(K(he), {
|
|
296
|
+
items: x.value,
|
|
297
|
+
"active-href": T.value,
|
|
298
|
+
onSelect: _e
|
|
299
|
+
}, null, 8, ["items", "active-href"])
|
|
300
|
+
])
|
|
301
|
+
], 4),
|
|
302
|
+
h("div", {
|
|
303
|
+
class: "vfp-flex-1 vfp-transition-opacity vfp-duration-300",
|
|
304
|
+
style: W({ background: n.value ? "rgba(0,0,0,0.3)" : "transparent" }),
|
|
305
|
+
onClick: t[1] || (t[1] = (a) => n.value = !1)
|
|
306
|
+
}, null, 4)
|
|
307
|
+
], 4)) : D("", !0),
|
|
308
|
+
g.value ? D("", !0) : (S(), B("div", {
|
|
309
|
+
key: 3,
|
|
310
|
+
ref_key: "hostRef",
|
|
311
|
+
ref: V,
|
|
312
|
+
class: "vfp-h-full vfp-bg-surface-toolbar vfp-shadow-lg",
|
|
313
|
+
style: W({ width: u.value ? "100%" : "794px", maxWidth: "100%", transition: "width 0.3s ease" })
|
|
314
|
+
}, null, 4))
|
|
315
|
+
]));
|
|
316
|
+
}
|
|
317
|
+
}), Ie = /* @__PURE__ */ $e(Ve, [["__scopeId", "data-v-0302202a"]]);
|
|
318
|
+
export {
|
|
319
|
+
Ie as default
|
|
320
|
+
};
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as W, ref as y, onMounted as F, watch as L, onBeforeUnmount as P, openBlock as g, createElementBlock as x, createElementVNode as _, toDisplayString as q, unref as B, createCommentVNode as T, createBlock as A, normalizeStyle as G } from "vue";
|
|
2
2
|
import { init as E } from "pptx-preview";
|
|
3
|
-
import { u as
|
|
4
|
-
import { _ as
|
|
5
|
-
const
|
|
3
|
+
import { u as H, b as I, D as N } from "./index-xY2bzsk7.mjs";
|
|
4
|
+
import { _ as O } from "./RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs";
|
|
5
|
+
const S = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, V = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
8
|
-
},
|
|
8
|
+
}, $ = { class: "vfp-text-center" }, j = { class: "vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, Y = /* @__PURE__ */ W({
|
|
9
9
|
__name: "index",
|
|
10
10
|
props: {
|
|
11
11
|
url: {},
|
|
12
12
|
tiled: { type: Boolean, default: !0 }
|
|
13
13
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const s =
|
|
16
|
-
let l = null, v = null, c = null, p = null, h = { width: 0, height: 0 };
|
|
14
|
+
setup(z, { expose: C }) {
|
|
15
|
+
const s = z, { t: n } = H(), M = I(), a = y(!0), u = y(null), d = y(0), i = y(null);
|
|
16
|
+
let l = null, v = null, c = null, p = null, h = { width: 0, height: 0 }, k = 9 / 16;
|
|
17
17
|
const m = () => {
|
|
18
18
|
var f;
|
|
19
|
-
if (!
|
|
20
|
-
const t =
|
|
21
|
-
return { width:
|
|
22
|
-
},
|
|
23
|
-
if (!(!
|
|
19
|
+
if (!i.value) return { width: 960, height: 540 };
|
|
20
|
+
const t = i.value.clientWidth, e = ((f = i.value.parentElement) == null ? void 0 : f.clientWidth) || 0, r = t > 100 ? t : e > 100 ? e : 300, o = Math.floor(r * k);
|
|
21
|
+
return { width: r, height: o };
|
|
22
|
+
}, R = async () => {
|
|
23
|
+
if (!(!i.value || !c || d.value === 0))
|
|
24
24
|
try {
|
|
25
25
|
if (l)
|
|
26
26
|
try {
|
|
27
27
|
l.destroy();
|
|
28
28
|
} catch {
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
i.value.innerHTML = "";
|
|
31
31
|
const t = m();
|
|
32
|
-
l = E(
|
|
32
|
+
l = E(i.value, {
|
|
33
33
|
width: t.width,
|
|
34
34
|
height: s.tiled ? t.height * d.value : t.height,
|
|
35
35
|
mode: s.tiled ? "list" : "slide"
|
|
36
36
|
}), await l.preview(c);
|
|
37
37
|
} catch {
|
|
38
38
|
}
|
|
39
|
-
},
|
|
40
|
-
if (!
|
|
39
|
+
}, D = async () => {
|
|
40
|
+
if (!i.value) return;
|
|
41
41
|
a.value = !0, u.value = null;
|
|
42
42
|
let t = window.setTimeout(() => {
|
|
43
43
|
u.value = n.value("pptx.timeout"), a.value = !1;
|
|
44
44
|
}, 3e4);
|
|
45
45
|
try {
|
|
46
|
-
const e = await
|
|
46
|
+
const e = await M.value(s.url, {
|
|
47
47
|
mode: "cors",
|
|
48
48
|
credentials: "omit",
|
|
49
49
|
redirect: "follow"
|
|
50
50
|
});
|
|
51
51
|
if (!e.ok)
|
|
52
52
|
throw e.status === 404 ? new Error(n.value("pptx.not_found")) : e.status === 403 ? new Error("无权限访问此文件") : e.status >= 500 ? new Error("服务器错误,请稍后重试") : new Error(`文件加载失败 (${e.status})`);
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
c =
|
|
53
|
+
const r = await e.arrayBuffer();
|
|
54
|
+
if (r.byteLength === 0) throw new Error("文件为空");
|
|
55
|
+
c = r, k = (await N(r)).ratio;
|
|
56
56
|
const o = document.createElement("div");
|
|
57
57
|
o.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden", document.body.appendChild(o);
|
|
58
58
|
try {
|
|
@@ -62,80 +62,80 @@ const N = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
62
62
|
mode: "slide"
|
|
63
63
|
});
|
|
64
64
|
try {
|
|
65
|
-
await f.preview(
|
|
65
|
+
await f.preview(r);
|
|
66
66
|
} catch {
|
|
67
67
|
throw new Error(n.value("pptx.invalid_format"));
|
|
68
68
|
}
|
|
69
69
|
const w = f.slideCount;
|
|
70
70
|
if (!w || w === 0) throw new Error(n.value("pptx.no_pages"));
|
|
71
|
-
f.destroy(), d.value = w,
|
|
72
|
-
const
|
|
73
|
-
l = E(
|
|
74
|
-
width:
|
|
75
|
-
height: s.tiled ?
|
|
71
|
+
f.destroy(), d.value = w, i.value && (i.value.innerHTML = "");
|
|
72
|
+
const b = m();
|
|
73
|
+
l = E(i.value, {
|
|
74
|
+
width: b.width,
|
|
75
|
+
height: s.tiled ? b.height * w : b.height,
|
|
76
76
|
mode: s.tiled ? "list" : "slide"
|
|
77
|
-
}), await l.preview(
|
|
77
|
+
}), await l.preview(r), t !== null && (clearTimeout(t), t = null), a.value = !1;
|
|
78
78
|
} finally {
|
|
79
79
|
document.body.contains(o) && document.body.removeChild(o);
|
|
80
80
|
}
|
|
81
81
|
} catch (e) {
|
|
82
82
|
t !== null && clearTimeout(t);
|
|
83
|
-
let
|
|
84
|
-
e instanceof Error ?
|
|
83
|
+
let r = n.value("pptx.parse_failed");
|
|
84
|
+
e instanceof Error ? r = e.message : typeof e == "string" && (r = e), u.value = r, a.value = !1;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
return
|
|
88
|
-
if (!
|
|
87
|
+
return F(() => {
|
|
88
|
+
if (!i.value) return;
|
|
89
89
|
let t = !0;
|
|
90
90
|
v = new ResizeObserver(() => {
|
|
91
91
|
if (t) {
|
|
92
92
|
t = !1, h = m();
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
const e = m(),
|
|
96
|
-
|
|
97
|
-
l && c &&
|
|
95
|
+
const e = m(), r = Math.abs(h.width - e.width), o = Math.abs(h.height - e.height);
|
|
96
|
+
r < 10 && o < 10 || (h = e, p !== null && clearTimeout(p), p = window.setTimeout(() => {
|
|
97
|
+
l && c && R();
|
|
98
98
|
}, 800));
|
|
99
|
-
}), v.observe(
|
|
100
|
-
requestAnimationFrame(() => requestAnimationFrame(() =>
|
|
99
|
+
}), v.observe(i.value), setTimeout(() => {
|
|
100
|
+
requestAnimationFrame(() => requestAnimationFrame(() => D()));
|
|
101
101
|
}, 150);
|
|
102
|
-
}),
|
|
102
|
+
}), L(
|
|
103
103
|
() => s.url,
|
|
104
104
|
(t) => {
|
|
105
|
-
t &&
|
|
105
|
+
t && D();
|
|
106
106
|
}
|
|
107
|
-
),
|
|
107
|
+
), P(() => {
|
|
108
108
|
if (v && v.disconnect(), p !== null && clearTimeout(p), c = null, d.value = 0, l)
|
|
109
109
|
try {
|
|
110
110
|
l.destroy();
|
|
111
111
|
} catch {
|
|
112
112
|
}
|
|
113
113
|
l = null;
|
|
114
|
-
}),
|
|
114
|
+
}), C({
|
|
115
115
|
getToolbarGroups: () => []
|
|
116
|
-
}), (t, e) => (g(),
|
|
117
|
-
a.value ? (g(),
|
|
118
|
-
_("div",
|
|
116
|
+
}), (t, e) => (g(), x("div", S, [
|
|
117
|
+
a.value ? (g(), x("div", V, [
|
|
118
|
+
_("div", $, [
|
|
119
119
|
e[0] || (e[0] = _("div", { class: "vfp-w-10 vfp-h-10 md:vfp-w-12 md:vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)),
|
|
120
|
-
_("p",
|
|
120
|
+
_("p", j, q(B(n)("pptx.loading")), 1)
|
|
121
121
|
])
|
|
122
122
|
])) : T("", !0),
|
|
123
|
-
u.value && !a.value ? (g(),
|
|
123
|
+
u.value && !a.value ? (g(), A(O, {
|
|
124
124
|
key: 1,
|
|
125
125
|
message: B(n)("pptx.load_failed"),
|
|
126
126
|
detail: u.value,
|
|
127
127
|
class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
128
128
|
}, null, 8, ["message", "detail"])) : T("", !0),
|
|
129
|
-
u.value ? T("", !0) : (g(),
|
|
129
|
+
u.value ? T("", !0) : (g(), x("div", {
|
|
130
130
|
key: 2,
|
|
131
131
|
ref_key: "containerRef",
|
|
132
|
-
ref:
|
|
132
|
+
ref: i,
|
|
133
133
|
class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
|
|
134
|
-
style:
|
|
134
|
+
style: G({ opacity: a.value ? 0 : 1 })
|
|
135
135
|
}, null, 4))
|
|
136
136
|
]));
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
export {
|
|
140
|
-
|
|
140
|
+
Y as default
|
|
141
141
|
};
|