import{d as E,r as g,H as A,z as B,c as _,a as s,w as a,a$ as I,B as y,J as K,K as P,L as h,b as t,t as c,i as $,h as f,O as F,C as d,o as w}from"./index-DqVhJ65C.js";/* empty css                *//* empty css                   */const N={class:"p-6"},S={class:"text-xl font-bold text-red-500 mr-2"},U={key:0,class:"bg-gray-50 p-4 rounded border border-gray-200"},D={class:"mb-2"},M={class:"font-mono font-bold"},z={class:"font-mono"},H={key:1},j=E({__name:"Profile",setup(J){const n=g({}),p=g(!1),o=A({password:"",confirm:""}),v=async()=>{try{const l=await y.get("/user/info");l.code===0&&(n.value=l.data)}catch{}},k=async()=>{if(!o.password)return d.warning("请输入新密码");if(o.password!==o.confirm)return d.warning("两次输入不一致");try{await y.post("/user/change_password",{password:o.password}),d.success("密码修改成功"),o.password="",o.confirm=""}catch(l){d.error(l.message)}},x=async()=>{try{await y.post("/user/generate_api_key"),d.success("生成的密钥"),v()}catch(l){d.error(l.message)}};return B(()=>{v()}),(l,e)=>{const u=h,r=P,m=$,V=F,C=K,b=I;return w(),_("div",N,[s(b,{shadow:"hover"},{header:a(()=>[...e[4]||(e[4]=[t("span",{class:"font-bold"},"个人资料",-1)])]),default:a(()=>[s(C,{"label-width":"100px",class:"max-w-md mt-4"},{default:a(()=>[s(r,{label:"用户名"},{default:a(()=>[s(u,{value:n.value.username,disabled:""},null,8,["value"])]),_:1}),s(r,{label:"邮箱"},{default:a(()=>[s(u,{value:n.value.email,disabled:""},null,8,["value"])]),_:1}),s(r,{label:"当前余额"},{default:a(()=>[t("span",S,"¥"+c(n.value.balance),1),s(m,{link:"",type:"primary",onClick:e[0]||(e[0]=i=>l.$router.push("/dashboard/recharge"))},{default:a(()=>[...e[5]||(e[5]=[f("充值",-1)])]),_:1})]),_:1}),s(V),s(r,{label:"新密码"},{default:a(()=>[s(u,{modelValue:o.password,"onUpdate:modelValue":e[1]||(e[1]=i=>o.password=i),type:"password","show-password":""},null,8,["modelValue"])]),_:1}),s(r,{label:"确认密码"},{default:a(()=>[s(u,{modelValue:o.confirm,"onUpdate:modelValue":e[2]||(e[2]=i=>o.confirm=i),type:"password","show-password":""},null,8,["modelValue"])]),_:1}),s(r,null,{default:a(()=>[s(m,{type:"primary",onClick:k},{default:a(()=>[...e[6]||(e[6]=[f("修改密码",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),s(b,{shadow:"hover",class:"mt-6"},{header:a(()=>[...e[7]||(e[7]=[t("span",{class:"font-bold"},"API 密钥 (AccessKey)",-1)])]),default:a(()=>[e[11]||(e[11]=t("div",{class:"text-sm text-gray-500 mb-4"},"用于通过 API 管理您的域名。请妥善保管，不要泄露。",-1)),n.value.api_key?(w(),_("div",U,[t("div",D,[e[8]||(e[8]=t("span",{class:"text-gray-500 w-24 inline-block"},"Access Key:",-1)),t("span",M,c(n.value.api_key),1)]),t("div",null,[e[9]||(e[9]=t("span",{class:"text-gray-500 w-24 inline-block"},"Secret Key:",-1)),t("span",z,c(p.value?n.value.api_secret:"****************"),1),s(m,{link:"",type:"primary",class:"ml-2",onClick:e[3]||(e[3]=i=>p.value=!p.value)},{default:a(()=>[f(c(p.value?"隐藏":"显示"),1)]),_:1})])])):(w(),_("div",H,[s(m,{type:"primary",onClick:x},{default:a(()=>[...e[10]||(e[10]=[f("生成 API 密钥",-1)])]),_:1})]))]),_:1})])}}});export{j as default};
