import{d as j,r as f,z as L,c as x,A as U,b as n,F as q,j as R,t as D,B as h,C as S,o as y,D as G,G as Q,H as z,a as t,w as a,I as H,J as T,h as c,K as Y,L as A,E as J,u as N,M as K,m as O,N as P,g as W,i as X,O as Z,P as ee,Q as k}from"./index-DqVhJ65C.js";/* empty css                   *//* empty css                    */import{C as te}from"./Captcha-hQQe1ifD.js";const se={key:0,class:"flex flex-col items-center"},oe={class:"flex gap-4 justify-center flex-wrap"},ae=["onClick","title"],ne={class:"text-xs font-bold"},le=j({__name:"SocialLogin",setup($){const g=f(!0),d=f([]),m={qq:{name:"QQ",icon:"icon-qq"},wx:{name:"微信",icon:"icon-wechat"},alipay:{name:"支付宝",icon:"icon-alipay"},douyin:{name:"抖音",icon:"icon-douyin"},github:{name:"GitHub",icon:"icon-github"},google:{name:"Google",icon:"icon-google"}},w=async()=>{try{const o=await h.get("/auth/social/config");o.code===0&&o.data.providers&&(d.value=o.data.providers)}catch(o){console.error(o)}finally{g.value=!1}},s=async o=>{try{const l=await h.get("/auth/social/url",{params:{provider:o}});l.code===0&&l.data.url?window.location.href=l.data.url:S.error("获取跳转链接失败")}catch(l){S.error(l.message||"系统错误")}};return L(w),(o,l)=>d.value.length>0?(y(),x("div",se,[n("div",oe,[(y(!0),x(q,null,R(d.value,r=>{var _,v;return y(),x("button",{key:r,onClick:C=>s(r),class:"w-10 h-10 rounded-full bg-gray-100 flex items-center justify-center hover:bg-blue-50 hover:text-blue-600 transition-colors",title:((_=m[r])==null?void 0:_.name)||r},[n("span",ne,D((((v=m[r])==null?void 0:v.name)||r).substring(0,1)),1)],8,ae)}),128))])])):U("",!0)}}),re={class:"h-screen w-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900"},ie={class:"w-full max-w-md bg-white dark:bg-gray-800 rounded-lg shadow-md p-8"},ue={class:"flex justify-between items-center text-sm"},ce={class:"flex justify-center"},de={class:"mt-4 text-center text-sm text-gray-500"},me={class:"fixed bottom-0 w-full p-4 text-center"},fe={class:"text-sm text-gray-400 flex justify-center items-center gap-1"},xe=j({__name:"Login",setup($){const g=ee(),d=G(),m=f(!1),w=Q(()=>new Date().getFullYear()),s=z({username:"",password:"",remember:!1}),o=f(null),l=f(null),r=f(null),_=async()=>{try{const i=await h.get("/auth/captcha");o.value=i.data}catch(i){console.error(i)}},v=i=>{l.value=i},C=async()=>{var i,e;if(!s.username||!s.password)return k.warning("请输入账号和密码");if((i=o.value)!=null&&i.enabled&&!l.value)return k.warning("请先完成安全验证");m.value=!0;try{const u=await h.post("/auth/login",{username:s.username,password:s.password,...l.value||{}});u.code===0&&(k.success("登录成功，欢迎回来"),d.setToken(u.data.token),d.setUserInfo(u.data.user),d.setLoginStatus(!0),(u.data.user.role||"user")==="admin"?g.push("/admin/dashboard"):g.push("/dashboard"))}catch(u){console.error(u),l.value=null,(e=r.value)==null||e.reset()}finally{m.value=!1}};return L(()=>{_()}),(i,e)=>{const u=J,b=A,V=Y,B=P,E=W("router-link"),F=X,I=Z,M=T;return y(),x("div",re,[n("div",ie,[e[9]||(e[9]=n("div",{class:"text-center mb-8"},[n("h2",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"NewDNS"),n("p",{class:"text-sm text-gray-500 mt-2"},"专业的二级域名分发平台")],-1)),t(M,{class:"space-y-4",size:"large",onSubmit:H(C,["prevent"])},{default:a(()=>[t(V,null,{default:a(()=>[t(b,{modelValue:s.username,"onUpdate:modelValue":e[0]||(e[0]=p=>s.username=p),placeholder:"请输入用户名/邮箱/手机号",class:"!rounded-md"},{prefix:a(()=>[t(u,null,{default:a(()=>[t(N(K))]),_:1})]),_:1},8,["modelValue"])]),_:1}),t(V,null,{default:a(()=>[t(b,{modelValue:s.password,"onUpdate:modelValue":e[1]||(e[1]=p=>s.password=p),type:"password",placeholder:"请输入密码","show-password":"",class:"!rounded-md"},{prefix:a(()=>[t(u,null,{default:a(()=>[t(N(O))]),_:1})]),_:1},8,["modelValue"])]),_:1}),n("div",ue,[t(B,{modelValue:s.remember,"onUpdate:modelValue":e[2]||(e[2]=p=>s.remember=p)},{default:a(()=>[...e[3]||(e[3]=[c("记住我",-1)])]),_:1},8,["modelValue"]),t(E,{to:"/forgot-password",class:"text-blue-600 hover:underline"},{default:a(()=>[...e[4]||(e[4]=[c("忘记密码？",-1)])]),_:1})]),n("div",ce,[t(te,{ref_key:"captchaRef",ref:r,config:o.value,onSuccess:v},null,8,["config"])]),t(F,{type:"primary","native-type":"submit",class:"w-full !rounded-md",loading:m.value},{default:a(()=>[...e[5]||(e[5]=[c(" 登录 ",-1)])]),_:1},8,["loading"]),n("div",de,[e[7]||(e[7]=c(" 还没有账号？ ",-1)),t(E,{to:"/register",class:"text-blue-600 hover:underline"},{default:a(()=>[...e[6]||(e[6]=[c("立即注册",-1)])]),_:1})]),t(I,null,{default:a(()=>[...e[8]||(e[8]=[c("社交账号登录",-1)])]),_:1}),t(le)]),_:1})]),n("div",me,[n("div",fe,[e[10]||(e[10]=c(" Copyright ",-1)),e[11]||(e[11]=n("span",{class:"text-base"},"©",-1)),c(" "+D(w.value)+" 新云DNS系统 ",1)])])])}}});export{xe as default};
