2 lines
2.4 KiB
JavaScript
2 lines
2.4 KiB
JavaScript
var k=(w,u,r)=>new Promise((t,m)=>{var f=n=>{try{i(r.next(n))}catch(c){m(c)}},g=n=>{try{i(r.throw(n))}catch(c){m(c)}},i=n=>n.done?t(n.value):Promise.resolve(n.value).then(f,g);i((r=r.apply(w,u)).next())});import{d as E,b as R,a as D,p as N,r as y,q as T,e as h,j as s,o as M,f as U,w as L,v as _,m as a,s as l,x as b,y as V,F as q,z as K}from"./index.600742c0.js";import{Form as C,Input as I,Button as $}from"ant-design-vue";import{u as P,a as j,L as G,_ as O,b as A}from"./LoginFormTitle.58be05ca.js";const X=E({__name:"LoginForm",setup(w){const u=C.Item,r=I.Password,{t}=R(),{notification:m,createErrorModal:f}=K(),{prefixCls:g}=D("login"),i=N(),{setLoginState:n,getLoginState:c}=P(),{getFormRules:z}=j(),x=y(),p=y(!1);y(!1);const d=T({account:"",password:""}),{validForm:B}=A(x),F=h(()=>s(c)===G.LOGIN);function v(S){return k(this,null,function*(){const e=yield B();if(!!e)try{p.value=!0;const o=yield i.login({password:e.password,username:e.account,mode:"none",homeRouter:S});o&&m.success({message:t("sys.login.loginSuccessTitle"),description:`${t("sys.login.loginSuccessDesc")}: ${o.name}`,duration:3})}catch(o){f({title:t("sys.api.errorTip"),content:o.message||t("sys.api.networkExceptionMsg"),getContainer:()=>document.body.querySelector(`.${g}`)||document.body})}finally{p.value=!1}})}return(S,e)=>(M(),U(q,null,[L(a(O,{class:"enter-x"},null,512),[[_,s(F)]]),L(a(s(C),{class:"p-4 enter-x",model:d,rules:s(z),ref_key:"formRef",ref:x,onKeypress:e[4]||(e[4]=V(o=>v("/"),["enter"]))},{default:l(()=>[a(s(u),{name:"account",class:"enter-x"},{default:l(()=>[a(s(I),{size:"large",value:d.account,"onUpdate:value":e[0]||(e[0]=o=>d.account=o),placeholder:s(t)("sys.login.userName"),class:"fix-auto-fill"},null,8,["value","placeholder"])]),_:1}),a(s(u),{name:"password",class:"enter-x"},{default:l(()=>[a(s(r),{size:"large",visibilityToggle:"",value:d.password,"onUpdate:value":e[1]||(e[1]=o=>d.password=o),placeholder:s(t)("sys.login.password")},null,8,["value","placeholder"])]),_:1}),a(s(u),{class:"enter-x"},{default:l(()=>[a(s($),{type:"primary",size:"large",block:"",onClick:e[2]||(e[2]=o=>v("/")),loading:p.value},{default:l(()=>[b(" \u767B\u5F55\u540E\u53F0 ")]),_:1},8,["loading"]),a(s($),{size:"large",class:"mt-4",block:"",onClick:e[3]||(e[3]=o=>v("/v")),loading:p.value},{default:l(()=>[b(" \u767B\u5F55\u5927\u5C4F ")]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules"]),[[_,s(F)]])],64))}});export{X as default};
|