UNPKG

dk-plus

Version:
34 lines (33 loc) 1.09 kB
import { defineComponent as l, onMounted as s, getCurrentInstance as i } from "vue"; import { dkWatermark as m } from "./index3.js"; const y = /* @__PURE__ */ l({ __name: "watermark", props: m, setup(p) { const t = p, e = { value: t.value, font: t.font, color: t.color, rotate: +t.rotate, opacity: t.opacity, appendToBody: t.appendToBody }, d = (a, r) => { const c = document.createElement("canvas"); c.width = 300, c.height = 200; const n = c.getContext("2d"); if (n) { n.font = e.font, n.fillStyle = e.color, n.rotate(e.rotate * Math.PI / 180), n.fillText(a, 50, 100); const o = document.createElement("div"); o.className = "dk-watermark", o.style.opacity = e.opacity, o && (o.style.backgroundImage = `url(${c.toDataURL("image/png")})`, e.appendToBody ? document.body.appendChild(o) : r.appendChild(o)); } }; return s(() => { const a = i(), r = a && a.proxy && a.proxy.$el.parentElement; r && d(e.value, r); }), () => { }; } }); export { y as default };