vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
40 lines (39 loc) • 1.05 kB
JavaScript
import { defineComponent as c, ref as d, watch as l, openBlock as m, createElementBlock as s, toDisplayString as u } from "vue";
import { getFileRenderByFile as f, getFileRenderByUrl as p } from "../../utils/utils.mjs";
const _ = { class: "txt-preview" }, x = /* @__PURE__ */ c({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {}
},
emits: ["rendered", "error"],
setup(o, { emit: a }) {
const n = o, t = a, i = d(null);
return l(
() => n.file,
(r) => {
r && f(r).then((e) => {
i.value = e, t("rendered");
}).catch((e) => {
t("error", e);
});
},
{ immediate: !0 }
), l(
() => n.url,
(r) => {
r && !n.file && p(r).then((e) => {
i.value = e, t("rendered");
}).catch((e) => {
t("error", e);
});
},
{ immediate: !0 }
), (r, e) => (m(), s("div", _, u(i.value), 1));
}
});
export {
x as default
};
//# sourceMappingURL=index.vue.mjs.map