var y=(k,_,n)=>new Promise((g,c)=>{var u=e=>{try{p(n.next(e))}catch(m){c(m)}},i=e=>{try{p(n.throw(e))}catch(m){c(m)}},p=e=>e.done?g(e.value):Promise.resolve(e.value).then(u,i);p((n=n.apply(k,_)).next())});import{_ as S}from"./_plugin-vue_export-helper-DRcqrMy4.js";/* empty css                     *//* empty css                  *//* empty css                    *//* empty css               *//* empty css                 */import{v as D,aA as M,aB as N,j,ab as B,y as v,B as z,E as r,C as a,D as t,z as A,Q as L,R as Q,an as T,r as f,l as G}from"./vue-vendor-81Zqb-7t.js";import{u as H,g as J}from"./index-Dua4jQwX.js";import{c as O,d as P,e as W,f as X,g as Y,h as Z,j as $,k as ee,E as b}from"./element-plus-CSxUwlOP.js";const ae={class:"login-container"},oe={class:"login-box"},te={class:"logo-section"},se=["src"],le=D({__name:"Login",setup(k){const _=M(),n=N(),g=H(),c=f(),u=f(!1),i=f(""),p=f(""),e=G({username:"",password:"",captcha:"",captcha_key:"",remember:!1}),m={username:[{required:!0,message:"请输入用户名",trigger:"blur"},{min:4,max:50,message:"用户名长度为 4 到 50 个字符",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"},{min:6,message:"密码长度不能少于 6 个字符",trigger:"blur"}],captcha:[{required:!0,message:"请输入验证码",trigger:"blur"},{len:4,message:"验证码为 4 位",trigger:"blur"}]},w=()=>y(this,null,function*(){try{const s=yield J();i.value=s.captcha_image,p.value=s.captcha_key,e.captcha_key=s.captcha_key}catch(s){b.error("获取验证码失败")}}),x=()=>{w(),e.captcha=""},V=()=>y(this,null,function*(){if(c.value)try{yield c.value.validate(),u.value=!0,yield g.login(e.username,e.password,e.captcha,e.captcha_key),b.success("登录成功");const s=n.query.redirect||"/";_.push(s)}catch(s){s!==!1&&(b.error(s.message||"登录失败，请检查用户名和密码"),x())}finally{u.value=!1}});return j(()=>{if(g.isLoggedIn){_.push("/");return}w()}),(s,o)=>{const R=B("Box"),C=O,h=W,d=P,E=Y,U=B("Loading"),I=X,q=Z,F=$,K=ee;return v(),z("div",ae,[r("div",oe,[r("div",te,[a(C,{size:80,color:"#475569"},{default:t(()=>[a(R)]),_:1}),o[4]||(o[4]=r("h1",null,"资产管理系统",-1)),o[5]||(o[5]=r("p",null,"Asset Management System",-1))]),a(K,{ref_key:"loginFormRef",ref:c,model:e,rules:m,class:"login-form",onKeyup:T(V,["enter"])},{default:t(()=>[a(d,{prop:"username"},{default:t(()=>[a(h,{modelValue:e.username,"onUpdate:modelValue":o[0]||(o[0]=l=>e.username=l),placeholder:"请输入用户名","prefix-icon":"User",size:"large",clearable:""},null,8,["modelValue"])]),_:1}),a(d,{prop:"password"},{default:t(()=>[a(h,{modelValue:e.password,"onUpdate:modelValue":o[1]||(o[1]=l=>e.password=l),type:"password",placeholder:"请输入密码","prefix-icon":"Lock",size:"large","show-password":"",clearable:""},null,8,["modelValue"])]),_:1}),a(d,{prop:"captcha"},{default:t(()=>[a(I,{gutter:10},{default:t(()=>[a(E,{span:14},{default:t(()=>[a(h,{modelValue:e.captcha,"onUpdate:modelValue":o[2]||(o[2]=l=>e.captcha=l),placeholder:"请输入验证码","prefix-icon":"Key",size:"large",clearable:""},null,8,["modelValue"])]),_:1}),a(E,{span:10},{default:t(()=>[r("div",{class:"captcha-box",onClick:x},[i.value?(v(),z("img",{key:0,src:i.value,alt:"验证码"},null,8,se)):(v(),A(C,{key:1,size:40},{default:t(()=>[a(U)]),_:1}))])]),_:1})]),_:1})]),_:1}),a(d,null,{default:t(()=>[a(q,{modelValue:e.remember,"onUpdate:modelValue":o[3]||(o[3]=l=>e.remember=l)},{default:t(()=>[...o[6]||(o[6]=[L("记住我",-1)])]),_:1},8,["modelValue"])]),_:1}),a(d,null,{default:t(()=>[a(F,{type:"primary",size:"large",loading:u.value,onClick:V,style:{width:"100%"}},{default:t(()=>[L(Q(u.value?"登录中...":"登录"),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"]),o[7]||(o[7]=r("div",{class:"footer"},[r("p",null,"推荐使用 Chrome 浏览器以获得最佳体验")],-1))])])}}}),fe=S(le,[["__scopeId","data-v-132f806e"]]);export{fe as default};
