chore: update

This commit is contained in:
xiaoxian521
2023-08-30 21:53:35 +08:00
parent d7a479afc6
commit a2e0b9155b
510 changed files with 6 additions and 516 deletions

View File

@@ -6,4 +6,3 @@ The chosen QR Code version cannot contain this amount of data.
Minimum version required to store current data is: `+n+`.
`);const s=Ue(e,i,o),c=et.getSymbolSize(e),a=new pe(c);return Pe(a,e),Re(a),Le(a,e),it(a,i,0),e>=7&&ve(a,e),De(a,s),isNaN(r)&&(r=ct.getBestMask(a,it.bind(null,a,i))),ct.applyMask(r,a),it(a,i,r),{modules:a,version:e,errorCorrectionLevel:i,maskPattern:r,segments:o}}Tt.create=function(e,i){if(typeof e>"u"||e==="")throw new Error("No input text");let r=ot.M,o,n;return typeof i<"u"&&(r=ot.from(i.errorCorrectionLevel,ot.M),o=X.from(i.version),n=ct.from(i.maskPattern),i.toSJISFunc&&et.setToSJISFunction(i.toSJISFunc)),Fe(e,o,r,n)};var kt={},ht={};(function(t){function e(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let r=i.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+i);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(n){return[n,n]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,n=r.width&&r.width>=21?r.width:void 0,s=r.scale||4;return{width:n,scale:n?4:s,margin:o,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},t.getImageWidth=function(r,o){const n=t.getScale(r,o);return Math.floor((r+o.margin*2)*n)},t.qrToImageData=function(r,o,n){const s=o.modules.size,c=o.modules.data,a=t.getScale(s,n),f=Math.floor((s+n.margin*2)*a),d=n.margin*a,A=[n.color.light,n.color.dark];for(let C=0;C<f;C++)for(let w=0;w<f;w++){let y=(C*f+w)*4,u=n.color.light;if(C>=d&&w>=d&&C<f-d&&w<f-d){const E=Math.floor((C-d)/a),l=Math.floor((w-d)/a);u=A[c[E*s+l]?1:0]}r[y++]=u.r,r[y++]=u.g,r[y++]=u.b,r[y]=u.a}}})(ht);(function(t){const e=ht;function i(o,n,s){o.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=s,n.width=s,n.style.height=s+"px",n.style.width=s+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(n,s,c){let a=c,f=s;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),s||(f=r()),a=e.getOptions(a);const d=e.getImageWidth(n.modules.size,a),A=f.getContext("2d"),C=A.createImageData(d,d);return e.qrToImageData(C.data,n,a),i(A,f,d),A.putImageData(C,0,0),f},t.renderToDataURL=function(n,s,c){let a=c;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),a||(a={});const f=t.render(n,s,a),d=a.type||"image/png",A=a.rendererOpts||{};return f.toDataURL(d,A.quality)}})(kt);var zt={};const ke=ht;function pt(t,e){const i=t.a/255,r=e+'="'+t.hex+'"';return i<1?r+" "+e+'-opacity="'+i.toFixed(2).slice(1)+'"':r}function st(t,e,i){let r=t+e;return typeof i<"u"&&(r+=" "+i),r}function ze(t,e,i){let r="",o=0,n=!1,s=0;for(let c=0;c<t.length;c++){const a=Math.floor(c%e),f=Math.floor(c/e);!a&&!n&&(n=!0),t[c]?(s++,c>0&&a>0&&t[c-1]||(r+=n?st("M",a+i,.5+f+i):st("m",o,0),o=0,n=!1),a+1<e&&t[c+1]||(r+=st("h",s),s=0)):o++}return r}zt.render=function(e,i,r){const o=ke.getOptions(i),n=e.modules.size,s=e.modules.data,c=n+o.margin*2,a=o.color.light.a?"<path "+pt(o.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",f="<path "+pt(o.color.dark,"stroke")+' d="'+ze(s,n,o.margin)+'"/>',d='viewBox="0 0 '+c+" "+c+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+d+' shape-rendering="crispEdges">'+a+f+`</svg>
`;return typeof r=="function"&&r(null,C),C};const He=Zt,lt=Tt,Ht=kt,Ve=zt;function wt(t,e,i,r,o){const n=[].slice.call(arguments,1),s=n.length,c=typeof n[s-1]=="function";if(!c&&!He())throw new Error("Callback required as last argument");if(c){if(s<2)throw new Error("Too few arguments provided");s===2?(o=i,i=e,e=r=void 0):s===3&&(e.getContext&&typeof o>"u"?(o=r,r=void 0):(o=r,r=i,i=e,e=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(i=e,e=r=void 0):s===2&&!e.getContext&&(r=i,i=e,e=void 0),new Promise(function(a,f){try{const d=lt.create(i,r);a(t(d,e,r))}catch(d){f(d)}})}try{const a=lt.create(i,r);o(null,t(a,e,r))}catch(a){o(a)}}Y.create=lt.create;Y.toCanvas=wt.bind(null,Ht.render);Y.toDataURL=wt.bind(null,Ht.renderToDataURL);Y.toString=wt.bind(null,function(t,e,i){return Ve.render(t,i)});const Ke={tag:Q.string.validate(t=>["canvas","img"].includes(t)).def("canvas"),text:{type:[String,Array],default:null},options:{type:Object,default:()=>({})},width:Q.number.def(200),logo:{type:[String,Object],default:()=>""},disabled:Q.bool.def(!1),disabledText:Q.string.def("")},Oe=Ot({name:"ReQrcode",props:Ke,emits:["done","click","disabled-click"],setup(t,{emit:e}){const{toCanvas:i,toDataURL:r}=Y,o=yt(!0),n=yt(null),s=Et(()=>String(t.text)),c=Et(()=>({width:t.width+"px",height:t.width+"px"})),a=async()=>{await Gt();const u=qt(t.options||{});if(t.tag==="canvas"){u.errorCorrectionLevel=u.errorCorrectionLevel||A(U(s));const E=await d(U(s),u);u.scale=t.width===0?void 0:t.width/E*4;const l=await i(U(n),U(s),u);if(t.logo){const m=await f(l);e("done",m),o.value=!1}else e("done",l.toDataURL()),o.value=!1}else{const E=await r(s.value,{errorCorrectionLevel:"H",width:t.width,...u});U(n).src=E,e("done",E),o.value=!1}};Jt(()=>s.value,u=>{u&&a()},{deep:!0,immediate:!0});const f=u=>{const E=u.width,l=Object.assign({logoSize:.15,bgColor:"#ffffff",borderSize:.05,crossOrigin:"anonymous",borderRadius:8,logoRadius:0},Bt(t.logo)?{}:t.logo),{logoSize:m=.15,bgColor:h="#ffffff",borderSize:g=.05,crossOrigin:B="anonymous",borderRadius:b=8,logoRadius:p=0}=l,N=Bt(t.logo)?t.logo:t.logo.src,S=E*m,I=E*(1-m)/2,R=E*(m+g),_=E*(1-m-g)/2,T=u.getContext("2d");if(!T)return;C(T)(_,_,R,R,b),T.fillStyle=h,T.fill();const V=new Image;(B||p)&&V.setAttribute("crossOrigin",B),V.src=N;const Vt=K=>{T.drawImage(K,I,I,S,S)},Kt=K=>{const $=document.createElement("canvas");$.width=I+S,$.height=I+S;const mt=$.getContext("2d");if(!mt||!T||(mt.drawImage(K,I,I,S,S),C(T)(I,I,S,S,p),!T))return;const Ct=T.createPattern($,"no-repeat");Ct&&(T.fillStyle=Ct,T.fill())};return new Promise(K=>{V.onload=()=>{p?Kt(V):Vt(V),K(u.toDataURL())}})},d=async(u,E)=>{const l=document.createElement("canvas");return await i(l,u,E),l.width},A=u=>u.length>36?"M":u.length>16?"Q":"H",C=u=>(E,l,m,h,g)=>{const B=Math.min(m,h);return g>B/2&&(g=B/2),u.beginPath(),u.moveTo(E+g,l),u.arcTo(E+m,l,E+m,l+h,g),u.arcTo(E+m,l+h,E,l+h,g),u.arcTo(E,l+h,E,l,g),u.arcTo(E,l,E+m,l,g),u.closePath(),u},w=()=>{e("click")},y=()=>{e("disabled-click")};return()=>L(Qt,null,[Yt(L("div",{class:"qrcode relative inline-block",style:U(c)},[t.tag==="canvas"?L("canvas",{ref:n,onClick:w},null):L("img",{ref:n,onClick:w},null),t.disabled&&L("div",{class:"qrcode--disabled absolute top-0 left-0 flex w-full h-full items-center justify-center",onClick:y},[L("div",{class:"absolute top-[50%] left-[50%] font-bold"},[L($t("iconify-icon-offline"),{class:"cursor-pointer",icon:Xt,width:"30",color:"var(--el-color-primary)"},null),L("div",null,[t.disabledText])])])]),[[jt("loading"),U(o)]])])}}),$e=Wt(Oe);export{$e as R};
//# sourceMappingURL=index61.js.map