邹方成 2a89a1ab9d
Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 39s
feat(admin): 更新前端资源文件及修复相关功能
refactor(service): 修改banner和guild删除逻辑为软删除
fix(service): 修复删除操作使用软删除而非物理删除

build: 添加SQLite测试仓库实现
docs: 新增奖励管理字段拆分和批量抽奖UI改造文档

ci: 更新CI忽略文件
style: 清理无用资源文件
2025-11-19 01:35:55 +08:00

2 lines
6.0 KiB
JavaScript

var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,l=(t,n,a)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[n]=a,u=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&l(e,n,t[n]);if(a)for(var n of a(t))r.call(t,n)&&l(e,n,t[n]);return e},s=(e,a)=>t(e,n(a));import{a2 as i,ak as f,af as c,_ as d,d as v,c as p,aC as m,a as g,o as h,w as x,b,bP as y,e as w,f as $,j as M,g as A,a6 as I,ap as z,A as S,q as k,s as B,k as E,u as O,p as P,z as j,h as N}from"./index-CZ0Lvzl5.js";const _=i({zIndex:{type:Number,default:9},rotate:{type:Number,default:-22},width:Number,height:Number,image:String,content:{type:f([String,Array]),default:"Element Plus"},font:{type:f(Object)},gap:{type:f(Array),default:()=>[100,100]},offset:{type:f(Array)}});const C={left:[0,.5],start:[0,.5],center:[.5,0],right:[1,-.5],end:[1,-.5]};function T(e,t,n=1){const a=document.createElement("canvas"),o=a.getContext("2d"),r=e*n,l=t*n;return a.setAttribute("width",`${r}px`),a.setAttribute("height",`${l}px`),o.save(),[o,a,r,l]}function W(){return function(e,t,n,a,o,r,l,u,s){const[i,f,d,v]=T(a,o,n);if(e instanceof HTMLImageElement)i.drawImage(e,0,0,d,v);else{const{color:t,fontSize:a,fontStyle:l,fontWeight:u,fontFamily:f,textAlign:v,textBaseline:p}=r,m=Number(a)*n;i.font=`${l} normal ${u} ${m}px/${o}px ${f}`,i.fillStyle=t,i.textAlign=v,i.textBaseline=p;const g=c(e)?e:[e];null==g||g.forEach((e,t)=>{const[a,o]=C[v];i.fillText(null!=e?e:"",d*a+s*o,t*(m+3*n))})}const p=Math.PI/180*Number(t),m=Math.max(a,o),[g,h,x]=T(m,m,n);g.translate(x/2,x/2),g.rotate(p),d>0&&v>0&&g.drawImage(f,-d/2,-v/2);let b=0,y=0,w=0,$=0;const M=d/2,A=v/2;[[0-M,0-A],[0+M,0-A],[0+M,0+A],[0-M,0+A]].forEach(([e,t])=>{const[n,a]=function(e,t){return[e*Math.cos(p)-t*Math.sin(p),e*Math.sin(p)+t*Math.cos(p)]}(e,t);b=Math.min(b,n),y=Math.max(y,n),w=Math.min(w,a),$=Math.max($,a)});const I=b+x/2,z=w+x/2,S=y-b,k=$-w,B=l*n,E=u*n,O=2*(S+B),P=k+E,[j,N]=T(O,P);function _(e=0,t=0){j.drawImage(h,I,z,S,k,e,t,S,k)}return _(),_(S+B,-k/2-E/2),_(S+B,+k/2+E/2),[N.toDataURL(),O/n,P/n]}}const D=v({name:"ElWatermark"});const L=z(d(v(s(u({},D),{props:_,setup(e){const t=e,n={position:"relative"},a=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.color)?n:"rgba(0,0,0,.15)"}),o=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.fontSize)?n:16}),r=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.fontWeight)?n:"normal"}),l=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.fontStyle)?n:"normal"}),i=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.fontFamily)?n:"sans-serif"}),f=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.textAlign)?n:"center"}),d=p(()=>{var e,n;return null!=(n=null==(e=t.font)?void 0:e.textBaseline)?n:"hanging"}),v=p(()=>t.gap[0]),z=p(()=>t.gap[1]),S=p(()=>v.value/2),k=p(()=>z.value/2),B=p(()=>{var e,n;return null!=(n=null==(e=t.offset)?void 0:e[0])?n:S.value}),E=p(()=>{var e,n;return null!=(n=null==(e=t.offset)?void 0:e[1])?n:k.value}),O=m(null),P=m(),j=g(!1),N=()=>{P.value&&(P.value.remove(),P.value=void 0)},_=(e,n)=>{var a;O.value&&P.value&&(j.value=!0,P.value.setAttribute("style",function(e){return Object.keys(e).map(t=>`${function(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}(t)}: ${e[t]};`).join(" ")}(s(u({},(()=>{const e={zIndex:t.zIndex,position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",backgroundRepeat:"repeat"};let n=B.value-S.value,a=E.value-k.value;return n>0&&(e.left=`${n}px`,e.width=`calc(100% - ${n}px)`,n=0),a>0&&(e.top=`${a}px`,e.height=`calc(100% - ${a}px)`,a=0),e.backgroundPosition=`${n}px ${a}px`,e})()),{backgroundImage:`url('${e}')`,backgroundSize:`${Math.floor(n)}px`}))),null==(a=O.value)||a.append(P.value),setTimeout(()=>{j.value=!1}))},C=W(),T=()=>{const e=document.createElement("canvas").getContext("2d"),n=t.image,u=t.content,s=t.rotate;if(e){P.value||(P.value=document.createElement("div"));const p=window.devicePixelRatio||1,[m,g,h]=(e=>{let n=120,a=64,r=0;const{image:l,content:u,width:s,height:f,rotate:d}=t;if(!l&&e.measureText){e.font=`${Number(o.value)}px ${i.value}`;const t=c(u)?u:[u];let l=0,s=0;t.forEach(t=>{const{width:n,fontBoundingBoxAscent:a,fontBoundingBoxDescent:o,actualBoundingBoxAscent:r,actualBoundingBoxDescent:u}=e.measureText(t),i=I(a)?r+u:a+o;n>l&&(l=Math.ceil(n)),i>s&&(s=Math.ceil(i))}),n=l,a=s*t.length+3*(t.length-1);const f=Math.PI/180*Number(d);r=Math.ceil(Math.abs(Math.sin(f)*a)/2),n+=r}return[null!=s?s:n,null!=f?f:a,r]})(e),x=e=>{const[t,n]=C(e||"",s,p,m,g,{color:a.value,fontSize:o.value,fontStyle:l.value,fontWeight:r.value,fontFamily:i.value,textAlign:f.value,textBaseline:d.value},v.value,z.value,h);_(t,n)};if(n){const e=new Image;e.onload=()=>{x(e)},e.onerror=()=>{x(u)},e.crossOrigin="anonymous",e.referrerPolicy="no-referrer",e.src=n}else x(u)}};h(()=>{T()}),x(()=>t,()=>{T()},{deep:!0,flush:"post"}),b(()=>{N()});return y(O,e=>{j.value||e.forEach(e=>{((e,t)=>{let n=!1;return e.removedNodes.length&&t&&(n=Array.from(e.removedNodes).includes(t)),"attributes"===e.type&&e.target===t&&(n=!0),n})(e,P.value)&&(N(),T())})},{attributes:!0,subtree:!0,childList:!0}),(e,t)=>($(),w("div",{ref_key:"containerRef",ref:O,style:A([n])},[M(e.$slots,"default")],4))}})),[["__file","watermark.vue"]])),R=v(s(u({},{name:"ArtWatermark"}),{__name:"index",props:{content:{default:S.systemInfo.name},visible:{type:Boolean,default:!1},fontSize:{default:16},fontColor:{default:"rgba(128, 128, 128, 0.2)"},rotate:{default:-22},gapX:{default:100},gapY:{default:100},offsetX:{default:50},offsetY:{default:50},zIndex:{default:3100}},setup(e){const t=k(),{watermarkVisible:n}=B(t);return(t,a)=>{const o=L;return O(n)?($(),w("div",{key:0,class:"fixed left-0 top-0 h-screen w-screen pointer-events-none",style:A({zIndex:e.zIndex})},[P(o,{content:e.content,font:{fontSize:e.fontSize,color:e.fontColor},rotate:e.rotate,gap:[e.gapX,e.gapY],offset:[e.offsetX,e.offsetY]},{default:j(()=>[...a[0]||(a[0]=[N("div",{style:{height:"100vh"}},null,-1)])]),_:1},8,["content","font","rotate","gap","offset"])],4)):E("",!0)}}}));export{R as default};