vue-files-preview
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
83 lines (82 loc) • 2.93 kB
JavaScript
import { defineComponent as y, ref as t, watch as g, openBlock as k, createElementBlock as x, normalizeStyle as K, createElementVNode as u } from "vue";
import "../../../../node_modules/.pnpm/epubjs@0.3.93/node_modules/epubjs/src/book.mjs";
import "../../../../node_modules/.pnpm/@xmldom_xmldom@0.7.13/node_modules/@xmldom/xmldom/lib/dom.mjs";
import "../../../../node_modules/.pnpm/@xmldom_xmldom@0.7.13/node_modules/@xmldom/xmldom/lib/dom-parser.mjs";
import "../../../../node_modules/.pnpm/epubjs@0.3.93/node_modules/epubjs/src/rendition.mjs";
import "../../../../node_modules/.pnpm/epubjs@0.3.93/node_modules/epubjs/src/contents.mjs";
import "../../../../node_modules/.pnpm/epubjs@0.3.93/node_modules/epubjs/src/layout.mjs";
import P from "../../../../node_modules/.pnpm/epubjs@0.3.93/node_modules/epubjs/src/epub.mjs";
import { getFileRenderByFile as D } from "../../utils/utils.mjs";
import { onKeyStroke as p } from "../../../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.11_typescript@5.4.2_/node_modules/@vueuse/core/index.mjs";
const N = /* @__PURE__ */ y({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {},
width: { default: () => "100%" },
height: { default: () => "100%" }
},
setup(s) {
const a = s, f = t(), r = t(), l = t(1), i = t(), c = t(!1), o = t(), n = t();
function d() {
a.file && D(a.file).then((e) => {
o.value = P(e), n.value = o.value.renderTo("epub-viewer", {
// 滚动模式
width: "100%",
height: "calc(100vh - 80x)",
flow: "scrolled",
allowScriptedContent: !0
}), o.value.ready.then(() => {
f.value = o.value.navigation, r.value = o.value.locations, c.value = !0, i.value = r.value.length(), n.value.display();
});
});
}
g(
() => a.file,
() => {
d();
},
{ immediate: !0 }
);
function m() {
n.value && (n.value.prev(), l.value--, l.value < 1 && (l.value = 1));
}
function w() {
n.value && (n.value.next(), l.value++, l.value > i.value && (l.value = i.value));
}
function h(e) {
e.preventDefault();
}
function b(e) {
e.preventDefault();
}
return p("ArrowLeft", () => {
m();
}), p("ArrowRight", () => {
w();
}), (e, v) => (k(), x("div", {
class: "epub-preview epub-box",
style: K({ width: e.width, height: e.height })
}, [
u("button", {
class: "btn",
style: { display: "none" },
onKeydown: h
}, " 上一页 ", 32),
v[0] || (v[0] = u("div", {
id: "epub-viewer",
class: "epub-viewer"
}, null, -1)),
u("button", {
class: "btn",
style: { display: "none" },
onKeydown: b
}, " 下一页 ", 32)
], 4));
}
});
export {
N as default
};
//# sourceMappingURL=index.vue2.mjs.map