import{d as k,o as C,c as w,a,t as m,e as t,w as i,f as x,b as L,g as d,h as p,i as y,k as N,B as S,E as B,_ as E}from"./index-Cn8JNEqj.js";import{a as M,f as U}from"./index-DXp3oW3R.js";const q={class:"admin-login-page"},A={class:"login-card"},I={class:"login-brand"},K={class:"login-title"},R={key:0,class:"error-msg"},j={class:"login-footer"},z=k({__name:"AdminLogin",setup(D){const _=d(),u=d(!1),c=d(""),g=d(""),v=d("");M().then(l=>{l.site_name&&(g.value=l.site_name)}).catch(()=>{});const s=S({username:"",password:""}),b={username:[{required:!0,message:"请输入用户名",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"}]};async function h(){var e,r,n;if(await((e=_.value)==null?void 0:e.validate().catch(()=>!1))){u.value=!0,c.value="";try{const o=await U(s.username,s.password);localStorage.setItem("admin_token",o.token),B.success("登录成功"),window.location.href="/admin"}catch(o){c.value=((n=(r=o==null?void 0:o.response)==null?void 0:r.data)==null?void 0:n.message)||(o==null?void 0:o.message)||"登录失败"}finally{u.value=!1}}}return C(async()=>{try{const e=await(await fetch("/health")).json();v.value=e.version||""}catch{}}),(l,e)=>{const r=p("el-input"),n=p("el-form-item"),o=p("el-button"),V=p("el-form");return y(),w("div",q,[e[4]||(e[4]=a("div",{class:"login-bg-pattern"},null,-1)),a("div",A,[a("div",I,[e[2]||(e[2]=a("div",{class:"login-logo"},"☁️",-1)),a("h1",K,m(g.value||"CloudSearch"),1),e[3]||(e[3]=a("p",{class:"login-subtitle"},"管理后台",-1))]),t(V,{ref_key:"formRef",ref:_,model:s,rules:b,"label-width":"0",size:"large",onKeyup:x(h,["enter"])},{default:i(()=>[t(n,{prop:"username"},{default:i(()=>[t(r,{modelValue:s.username,"onUpdate:modelValue":e[0]||(e[0]=f=>s.username=f),placeholder:"用户名","prefix-icon":"User"},null,8,["modelValue"])]),_:1}),t(n,{prop:"password"},{default:i(()=>[t(r,{modelValue:s.password,"onUpdate:modelValue":e[1]||(e[1]=f=>s.password=f),type:"password",placeholder:"密码","prefix-icon":"Lock","show-password":""},null,8,["modelValue"])]),_:1}),t(n,null,{default:i(()=>[t(o,{type:"primary",loading:u.value,class:"login-btn",onClick:h},{default:i(()=>[N(m(u.value?"登录中...":"登 录"),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"]),c.value?(y(),w("p",R,m(c.value),1)):L("",!0),a("p",j,"CloudSearch v"+m(v.value),1)])])}}}),G=E(z,[["__scopeId","data-v-bd0b6672"]]);export{G as default};
