index-fefa734d.js
2.53 KB
import{u as s,I as v,k as b,g as x,t as y,d as $,a8 as C,_ as I,a9 as R,aa as f,f as g,E as w}from"./vue-5a35c3f5.js";import{bG as B,bH as M,bI as E,a$ as W,aW as P,_ as S}from"./index.js";import{P as z}from"./index-f532aa07.js";import"./antd-6b087f69.js";import"./useContentViewHeight-d0a5c58e.js";import"./useWindowSizeFn-cc2fb57c.js";import"./onMountedOrActivated-52afb7a7.js";const H=Symbol("watermark-dom"),_=new WeakMap;function L(n=b(document.body)){const a=s(n);if(a&&_.has(a))return _.get(a);const l=E(function(){const t=s(n);if(!t)return;const{clientHeight:e,clientWidth:r}=t;u({height:e,width:r})}),c=H.toString(),i=v(),m=()=>{const t=s(i);i.value=void 0;const e=s(n);e&&(t&&e.removeChild(t),B(e,l))};function d(t){const e=document.createElement("canvas"),r=300,h=240;Object.assign(e,{width:r,height:h});const o=e.getContext("2d");return o&&(o.rotate(-20*Math.PI/120),o.font="15px Vedana",o.fillStyle="rgba(0, 0, 0, 0.15)",o.textAlign="left",o.textBaseline="middle",o.fillText(t,r/20,h)),e.toDataURL("image/png")}function u(t={}){const e=s(i);e&&(W(t.width)&&(e.style.width=`${t.width}px`),W(t.height)&&(e.style.height=`${t.height}px`),W(t.str)&&(e.style.background=`url(${d(t.str)}) left top repeat`))}const k=t=>{if(s(i))return u({str:t}),c;const e=document.createElement("div");i.value=e,e.id=c,e.style.pointerEvents="none",e.style.top="0px",e.style.left="0px",e.style.position="absolute",e.style.zIndex="100000";const r=s(n);if(!r)return c;const{clientHeight:h,clientWidth:o}=r;return u({str:t,width:o,height:h}),r.appendChild(e),_.set(r,{setWatermark:p,clear:m}),c};function p(t){k(t),M(document.documentElement,l),x()&&y(()=>{m()})}return{setWatermark:p,clear:m}}const N=$({components:{CollapseContainer:P,PageWrapper:z},setup(){const n=b(null),{setWatermark:a,clear:l}=L();return{setWatermark:a,clear:l,areaRef:n}}});function T(n,a,l,c,i,m){const d=C("a-button"),u=C("CollapseContainer"),k=C("PageWrapper");return I(),R(k,{title:"水印示例"},{default:f(()=>[g(u,{class:"w-full h-32 bg-white rounded-md",title:"Global WaterMark"},{default:f(()=>[g(d,{type:"primary",class:"mr-2",onClick:a[0]||(a[0]=p=>n.setWatermark("WaterMark Info"))},{default:f(()=>[w(" Create ")]),_:1}),g(d,{color:"error",class:"mr-2",onClick:n.clear},{default:f(()=>[w(" Clear ")]),_:1},8,["onClick"]),g(d,{color:"warning",class:"mr-2",onClick:a[1]||(a[1]=p=>n.setWatermark("WaterMark Info New"))},{default:f(()=>[w(" Reset ")]),_:1})]),_:1})]),_:1})}const O=S(N,[["render",T],["__file","E:/allcode/erp/test7901/order-erp-front/src/views/demo/feat/watermark/index.vue"]]);export{O as default};