1 |
- import{ae as v,s as W,i as c,fI as w,fJ as _,L as x,fK as b,bg as $,ee as g,av as I,a as R,cD as B,a_ as C,o as P,j as z,y as m,n as d,z as k}from"./index.f9240906.js";import{P as L}from"./index.ab16c1d0.js";import"./index.963f7d97.js";import"./index.e6f3c6c4.js";import"./useSize.3965ca89.js";import"./eagerComputed.938959e2.js";import"./useWindowSizeFn.e05ba499.js";import"./useContentViewHeight.51fb01ea.js";import"./ArrowLeftOutlined.8ef55b3d.js";import"./index.ae5f4215.js";import"./transButton.bc515676.js";const M=Symbol("watermark-dom");function S(n=W(document.body)){const r=b(function(){const t=c(n);if(!t)return;const{clientHeight:e,clientWidth:o}=t;i({height:e,width:o})}),s=M.toString(),l=v(),f=()=>{const t=c(l);l.value=void 0;const e=c(n);!e||(t&&e.removeChild(t),w(e,r))};function y(t){const e=document.createElement("canvas"),o=300,u=240;Object.assign(e,{width:o,height:u});const a=e.getContext("2d");return a&&(a.rotate(-20*Math.PI/120),a.font="15px Vedana",a.fillStyle="rgba(0, 0, 0, 0.15)",a.textAlign="left",a.textBaseline="middle",a.fillText(t,o/20,u)),e.toDataURL("image/png")}function i(t={}){const e=c(l);!e||(g(t.width)&&(e.style.width=`${t.width}px`),g(t.height)&&(e.style.height=`${t.height}px`),g(t.str)&&(e.style.background=`url(${y(t.str)}) left top repeat`))}const p=t=>{if(c(l))return i({str:t}),s;const e=document.createElement("div");l.value=e,e.id=s,e.style.pointerEvents="none",e.style.top="0px",e.style.left="0px",e.style.position="absolute",e.style.zIndex="100000";const o=c(n);if(!o)return s;const{clientHeight:u,clientWidth:a}=o;return i({str:t,width:a,height:u}),o.appendChild(e),s};function h(t){p(t),_(document.documentElement,r),$()&&x(()=>{f()})}return{setWatermark:h,clear:f}}const D=R({components:{CollapseContainer:B,PageWrapper:L},setup(){const n=W(null),{setWatermark:r,clear:s}=S();return{setWatermark:r,clear:s,areaRef:n}}});function E(n,r,s,l,f,y){const i=C("a-button"),p=C("CollapseContainer"),h=C("PageWrapper");return P(),z(h,{title:"\u6C34\u5370\u793A\u4F8B"},{default:m(()=>[d(p,{class:"w-full h-32 bg-white rounded-md",title:"Global WaterMark"},{default:m(()=>[d(i,{type:"primary",class:"mr-2",onClick:r[0]||(r[0]=t=>n.setWatermark("WaterMark Info"))},{default:m(()=>[k(" Create ")]),_:1}),d(i,{color:"error",class:"mr-2",onClick:n.clear},{default:m(()=>[k(" Clear ")]),_:1},8,["onClick"]),d(i,{color:"warning",class:"mr-2",onClick:r[1]||(r[1]=t=>n.setWatermark("WaterMark Info New"))},{default:m(()=>[k(" Reset ")]),_:1})]),_:1})]),_:1})}var O=I(D,[["render",E]]);export{O as default};
|