import{d as P,r as u,H as S,z as j,c as x,a as e,w as a,a$ as h,a0 as q,B as _,Z as T,b0 as H,b1 as J,h as d,t as R,i as K,b2 as O,b as c,q as Y,aY as Z,J as G,K as Q,b3 as W,b4 as ee,L as le,C as f,a8 as ae,o as v}from"./index-DqVhJ65C.js";/* empty css               *//* empty css                  *//* empty css                     *//* empty css                  *//* empty css                *//* empty css                        *//* empty css                    */import"./el-tooltip-l0sNRNKZ.js";const te={class:"p-6"},oe={class:"flex items-center justify-between"},se={key:1},ne={class:"mb-4 flex items-center justify-between"},re={class:"flex items-center gap-4"},de={class:"text-lg font-bold"},ie={class:"dialog-footer"},we=P({__name:"DomainManager",setup(ue){const V=u([]),r=u(null),k=u([]),b=u(!1),m=u(!1),y=u(!1),s=S({type:"A",rr:"",value:""}),C=async()=>{try{const t=await _.get("/domain/records");t.code===0&&(V.value=t.data)}catch(t){console.error(t)}},D=async t=>{r.value=t,g()},g=async()=>{if(r.value){b.value=!0;try{const t=await _.get(`/domain/${r.value.id}/records`);t.code===0?k.value=t.data:f.error(t.message)}catch(t){console.error(t)}finally{b.value=!1}}},M=()=>{s.type="A",s.rr="",s.value="",m.value=!0},B=async()=>{if(!s.rr||!s.value){f.warning("请填写完整");return}y.value=!0;try{const t=await _.post("/domain/record",{domain_id:r.value.id,...s});t.code===0?(f.success("添加成功"),m.value=!1,g()):f.error(t.message)}catch(t){console.error(t)}finally{y.value=!1}},$=t=>{ae.confirm("确定要删除这条解析记录吗？","提示",{type:"warning"}).then(async()=>{try{(await _.delete(`/domain/record/${t.RecordId}`,{params:{domain_id:r.value.id}})).code===0&&(f.success("删除成功"),g())}catch(l){console.error(l)}})};return j(()=>{C()}),(t,l)=>{const i=K,n=H,I=J,E=O,N=h,p=ee,F=W,w=Q,A=le,L=G,U=q,X=Z;return v(),x("div",te,[e(N,{shadow:"never",class:"!rounded-xl border-none"},{header:a(()=>[c("div",oe,[l[7]||(l[7]=c("span",{class:"text-lg font-bold"},"我的域名",-1)),e(i,{type:"primary",onClick:C},{default:a(()=>[...l[6]||(l[6]=[d("刷新列表",-1)])]),_:1})])]),default:a(()=>[r.value?(v(),x("div",se,[c("div",ne,[c("div",re,[e(i,{link:"",onClick:l[0]||(l[0]=o=>r.value=null)},{default:a(()=>[...l[9]||(l[9]=[d("← 返回域名列表",-1)])]),_:1}),c("h3",de,R(r.value.domain)+" 解析设置",1)]),e(i,{type:"primary",onClick:M},{default:a(()=>[...l[10]||(l[10]=[d("添加记录",-1)])]),_:1})]),Y((v(),T(E,{data:k.value},{default:a(()=>[e(n,{prop:"RR",label:"主机记录 (RR)"}),e(n,{prop:"Type",label:"记录类型"}),e(n,{prop:"Value",label:"记录值"}),e(n,{prop:"TTL",label:"TTL"}),e(n,{label:"操作",width:"150"},{default:a(o=>[e(i,{size:"small",type:"danger",link:"",onClick:z=>$(o.row)},{default:a(()=>[...l[11]||(l[11]=[d("删除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[X,b.value]])])):(v(),T(E,{key:0,data:V.value,style:{width:"100%"}},{default:a(()=>[e(n,{prop:"domain",label:"域名"}),e(n,{prop:"created_at",label:"注册时间"}),e(n,{prop:"expired_at",label:"过期时间"}),e(n,{prop:"status",label:"状态"},{default:a(o=>[e(I,{type:o.row.status===1?"success":"danger"},{default:a(()=>[d(R(o.row.status===1?"正常":"已暂停"),1)]),_:2},1032,["type"])]),_:1}),e(n,{label:"操作",width:"200"},{default:a(o=>[e(i,{size:"small",type:"primary",onClick:z=>D(o.row)},{default:a(()=>[...l[8]||(l[8]=[d("解析管理",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"]))]),_:1}),e(U,{modelValue:m.value,"onUpdate:modelValue":l[5]||(l[5]=o=>m.value=o),title:"添加解析记录",width:"500px"},{footer:a(()=>[c("span",ie,[e(i,{onClick:l[4]||(l[4]=o=>m.value=!1)},{default:a(()=>[...l[12]||(l[12]=[d("取消",-1)])]),_:1}),e(i,{type:"primary",loading:y.value,onClick:B},{default:a(()=>[...l[13]||(l[13]=[d("确定",-1)])]),_:1},8,["loading"])])]),default:a(()=>[e(L,{model:s,"label-width":"100px"},{default:a(()=>[e(w,{label:"记录类型"},{default:a(()=>[e(F,{modelValue:s.type,"onUpdate:modelValue":l[1]||(l[1]=o=>s.type=o),class:"w-full"},{default:a(()=>[e(p,{value:"A",label:"A - 将域名指向一个IPV4地址"}),e(p,{value:"CNAME",label:"CNAME - 将域名指向另外一个域名"}),e(p,{value:"TXT",label:"TXT - 文本长度限制512，通常做SPF记录"}),e(p,{value:"MX",label:"MX - 邮件交换记录"}),e(p,{value:"AAAA",label:"AAAA - 将域名指向一个IPV6地址"})]),_:1},8,["modelValue"])]),_:1}),e(w,{label:"主机记录"},{default:a(()=>[e(A,{modelValue:s.rr,"onUpdate:modelValue":l[2]||(l[2]=o=>s.rr=o),placeholder:"例如: www"},null,8,["modelValue"])]),_:1}),e(w,{label:"记录值"},{default:a(()=>[e(A,{modelValue:s.value,"onUpdate:modelValue":l[3]||(l[3]=o=>s.value=o),placeholder:"例如: 1.1.1.1"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])])}}});export{we as default};
