Files
aiot-platform-ui/apps/web-antd/dist/js/verify-points-CTcwMu3B.js
lzh 2deb263bf9
All checks were successful
Web UI CI/CD / build-and-deploy (push) Successful in 8s
chore: build and deploy web-antd
2026-03-08 00:18:15 +08:00

2 lines
4.2 KiB
JavaScript

var P=(g,W,h)=>new Promise((z,u)=>{var b=i=>{try{l(h.next(i))}catch(o){u(o)}},_=i=>{try{l(h.throw(i))}catch(o){u(o)}},l=i=>i.done?z(i.value):Promise.resolve(i.value).then(b,_);l((h=h.apply(g,W)).next())});import{am as G,an as Q,$ as B}from"./bootstrap-D7yvUSkm.js";import{m as U,bt as Z,r as ee,b9 as n,b7 as T,v as te,ad as D,b2 as O,ae as f,aT as E,bL as ae,j as se,u as ie,I as ne,bb as oe,bp as K,n as re,ed as X}from"../jse/index-index-BAlyf32H.js";import{r as ce}from"./util-BwSl71C9.js";const le={style:{position:"relative"}},ue={class:"verify-img-out"},de=["src"],ve={class:"verify-msg"},me=U({name:"VerifyPoints",__name:"verify-points",props:{arith:{},barSize:{default:()=>({height:"40px",width:"310px"})},blockSize:{},captchaType:{default:"clickWord"},explain:{},figure:{},imgSize:{default:()=>({height:"155px",width:"310px"})},mode:{default:"fixed"},space:{default:5},type:{},checkCaptchaApi:{},getCaptchaApi:{}},emits:["onSuccess","onError","onClose","onReady"],setup(g,{expose:W,emit:h}){const z=g,u=h,{captchaType:b,mode:_,checkCaptchaApi:l,getCaptchaApi:i}=Z(z),{proxy:o}=ee(),m=n(),J=n(3),L=T([]),r=T([]),d=n(1),M=n(),R=n([]),x=n(),c=T({barHeight:0,barWidth:0,imgHeight:0,imgWidth:0}),H=T([]),y=n(),k=n(),S=n(),j=n(!0),N=n(!0);function V(){L.splice(0),r.splice(0),d.value=1,F(),re(()=>{const{barHeight:t,barWidth:e,imgHeight:a,imgWidth:s}=ce(o);c.imgHeight=a,c.imgWidth=s,c.barHeight=t,c.barWidth=e,u("onReady",o)})}te(()=>{var t;V(),(t=o==null?void 0:o.$el)==null||t.addEventListener("selectstart",()=>!1)});const w=n(null),C=function(t,e){const a=e.offsetX,s=e.offsetY;return{x:a,y:s}},A=function(t){return H.push(Object.assign({},t)),d.value+1},Y=function(t,e){return t.map(s=>{const v=Math.round(310*s.x/Number.parseInt(e.imgWidth)),p=Math.round(155*s.y/Number.parseInt(e.imgHeight));return{x:v,y:p}})},$=function(){return P(this,null,function*(){H.splice(0),k.value="#000",S.value="#ddd",N.value=!0,L.splice(0),r.splice(0),d.value=1,yield F(),j.value=!0})};function q(t){if(r.push(C(w,t)),d.value===J.value){d.value=A(C(w,t));const e=Y(r,c);r.length=0,r.push(...e),setTimeout(()=>{var v;const a=m.value?X.encrypt(`${x.value}---${JSON.stringify(r)}`,m.value):`${x.value}---${JSON.stringify(r)}`,s={captchaType:b.value,pointJson:m.value?X.encrypt(JSON.stringify(r),m.value):JSON.stringify(r),token:x.value};(v=l==null?void 0:l.value)==null||v.call(l,s).then(p=>{p.data.repCode==="0000"?(k.value="#4cae4c",S.value="#5cb85c",y.value=B("ui.captcha.sliderSuccessText"),N.value=!1,_.value==="pop"&&setTimeout(()=>{u("onClose"),$()},1500),u("onSuccess",{captchaVerification:a})):(u("onError",o),k.value="#d9534f",S.value="#d9534f",y.value=B("ui.captcha.sliderRotateFailTip"),setTimeout(()=>{$()},700))})},400)}d.value<J.value&&(d.value=A(C(w,t)))}function F(){return P(this,null,function*(){var a,s,v,p,I;const t={captchaType:b.value},e=yield(a=i==null?void 0:i.value)==null?void 0:a.call(i,t);((s=e==null?void 0:e.data)==null?void 0:s.repCode)==="0000"?(M.value=`data:image/png;base64,${(p=(v=e==null?void 0:e.data)==null?void 0:v.repData)==null?void 0:p.originalImageBase64}`,x.value=e.data.repData.token,m.value=e.data.repData.secretKey,R.value=e.data.repData.wordList,y.value=`${B("ui.captcha.clickInOrder")}${R.value.join(",")}`):y.value=(I=e==null?void 0:e.data)==null?void 0:I.repMsg})}return W({init:V,refresh:$}),(t,e)=>(O(),D("div",le,[f("div",ue,[f("div",{style:E({width:c.imgWidth,height:c.imgHeight,"background-size":`${c.imgWidth} ${c.imgHeight}`,"margin-bottom":`${g.space}px`}),class:"verify-img-panel"},[ae(f("div",{class:"verify-refresh",style:{"z-index":"3"},onClick:$},[se(ie(Q),{icon:"lucide:refresh-ccw",class:"mr-2 size-5"})],512),[[G,j.value]]),f("img",{ref_key:"canvas",ref:w,src:M.value,alt:"",style:{display:"block",width:"100%",height:"100%"},onClick:e[0]||(e[0]=a=>N.value?q(a):void 0)},null,8,de),(O(!0),D(ne,null,oe(H,(a,s)=>(O(),D("div",{key:s,style:E({"background-color":"#1abd6c",color:"#fff","z-index":9999,width:"20px",height:"20px","text-align":"center","line-height":"20px","border-radius":"50%",position:"absolute",top:`${a.y-10}px`,left:`${a.x-10}px`}),class:"point-area"},K(s+1),5))),128))],4)]),f("div",{style:E({width:c.imgWidth,color:k.value,"border-color":S.value,"line-height":g.barSize.height}),class:"verify-bar-area"},[f("span",ve,K(y.value),1)],4)]))}});export{me as default};