import{d as y,aa as k,aj as C,r as m,o as I,A as P,J as i,P as _,B as o,C as l,ad as x,j as t,ak as z,e as S,g as j,al as g,am as w,an as B,_ as U,Q as A}from"./index-DOFLUERq.js";import{_ as R}from"./logo-CrT-C5Op.js";import{I as v}from"./iconify-p99pbjf9.js";import{_ as V}from"./_plugin-vue_export-helper-DlAUqK2U.js";const q={class:"login-container"},D={class:"login-card"},F={class:"login-header"},J={class:"logo"},K=["alt"],M={class:"title"},E=y({__name:"Login",setup(Q){const L=S(),c=k(),u=C(),N=()=>"zh-CN",s=e=>{const n=N(),a={"zh-CN":{Username:"用户名",Password:"密码",Login:"登录","Please enter username":"请输入用户名","Please enter password":"请输入密码","Password must be at least 6 characters":"密码至少需要6个字符","Login successful":"登录成功","Login failed":"登录失败","Login failed, please check username and password":"登录失败，请检查用户名和密码"}};return n==="zh-CN"&&a["zh-CN"]?.[e]?a["zh-CN"][e]:e},f=m(),d=m(!1),r=A({username:"",password:""}),b={username:[{required:!0,message:s("Please enter username"),trigger:"blur"}],password:[{required:!0,message:s("Please enter password"),trigger:"blur"},{min:6,message:s("Password must be at least 6 characters"),trigger:"blur"}]},h=async()=>{try{await f.value?.validate(),d.value=!0;const e=await u.login(r.username,r.password);e.success?(c.success(s("Login successful")),window.location.reload()):c.error(e.error||s("Login failed"))}catch(e){console.error("Login error:",e),c.error(s("Login failed, please check username and password"))}finally{d.value=!1}},p=m(localStorage.getItem("appName")||"Jingrow");return I(async()=>{if(!localStorage.getItem("appName"))try{const e=await fetch("/api/action/jingrow.sessions.get_app_name",{headers:{Accept:"application/json"},credentials:"include"});if(e.ok){const a=(await e.json()).message;a&&(localStorage.setItem("appName",a),p.value=a)}}catch{}await u.initAuth(),u.isLoggedIn&&L.push("/")}),(e,n)=>(j(),P("div",q,[i("div",D,[i("div",F,[i("div",J,[i("img",{src:R,alt:p.value,width:"48",height:"48"},null,8,K)]),i("h1",M,_(p.value),1)]),o(t(z),{ref_key:"formRef",ref:f,model:r,rules:b,size:"medium","show-label":!1,onKeyup:x(h,["enter"])},{default:l(()=>[o(t(g),{path:"username"},{default:l(()=>[o(t(w),{value:r.username,"onUpdate:value":n[0]||(n[0]=a=>r.username=a),placeholder:s("Username"),"input-props":{autocomplete:"username"}},{prefix:l(()=>[o(t(v),{icon:"tabler:user"})]),_:1},8,["value","placeholder"])]),_:1}),o(t(g),{path:"password"},{default:l(()=>[o(t(w),{value:r.password,"onUpdate:value":n[1]||(n[1]=a=>r.password=a),type:"password",placeholder:s("Password"),"input-props":{autocomplete:"current-password"},"show-password-on":"click"},{prefix:l(()=>[o(t(v),{icon:"tabler:lock"})]),_:1},8,["value","placeholder"])]),_:1}),o(t(g),null,{default:l(()=>[o(t(B),{type:"primary",size:"large",block:"",loading:d.value,onClick:h,class:"brand-button"},{default:l(()=>[U(_(s("Login")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])]))}}),W=V(E,[["__scopeId","data-v-54889905"]]);export{W as default};
