images-viewer-vue3
Version:
A lightweight image viewer for Vue3
37 lines (36 loc) • 1.64 kB
JavaScript
import { P as s } from "./utils-constant.ts-DQxBjGsQ.js";
import "./npm-hotkeys-js-CQ2lDUlP.js";
const u = () => {
const e = document.createElement("div");
return e.classList.add(s), e;
}, g = (e) => {
document.body.style.overflow = "hidden", document.body.style.margin = "0px", document.body.style.padding = "0px", document.body.appendChild(e);
}, v = (e) => new Promise((o, t) => {
if (c(e) && e.length > 0) {
const [n, a] = e.reduce((r, i) => (i ? r[0].push(i) : r[1].push(i), r), [[], []]);
a.length && console.warn(`images-viewer-vue3:The image parameter 'images' contains illegal characters:[${JSON.stringify(a)}]`), o({ data: n });
} else o({ data: e });
}), d = () => {
var e = /* @__PURE__ */ new Date(), o = e.getFullYear(), t = e.getMonth() + 1, n = e.getDate(), a = e.getHours(), r = e.getMinutes(), i = e.getSeconds();
return `${o}${t}${n}_${a}${r}${i}`;
}, y = (e, o) => {
fetch(e).then((t) => t.blob()).then((t) => {
var n = document.createElement("a");
n.style.display = "none", document.body.appendChild(n);
var a = window.URL.createObjectURL(t);
n.href = a, n.download = d(), n.click(), window.URL.revokeObjectURL(a), document.body.removeChild(n);
});
}, p = () => {
const e = navigator.userAgent || navigator.vendor || window.opera, o = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(
e.toLowerCase()
);
let t = !1;
return o && (t = !0), ("ontouchstart" in window || navigator.maxTouchPoints > 0) && (t = !0), t;
}, c = (e) => Object.prototype.toString.call(e) === "[object Array]";
export {
v as a,
u as c,
y as d,
p as g,
g as s
};