lcny-vue3-antd-admin/dist/assets/LoginForm.b4300eda.js

2 lines
5.8 KiB
JavaScript

var L=(e,t,n)=>new Promise((d,i)=>{var m=r=>{try{g(n.next(r))}catch(C){i(C)}},y=r=>{try{g(n.throw(r))}catch(C){i(C)}},g=r=>r.done?d(r.value):Promise.resolve(r.value).then(m,y);g((n=n.apply(e,t)).next())});import{q as K,o as D,h as H,i as w,a as O,r as j,I as x,c as J,b as Q,s as X,v as p,w as Y,f as Z,k as a,x as ee,y as I,z as T,p as l,B as f,C as $,D as z,E as te,F as oe,G as ne}from"./index.d39002cd.js";import{m as E}from"./md5.ff9309fc.js";import{F as P}from"./index.1d30c971.js";import"./index.22ab5e63.js";import{u as se,a as ae,L as ie,_ as re,b as le}from"./LoginFormTitle.d8b9d39f.js";import"./_baseIteratee.7084243b.js";import"./get.bf2aa0fe.js";import"./useSize.d6417580.js";const ue={name:"SIdentify",props:{identifyCode:{type:String,default:"1234"},fontSizeMin:{type:Number,default:16},fontSizeMax:{type:Number,default:40},backgroundColorMin:{type:Number,default:100},backgroundColorMax:{type:Number,default:240},colorMin:{type:Number,default:50},colorMax:{type:Number,default:100},lineColorMin:{type:Number,default:5},lineColorMax:{type:Number,default:2},dotColorMin:{type:Number,default:10},dotColorMax:{type:Number,default:105},contentWidth:{type:Number,default:112},contentHeight:{type:Number,default:38}},watch:{identifyCode(){this.drawPic()}},mounted(){this.drawPic()},methods:{randomNum(e,t){return Math.floor(Math.random()*(t-e)+e)},randomColor(e,t){let n=this.randomNum(e,t),d=this.randomNum(e,t),i=this.randomNum(e,t);return"rgb("+n+","+d+","+i+")"},drawPic(){let t=document.getElementById("s-canvas").getContext("2d");t.textBaseline="bottom",t.fillStyle=this.randomColor(this.backgroundColorMin,this.backgroundColorMax),t.fillRect(0,0,this.contentWidth,this.contentHeight);for(let n=0;n<this.identifyCode.length;n++)this.drawText(t,this.identifyCode[n],n);this.drawLine(t),this.drawDot(t)},drawText(e,t,n){e.fillStyle=this.randomColor(this.colorMin,this.colorMax),e.font=this.randomNum(this.fontSizeMin,this.fontSizeMax)+"px SimHei";let d=(n+1)*(this.contentWidth/(this.identifyCode.length+1)),i=this.randomNum(this.fontSizeMax,this.contentHeight-5);var m=this.randomNum(-45,45);e.translate(d,i),e.rotate(m*Math.PI/180),e.fillText(t,0,0),e.rotate(-m*Math.PI/180),e.translate(-d,-i)},drawLine(e){for(let t=0;t<0;t++)e.strokeStyle=this.randomColor(this.lineColorMin,this.lineColorMax),e.beginPath(),e.moveTo(this.randomNum(0,this.contentWidth),this.randomNum(0,this.contentHeight)),e.lineTo(this.randomNum(0,this.contentWidth),this.randomNum(0,this.contentHeight)),e.stroke()},drawDot(e){for(let t=0;t<10;t++)e.fillStyle=this.randomColor(0,255),e.beginPath(),e.arc(this.randomNum(0,this.contentWidth),this.randomNum(0,this.contentHeight),1,0,2*Math.PI),e.fill()}}},de={class:"s-canvas"},ce=["width","height"];function me(e,t,n,d,i,m){return D(),H("div",de,[w("canvas",{id:"s-canvas",width:n.contentWidth,height:n.contentHeight},null,8,ce)])}var fe=K(ue,[["render",me]]);const he={class:"flex items-center w-full"},ge={class:"flex-1"},_e=O({__name:"LoginForm",setup(e){const t=j(),n=P.Item,d=x.Password,{t:i}=J(),{notification:m,createErrorModal:y}=ne(),{prefixCls:g}=Q("login"),r=X(),{setLoginState:C,getLoginState:R}=se(),{getFormRules:W}=ae(),k=p(),v=p(!1);p(!1);const N=p(""),c=Y({account:"",password:"",identifyCode:""}),{validForm:U}=le(k),{username:M,userpwd:b,userToken:S}=t.query,B=Z(()=>a(R)===ie.LOGIN);p(!!S||!!M&&!!b),ee(()=>{S&&q(S),M&&b&&A(M,b)});function q(u){try{r.setToken(u),r.afterLoginAction()}catch(o){}}function A(u,o){const{redirect:s}=t.query;let h=s;h||(h="/"),r.login({password:E(o),username:u,mode:"none",homeRouter:h})}function V(u,o){return Math.floor(Math.random()*(o-u)+u)}function G(){c.identifyCode="",F()}F();function F(u=4){const o="1234567890abcdef";let s="";for(let h=0;h<u;h++)s+=o[V(0,o.length)];N.value=s}function _(u){return L(this,null,function*(){const o=yield U();if(!!o){if(o.identifyCode.toLowerCase()!==N.value.toLowerCase()){y({title:"\u9519\u8BEF\u63D0\u793A",content:"\u9A8C\u8BC1\u7801\u4E0D\u6B63\u786E"});return}try{v.value=!0;const s=yield r.login({password:E(o.password),username:o.account,mode:"none",homeRouter:u});s&&m.success({message:i("sys.login.loginSuccessTitle"),description:`${i("sys.login.loginSuccessDesc")}: ${s.name}`,duration:3})}catch(s){y({title:i("sys.api.errorTip"),content:s.message||i("sys.api.networkExceptionMsg"),getContainer:()=>document.body.querySelector(`.${g}`)||document.body})}finally{v.value=!1}}})}return(u,o)=>(D(),H(oe,null,[I(l(re,{class:"enter-x"},null,512),[[T,a(B)]]),I(l(a(P),{class:"p-4 enter-x",model:c,rules:a(W),ref_key:"formRef",ref:k,onKeypress:o[5]||(o[5]=te(s=>_("/"),["enter"]))},{default:f(()=>[l(a(n),{name:"account",class:"enter-x"},{default:f(()=>[l(a(x),{size:"large",value:c.account,"onUpdate:value":o[0]||(o[0]=s=>c.account=s),placeholder:a(i)("sys.login.userName"),class:"fix-auto-fill"},null,8,["value","placeholder"])]),_:1}),l(a(n),{name:"password",class:"enter-x"},{default:f(()=>[l(a(d),{size:"large",visibilityToggle:"",value:c.password,"onUpdate:value":o[1]||(o[1]=s=>c.password=s),placeholder:a(i)("sys.login.password")},null,8,["value","placeholder"])]),_:1}),l(a(n),{name:"identifyCode",class:"enter-x"},{default:f(()=>[w("div",he,[w("div",ge,[l(a(x),{size:"large",value:c.identifyCode,"onUpdate:value":o[2]||(o[2]=s=>c.identifyCode=s),placeholder:"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",class:"!w-full !min-w-full"},null,8,["value"])]),w("div",{onClick:G},[l(fe,{class:"ml-1 flex-none",identifyCode:N.value},null,8,["identifyCode"])])])]),_:1}),l(a(n),{class:"enter-x"},{default:f(()=>[l(a($),{size:"large",block:"",onClick:o[3]||(o[3]=s=>_("/v")),loading:v.value},{default:f(()=>[z(" \u767B\u5F55\u5927\u5C4F ")]),_:1},8,["loading"]),l(a($),{type:"primary",class:"mt-4",size:"large",block:"",onClick:o[4]||(o[4]=s=>_("/")),loading:v.value},{default:f(()=>[z(" \u767B\u5F55\u540E\u53F0 ")]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules"]),[[T,a(B)]])],64))}});export{_e as default};