LoginForm-c9ca8d1a.js 3.8 KB

1
  1. var f=(I,u,d)=>new Promise((l,y)=>{var S=o=>{try{p(d.next(o))}catch(m){y(m)}},x=o=>{try{p(d.throw(o))}catch(m){y(m)}},p=o=>o.done?l(o.value):Promise.resolve(o.value).then(S,x);p((d=d.apply(I,u)).next())});import{d as $,aj as P,o as Z,f as w,r as D,Y as j,Z as q,n as h,z as v,l as s,a7 as r,u as a,_ as A,E as G,$ as O,an as Q,F as Y}from"./vue-aed314e3.js";import{a as H,c as J,b as W}from"./LoginFormTitle-d25d37ad.js";import{a as X,f as ee,Q as ae,Z as se,ar as oe,as as te,at as E,au as ne,_ as re}from"./index.js";import{b as R}from"./uuid-31b8b5a4.js";import{s as le}from"./sysConfigApi-c5845550.js";import{aa as T,A as b,a6 as ce,a5 as U,B as ie}from"./antd-f259b82a.js";const ue=["src"],de=$({__name:"LoginForm",setup(I){const u=T.Item,d=b.Password,{t:l}=X(),{notification:y,createMessage:S}=ne();ee("login");const x=ae(),{clientId:p,clientSecret:o}=se(),{getFormRules:m}=H(),z=P(),_=oe.createBase64Encryption(),c=te({prefixKey:""});Z(()=>f(this,null,function*(){e.username=c.get("username")?_.decrypt(c.get("username")):"",e.password=c.get("password")?_.decrypt(c.get("password")):"",yield N()}));const K=w(),C=w(!1),M=w(!0),e=D({username:"",password:"",codeKey:R(),code:""}),g=D({loading:!1,captchaSrc:E(e.codeKey),showCaptcha:!0}),{validForm:V}=J(K),L=w(!0);function k(){return f(this,null,function*(){e.codeKey=R(),g.captchaSrc=E(e.codeKey)})}function B(){return f(this,null,function*(){var t;const i=yield V();if(i)try{C.value=!0;const n=((t=z.query)==null?void 0:t.redirect)||"",F=yield x.login({username:i.username,password:i.password,loginType:"login",mode:"none",captchaKey:e.codeKey,captchaCode:e.code,grant_type:"",redirect:n,client_id:p,client_secret:o,captchaVerification:""});console.log("🚀 ~ file: LoginForm.vue:169 ~ handleLogin ~ userInfo:",F),F&&(M.value?(c.set("username",_.encrypt(e.username)),c.set("password",_.encrypt(e.password))):(c.set("username",""),c.set("password","")),y.success({message:l("sys.login.loginSuccessTitle"),description:`${l("sys.login.loginSuccessDesc")}: ${F.nickname}`,duration:3}))}catch(n){k(),S.error(n.message||l("sys.api.networkExceptionMsg"))}finally{C.value=!1}})}function N(){return f(this,null,function*(){const i=yield le();console.log("🚀 ~ file: LoginForm.vue:194 ~ getSystemConfig ~ res:",i),i.captchaOpen==1?g.showCaptcha=!0:g.showCaptcha=!1})}return(i,t)=>(j(),q(Y,null,[h(s(W,{class:"enter-x"},null,512),[[v,L.value]]),h(s(a(T),{class:"p-4 enter-x",model:e,rules:a(m),ref_key:"formRef",ref:K,onKeypress:Q(B,["enter"]),layout:"vertical"},{default:r(()=>[s(a(u),{name:"username",class:"enter-x",label:"用户名"},{default:r(()=>[s(a(b),{size:"large",value:e.username,"onUpdate:value":t[0]||(t[0]=n=>e.username=n),placeholder:a(l)("sys.login.userName"),class:"fix-auto-fill"},null,8,["value","placeholder"])]),_:1}),s(a(u),{name:"password",class:"enter-x",label:"密码"},{default:r(()=>[s(a(d),{size:"large",visibilityToggle:"",value:e.password,"onUpdate:value":t[1]||(t[1]=n=>e.password=n),placeholder:a(l)("sys.login.password")},null,8,["value","placeholder"])]),_:1}),h(s(a(ce),{class:"enter-x flex-items-center"},{default:r(()=>[s(a(U),{span:"16"},{default:r(()=>[s(a(u),{class:"code-input",name:"code",label:"验证码"},{default:r(()=>[s(a(b),{size:"large",visibilityToggle:"",value:e.code,"onUpdate:value":t[2]||(t[2]=n=>e.code=n),placeholder:"验证码"},null,8,["value"])]),_:1})]),_:1}),s(a(U),{span:"8",class:"login-captcha"},{default:r(()=>[h(A("img",{src:g.captchaSrc,onClick:k,alt:"captcha",class:"code-image"},null,8,ue),[[v,!0]])]),_:1})]),_:1},512),[[v,g.showCaptcha]]),s(a(u),{class:"mt-10 enter-x"},{default:r(()=>[s(a(ie),{type:"primary",size:"large",block:"",onClick:B,loading:C.value},{default:r(()=>[G(O(a(l)("sys.login.loginButton")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules","onKeypress"]),[[v,L.value]])],64))}});const he=re(de,[["__scopeId","data-v-91ba9925"]]);export{he as default};