PageSourceSearch

https://shike-web.vercel.app/_nuxt/B4qmIbvR.js

js shike-web.vercel.app collected 2026-10-03 07:44:52 UTC 11,169 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Cs9dESHf.js","./DsqdWQfm.js"])))=>i.map(i=>d[i]);
2import{J as ue,aV as fe,ab as v,B as x,y as t,aD as o,A as k,d as Y,aw as m,aZ as C,aT as I,a0 as P,am as Z,a5 as K,a6 as pe,aP as Q,G,al as r,a4 as ee,q as te}from"./BRmlP7xU.js";import{u as ve}from"./DA4vWbVY.js";const xe={class:"flex flex-col gap-5"},me={key:0},ge={key:1,class:"flex items-center justify-center gap-2 py-8"},be={class:"flex items-center justify-between"},he={class:"text-sm text-slate-600"},we={class:"grid gap-5 lg:grid-cols-[1fr_320px]"},ye={class:"flex flex-col items-center gap-3"},_e={class:"relative inline-block w-full overflow-hidden rounded-xl border border-slate-200/80 bg-slate-50 shadow-sm"},ke={key:0,class:"flex h-96 items-center justify-center"},Ce={key:0,class:"flex items-center gap-3"},Pe=["disabled"],Re={class:"text-sm text-slate-500"},De=["disabled"],Ue={class:"flex flex-col gap-4 rounded-2xl border border-slate-200/80 bg-white/70 p-5"},je={class:"flex flex-col gap-1.5"},Fe={class:"flex flex-col gap-1.5"},Te={class:"grid grid-cols-2 gap-2"},Se=["onClick"],Ve={class:"text-base"},Be={class:"flex flex-col gap-1.5"},Ie={class:"flex items-center justify-between"},Me={class:"text-xs text-slate-400"},Ae={class:"flex flex-col gap-1.5"},Le={class:"flex items-center justify-between"},We={class:"text-xs text-slate-400"},Oe={class:"flex flex-col gap-1.5"},$e={class:"flex items-center justify-between"},ze={class:"text-xs text-slate-400"},Ee={class:"flex flex-col gap-1.5"},He={class:"flex items-center gap-2"},Ye=["onClick"],Ge={key:0,class:"text-xs text-white"},Ne={class:"flex items-center gap-3"},Xe={class:"flex cursor-pointer items-center gap-1.5 text-sm text-slate-600"},qe={class:"flex cursor-pointer items-center gap-1.5 text-sm text-slate-600"},Je=["disabled"],Ze={key:0,class:"h-4 w-4 animate-spin rounded-full border-2 border-white/30 border-t-white"},tt=ue({__name:"ToolsPdfWatermark",setup(Ke){const M=ve(),R=r(null),D=r(null),U=r(0),h=r(1),S=r(!1),V=r(!1),L=r(!1),i=r("机密文件"),u=r(28),f=r("#999999"),_=r(.25),w=r(-35),j=r("tile"),F=r("bold"),y=r(!1),W=r(null),O=r(null),A=r(null);async function se(n){const s=n.target.files?.[0];if(!s||s.type!=="application/pdf"){M.error("请选择 PDF 文件");return}R.value=s,S.value=!0,L.value=!1;try{const l=await s.arrayBuffer();D.value=l,S.value=!1,await ee(),await $(1)}catch(l){console.error("PDF 解析失败:",l),M.error("PDF 解析失败"),R.value=null,D.value=null,S.value=!1}}async function $(n){if(!D.value)return;const e=await te(()=>import("./B75MOh95.js"),[],import.meta.url);e.GlobalWorkerOptions.workerSrc="/pdf.worker.min.js";const s=await e.getDocument({data:D.value.slice(0),cMapUrl:"/pdfjs-cmaps/",cMapPacked:!0}).promise;U.value=s.numPages,h.value=n;const l=await s.getPage(n),a=l.getViewport({scale:1.5});await ee();const c=W.value,d=O.value;if(!c||!d)return;c.width=a.width,c.height=a.height,d.width=a.width,d.height=a.height;const g=c.getContext("2d");await l.render({canvas:null,canvasContext:g,viewport:a}).promise,L.value=!0,N()}function N(){const n=O.value,e=W.value;if(!n||!e)return;if(!i.value){n.getContext("2d")?.clearRect(0,0,n.width,n.height);return}const s=e.width,l=e.height;n.width=s,n.height=l;const a=n.getContext("2d");a.clearRect(0,0,s,l);const c=u.value*1.5;if(a.fillStyle=f.value,a.globalAlpha=_.value,a.font=`${F.value} ${c}px -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif`,a.textAlign="center",a.textBaseline="middle",y.value&&(a.strokeStyle=f.value,a.lineWidth=1),j.value==="tile"){const d=c*8,g=c*4;for(let p=0;p<l+g;p+=g)for(let b=0;b<s+d;b+=d)a.save(),a.translate(b,p),a.rotate(w.value*Math.PI/180),a.fillText(i.value,0,0),y.value&&a.strokeText(i.value,0,0),a.restore()}else j.value==="center"&&(a.save(),a.translate(s/2,l/2),a.rotate(w.value*Math.PI/180),a.fillText(i.value,0,0),y.value&&a.strokeText(i.value,0,0),a.restore())}fe([i,u,f,_,w,j,F,y],N);function le(){h.value>1&&$(h.value-1)}function ae(){h.value<U.value&&$(h.value+1)}function oe(n,e){const s=URL.createObjectURL(n),l=document.createElement("a");l.href=s,l.download=e,l.click(),URL.revokeObjectURL(s)}function ne(){const n=u.value*2,e=n*4,s=document.createElement("canvas");s.width=e,s.height=e;const l=s.getContext("2d");l.clearRect(0,0,e,e),l.fillStyle=f.value,l.globalAlpha=_.value,l.font=`${F.value} ${n}px -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif`,l.textAlign="center",l.textBaseline="middle",l.save(),l.translate(e/2,e/2),l.rotate(w.value*Math.PI/180),l.fillText(i.value,0,0),y.value&&(l.strokeStyle=f.value,l.lineWidth=2,l.strokeText(i.value,0,0)),l.restore(
2);const c=s.toDataURL("image/png").split(",")[1],d=atob(c),g=new Uint8Array(d.length);for(let p=0;p<d.length;p++)g[p]=d.charCodeAt(p);return g.buffer}async function re(){if(!(!D.value||!i.value)){V.value=!0;try{const{PDFDocument:n}=await te(async()=>{const{PDFDocument:b}=await import("./Cs9dESHf.js");return{PDFDocument:b}},__vite__mapDeps([0,1]),import.meta.url),e=await n.load(D.value.slice(0)),s=ne(),l=await e.embedPng(s),a=l.scale(1),c=e.getPages();for(const b of c){const{width:X,height:q}=b.getSize();if(j.value==="tile"){const T=u.value*8,B=u.value*4,z=u.value*2.5,J=a.height/a.width*z;for(let E=0;E<q+B;E+=B)for(let H=0;H<X+T;H+=T)b.drawImage(l,{x:H-z/2,y:E-J/2,width:z,height:J})}else{const T=u.value*4,B=a.height/a.width*T;b.drawImage(l,{x:(X-T)/2,y:(q-B)/2,width:T,height:B})}}const d=await e.save(),g=new Blob([d],{type:"application/pdf"}),p=R.value?.name.replace(/\.pdf$/i,"")||"watermarked";oe(g,`${p}_水印.pdf`),M.success("导出完成,已开始下载")}catch(n){console.error("导出失败:",n),M.error("导出失败")}finally{V.value=!1}}}function ie(){A.value&&(A.value.value=""),A.value?.click()}const ce=[{key:"tile",label:"平铺",icon:"⊞"},{key:"center",label:"居中",icon:"◎"}],de=["#999999","#cccccc","#ff4444","#ff8800","#3366ff","#33cc66","#9933cc"];return(n,e)=>(v(),x("div",xe,[t("input",{id:"pdf-watermark-input",ref_key:"fileInputRef",ref:A,type:"file",accept:"application/pdf",class:"hidden",onChange:se},null,544),o(R)?k("",!0):(v(),x("div",me,[...e[7]||(e[7]=[t("label",{for:"pdf-watermark-input",class:"flex cursor-pointer flex-col items-center justify-center gap-3 rounded-2xl border-2 border-dashed border-slate-300 bg-white/70 p-8 text-center transition-colors hover:border-teal-400 hover:bg-teal-50/30"},[t("div",{class:"text-4xl"},"💧"),t("div",{class:"text-sm font-medium text-slate-700"},"点击上传 PDF 文件"),t("div",{class:"text-xs text-slate-400"},"支持任意大小的 PDF")],-1)])])),o(S)?(v(),x("div",ge,[...e[8]||(e[8]=[t("div",{class:"h-5 w-5 animate-spin rounded-full border-2 border-teal-500 border-t-transparent"},null,-1),t("span",{class:"text-sm text-slate-500"},"解析中...",-1)])])):k("",!0),o(R)&&!o(S)?(v(),x(Y,{key:2},[t("div",be,[t("span",he,m(o(R).name)+" · 共 "+m(o(U))+" 页",1),t("button",{class:"rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs text-slate-600 transition-colors hover:border-teal-300 hover:bg-teal-50 hover:text-teal-700",onClick:ie}," 重新选择 ")]),t("div",we,[t("div",ye,[t("div",_e,[t("canvas",{ref_key:"pdfCanvasRef",ref:W,class:"block w-full"},null,512),t("canvas",{ref_key:"overlayCanvasRef",ref:O,class:"pointer-events-none absolute top-0 left-0 h-full w-full"},null,512),o(L)?k("",!0):(v(),x("div",ke,[...e[9]||(e[9]=[t("div",{class:"text-sm text-slate-400"},"加载预览中...",-1)])]))]),o(U)>1?(v(),x("div",Ce,[t("button",{class:"rounded-lg border border-slate-200 px-3 py-1 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-40",disabled:o(h)<=1,onClick:le}," 上一页 ",8,Pe),t("span",Re,m(o(h))+" / "+m(o(U)),1),t("button",{class:"rounded-lg border border-slate-200 px-3 py-1 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-40",disabled:o(h)>=o(U),onClick:ae}," 下一页 ",8,De)])):k("",!0)]),t("div",Ue,[t("div",je,[e[10]||(e[10]=t("label",{class:"text-xs font-medium text-slate-500"},"水印文字",-1)),C(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>P(i)?i.value=s:null),type:"text",placeholder:"输入水印内容",class:"rounded-lg border border-slate-200 px-3 py-2 text-sm focus:border-teal-400 focus:outline-none focus:ring-1 focus:ring-teal-400"},null,512),[[I,o(i)]])]),t("div",Fe,[e[11]||(e[11]=t("label",{class:"text-xs font-medium text-slate-500"},"水印位置",-1)),t("div",Te,[(v(),x(Y,null,Z(ce,s=>t("button",{key:s.key,class:K(["flex items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-sm transition-colors",o(j)===s.key?"border-teal-500 bg-teal-50 text-teal-700":"border-slate-200 text-slate-600 hover:border-teal-300 hover:bg-slate-50"]),onClick:l=>j.value=s.key},[t("span",Ve,m(s.icon),1),t("span",null,m(s.label),1)],10,Se)),64))])]),t("div",Be,[t("div",Ie,[e[12]||(e[12]=t("label",{class:"text-xs font-medium text-slate-500"},"字号",-1)),t("span",Me,m(o(u))+"px",1)]),C(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>P(u)?u.value=s:null),type:"range",min:"12",max:"72",class:"w-full accent-teal-500"},null,512),[[I,o(u),void 0,{number:!0}]])]),t("div",Ae,[t("div",Le,[e[13]||(e[13]=t("label",{class:"text-xs font-medium text-slate-500"},"透明度",-1)),t("span",We,m(Math.round(o(_)*100))+"%",1)]),C(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>P(_)?_.value=s:null),type:"range",min:"0.05",max:"0.8",step:"0.05",class:"w-full accent-teal-500"},null,512),[[I,o(_),void 0,{number:!0}]])]),t("div",Oe,[t("div",$e,[e[14]||(e[14]=t("label",{class:"text-xs font-medium text-slate-500"},"旋转角度",-1)),t("span",ze,m(o(w))+"°",1)]),C(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>P(w)?w.value=s:null),type:"range",min:"-90",max:"90",class:"w-full accent-teal-500"},null,512),[[I,o(w),void 0,{number:!0}]])]),t("div",Ee,[e[15]||(e[15]=t("label",{class:"text-xs font-medium text-slate-500"},"水印颜色",-1)),t("div",He,[(v(),x(Y,null,Z(de,s=>t("div",{key:s,class:K(["flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border-2 transition-transform hover:scale-110",o(f)===s?"border-teal-500 ring-2 ring-teal-200":"border-slate-200"]),style:pe({backgroundColor:s}),onClick:l=>f.value=s},[o(f)===s?(v(),x("span",Ge,"✓")):k("",!0)],14,Ye)),64)),C(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>P(f)?f.value=s:null),type:"color",class:"h-7 w-7 cursor-pointer rounded border-0"},null,512),[[I,o(f)]])])]),t("div",Ne,[t("label",Xe,[C(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>
2P(F)?F.value=s:null),type:"checkbox","true-value":"bold","false-value":"normal",class:"accent-teal-500"},null,512),[[Q,o(F)]]),e[16]||(e[16]=G(" 加粗 ",-1))]),t("label",qe,[C(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>P(y)?y.value=s:null),type:"checkbox",class:"accent-teal-500"},null,512),[[Q,o(y)]]),e[17]||(e[17]=G(" 描边 ",-1))])]),t("button",{class:"mt-2 flex w-full items-center justify-center gap-2 rounded-xl bg-teal-500 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-teal-600 disabled:cursor-not-allowed disabled:opacity-50",disabled:o(V)||!o(i),onClick:re},[o(V)?(v(),x("span",Ze)):k("",!0),G(" "+m(o(V)?"导出中...":"导出带水印的 PDF"),1)],8,Je)])])],64)):k("",!0)]))}});export{tt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.