import{x as L,s as w,c as N,r as p,k as V,l as j,y as A,O as o,F as s,V as D,u as t,E as G,I as H,ae as v,C as m,K as k,L as M,aB as O,aA as P,z as C}from"./vue-vendor-vBC20LeU.js";import{u as T,a as $,c as J,g as Q,_ as W}from"./index-D7dBOFlH.js";import{F as X,G as Y,H as Z,i as ee,x as ae,I as te,k as oe}from"./element-plus-DckSU5ni.js";import"./axios-CG2WSiiR.js";const le={class:"text-center text-4xl font-bold mb-2"},se={class:"w-full flex gap-2"},re={class:"flex-1 flex items-center justify-between"},ne=L({__name:"index",setup(ce){const u=w(),h=w(),E=O(),I=P(),F=T(),R=$(),f=N(()=>F.config),d=p(!1),r=p(!1),b=p(""),y=p(""),a=V({account:"",password:"",captcha:"",remember:!1}),z=V({account:[{required:!0,message:"请输入用户名",trigger:["blur","change"]}],password:[{required:!0,message:"请输入密码",trigger:["blur","change"]}],captcha:[{required:!0,message:"请输入验证码",trigger:["blur","change"]}]}),g=async()=>{try{const l=await Q();r.value=l.enabled===1,b.value=l.img,y.value=l.key}catch(l){console.error("获取验证码失败:",l)}},x=()=>{if(!a.account)return u.value?u.value?.validateField("account"):void 0;if(!a.password)return h.value?.focus();if(r.value&&!a.captcha)return u.value?u.value?.validateField("captcha"):void 0;_()},_=()=>{u.value?.validate(async l=>{if(l){d.value=!0;try{const e={...a,...r.value&&{captcha_key:y.value}};await R.login(e),d.value=!1;const i=E?.query?.redirect,n=typeof i=="string"?i:"/";I.push(n)}catch{d.value=!1,r.value&&g()}}})};return j(()=>{const l=J.get("remember_account");l&&(a.remember=!0,a.account=l),r.value=f.value.enable_captcha===1,r.value&&g()}),(l,e)=>{const i=ee,n=Z,B=ae,K=te,S=oe,U=Y,q=X;return C(),A("div",{class:"login-container",style:D({backgroundImage:`url(${t(f).login_bg_image||""})`})},[o(q,{class:"login-card !border-none"},{header:s(()=>[m("div",le,M(t(f).site_name),1),e[4]||(e[4]=m("div",{class:"text-center text-sm"},"请输入您的帐户信息以开始管理您的项目",-1))]),default:s(()=>[o(U,{class:"p-3",model:t(a),rules:t(z),ref_key:"loginFormRef",ref:u,"label-position":"top"},{default:s(()=>[o(n,{label:"用户名",prop:"account"},{default:s(()=>[o(i,{modelValue:t(a).account,"onUpdate:modelValue":e[0]||(e[0]=c=>t(a).account=c),placeholder:"请输入用户名","prefix-icon":"User",size:"large",onKeyup:v(x,["enter"])},null,8,["modelValue"])]),_:1}),o(n,{label:"密码",prop:"password"},{default:s(()=>[o(i,{ref_key:"passwordInputRef",ref:h,modelValue:t(a).password,"onUpdate:modelValue":e[1]||(e[1]=c=>t(a).password=c),type:"password",placeholder:"请输入密码","prefix-icon":"Lock","show-password":"",size:"large",onKeyup:v(x,["enter"])},null,8,["modelValue"])]),_:1}),t(r)?(C(),G(n,{key:0,label:"验证码",prop:"captcha"},{default:s(()=>[m("div",se,[o(i,{class:"flex-1",modelValue:t(a).captcha,"onUpdate:modelValue":e[2]||(e[2]=c=>t(a).captcha=c),placeholder:"请输入验证码","prefix-icon":"View",size:"large",onKeyup:v(_,["enter"])},null,8,["modelValue"]),o(B,{src:t(b),class:"w-auto h-10 cursor-pointer",onClick:g,fit:"cover"},null,8,["src"])])]),_:1})):H("",!0),o(n,null,{default:s(()=>[m("div",re,[o(K,{modelValue:t(a).remember,"onUpdate:modelValue":e[3]||(e[3]=c=>t(a).remember=c)},{default:s(()=>[...e[5]||(e[5]=[k("记住账号",-1)])]),_:1},8,["modelValue"])])]),_:1}),o(n,{style:{"margin-bottom":"0"}},{default:s(()=>[o(S,{class:"w-full",type:"primary",size:"large",loading:t(d),onClick:_},{default:s(()=>[...e[6]||(e[6]=[k(" 登 录 ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules"])]),_:1})],4)}}}),me=W(ne,[["__scopeId","data-v-4e589908"]]);export{me as default};
