import{d as R,u as z,r as d,a as B,o as U,c as _,b as l,e as a,w as o,f as E,g as n,h as F,E as x,i as I,j as N,k as h,l as c,m as M,n as S,p as j,q as H,s as L,t as T,_ as A}from"./index-CUnFTKV2.js";const D={class:"login-container"},G={class:"login-box"},J={class:"captcha-container"},O=["src"],P={key:1,class:"captcha-loading"},Q=R({__name:"index",setup(W){const C=I(),V=N(),b=z(),u=d(),p=d(!1),m=d(""),v=d(""),s=B({username:"",password:"",captchaCode:""}),k={username:[{required:!0,message:"请输入用户名",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"},{min:6,message:"密码至少6个字符",trigger:"blur"}],captchaCode:[{required:!0,message:"请输入验证码",trigger:"blur"},{min:4,max:6,message:"验证码为4-6位字符",trigger:"blur"}]},f=async()=>{try{const t=await F();v.value=t.data.captchaKey,m.value=t.data.captchaImage}catch{x.error("获取验证码失败，请重试")}},y=async()=>{u.value&&await u.value.validate(async t=>{if(t){p.value=!0;try{await b.login({username:s.username,password:s.password,captchaKey:v.value,captchaCode:s.captchaCode}),x.success("登录成功");const e=V.query.redirect;C.push(e||"/")}catch{s.captchaCode="",await f()}finally{p.value=!1}}})};return U(()=>{f()}),(t,e)=>{const g=n("el-input"),i=n("el-form-item"),w=n("el-icon"),q=n("el-button"),K=n("el-form");return h(),_("div",D,[l("div",G,[e[4]||(e[4]=l("div",{class:"login-header"},[l("h1",null,"HoneyBox 后台管理系统")],-1)),a(K,{ref_key:"loginFormRef",ref:u,model:s,rules:k,class:"login-form",onKeyup:E(y,["enter"])},{default:o(()=>[a(i,{prop:"username"},{default:o(()=>[a(g,{modelValue:s.username,"onUpdate:modelValue":e[0]||(e[0]=r=>s.username=r),placeholder:"请输入用户名","prefix-icon":c(M),size:"large"},null,8,["modelValue","prefix-icon"])]),_:1}),a(i,{prop:"password"},{default:o(()=>[a(g,{modelValue:s.password,"onUpdate:modelValue":e[1]||(e[1]=r=>s.password=r),type:"password",placeholder:"请输入密码","prefix-icon":c(S),size:"large","show-password":""},null,8,["modelValue","prefix-icon"])]),_:1}),a(i,{prop:"captchaCode"},{default:o(()=>[l("div",J,[a(g,{modelValue:s.captchaCode,"onUpdate:modelValue":e[2]||(e[2]=r=>s.captchaCode=r),placeholder:"请输入验证码","prefix-icon":c(j),size:"large",class:"captcha-input"},null,8,["modelValue","prefix-icon"]),l("div",{class:"captcha-image-wrapper",onClick:f},[m.value?(h(),_("img",{key:0,src:m.value,alt:"验证码",class:"captcha-image",title:"点击刷新验证码"},null,8,O)):(h(),_("div",P,[a(w,{class:"is-loading"},{default:o(()=>[a(c(H))]),_:1})])),a(w,{class:"refresh-icon"},{default:o(()=>[a(c(L))]),_:1})])])]),_:1}),a(i,null,{default:o(()=>[a(q,{type:"primary",size:"large",loading:p.value,class:"login-btn",onClick:y},{default:o(()=>[...e[3]||(e[3]=[T(" 登 录 ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])])}}}),Y=A(Q,[["__scopeId","data-v-91501f26"]]);export{Y as default};
