vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
59 lines (58 loc) • 2.52 kB
JavaScript
import { defineComponent as v, computed as a, onMounted as m, openBlock as l, createElementBlock as s, createElementVNode as r, toDisplayString as f, createCommentVNode as u, createStaticVNode as w } from "vue";
import { getFileType as k, getFileTypeFromUrl as x, getFileNameFromUrl as g } from "../../utils/utils.mjs";
const h = { class: "unknown-preview" }, y = { class: "unknown-preview-icon-wrapper" }, _ = {
key: 0,
class: "unknown-preview-badge"
}, F = ["title"], C = /* @__PURE__ */ v({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {}
},
emits: ["error"],
setup(p, { emit: d }) {
const e = p, c = d, i = a(() => {
if (e.file) {
const t = k(e.file, e.name);
return t ? `.${t}` : "";
}
if (e.url) {
const t = x(e.url);
return t ? `.${t}` : "";
}
return "";
}), o = a(() => e.file && "name" in e.file && e.file.name ? e.file.name : e.name ? e.name : e.url ? g(e.url) : "");
return m(() => {
c("error", new Error(`Unsupported file type: ${i.value}`));
}), (t, n) => (l(), s("div", h, [
r("div", y, [
n[0] || (n[0] = r("svg", {
xmlns: "http://www.w3.org/2000/svg",
width: "48",
height: "48",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "1.5",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}, [
r("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
r("polyline", { points: "14 2 14 8 20 8" })
], -1)),
i.value ? (l(), s("span", _, f(i.value), 1)) : u("", !0)
]),
o.value ? (l(), s("div", {
key: 0,
class: "unknown-preview-name",
title: o.value
}, f(o.value), 9, F)) : u("", !0),
n[1] || (n[1] = w('<div class="unknown-preview-tip" data-v-f16901ff><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-f16901ff><circle cx="12" cy="12" r="10" data-v-f16901ff></circle><line x1="12" y1="8" x2="12" y2="12" data-v-f16901ff></line><line x1="12" y1="16" x2="12.01" y2="16" data-v-f16901ff></line></svg><span data-v-f16901ff>This file type is not supported for preview</span></div>', 1))
]));
}
});
export {
C as default
};
//# sourceMappingURL=index.vue2.mjs.map