import{d as G,r as d,H as L,z as O,c as $,a as l,w as o,a$ as P,a0 as q,B as c,q as H,aY as J,Z as U,b0 as Z,b1 as Q,h as n,t as W,i as X,b2 as h,b as f,J as ee,K as le,L as te,b3 as oe,F as ae,j as se,b4 as ne,be as re,C as i,a8 as ie,o as v}from"./index-DqVhJ65C.js";/* empty css                 *//* empty css               *//* empty css                  *//* empty css                     *//* empty css                  *//* empty css                *//* empty css                        *//* empty css                    */import"./el-tooltip-l0sNRNKZ.js";const de={class:"p-6"},pe={class:"flex items-center justify-between"},ue={class:"space-x-2"},me={class:"dialog-footer"},ce={class:"dialog-footer"},xe=G({__name:"SslManager",setup(fe){const k=d([]),b=d(!1),p=d(!1),u=d(!1),g=d(!1),E=d(!1),C=d([]),r=L({cert:"",key:""}),_=L({domain_id:""}),y=async()=>{b.value=!0;try{const t=await c.get("/ssl/certificates");t.code===0&&(k.value=t.data)}catch(t){console.error(t)}finally{b.value=!1}},D=async()=>{try{const t=await c.get("/domain/records");t.code===0&&(C.value=t.data)}catch(t){console.error(t)}},F=async()=>{if(!r.cert||!r.key)return i.warning("请填写完整");g.value=!0;try{const t=await c.post("/ssl/upload",r);t.code===0?(i.success("上传成功"),p.value=!1,y()):i.error(t.message)}catch(t){console.error(t)}finally{g.value=!1}},I=async()=>{if(!_.domain_id)return i.warning("请选择域名");E.value=!0;try{const t=await c.post("/ssl/apply",_);t.code===0?(i.success("申请成功"),u.value=!1,y()):i.error(t.message)}catch{i.error("申请失败")}finally{E.value=!1}},T=t=>{ie.confirm("确定删除此证书吗？","提示",{type:"warning"}).then(async()=>{(await c.post(`/ssl/delete/${t.id}`)).code===0&&(i.success("删除成功"),y())})},N=t=>{const e=document.createElement("a"),s=new Blob([t.cert+`
`+t.key],{type:"text/plain"});e.href=URL.createObjectURL(s),e.download=`${t.domain}.pem`,document.body.appendChild(e),e.click()};return O(()=>{y(),D()}),(t,e)=>{const s=X,m=Z,S=Q,M=h,A=P,V=te,w=le,x=ee,B=q,R=ne,j=oe,z=re,K=J;return v(),$("div",de,[l(A,{shadow:"never",class:"!rounded-xl border-none"},{header:o(()=>[f("div",pe,[e[11]||(e[11]=f("span",{class:"text-lg font-bold"},"SSL 证书管理",-1)),f("div",ue,[l(s,{onClick:e[0]||(e[0]=a=>p.value=!0)},{default:o(()=>[...e[9]||(e[9]=[n("上传证书",-1)])]),_:1}),l(s,{type:"primary",onClick:e[1]||(e[1]=a=>u.value=!0)},{default:o(()=>[...e[10]||(e[10]=[n("申请证书",-1)])]),_:1})])])]),default:o(()=>[H((v(),U(M,{data:k.value,style:{width:"100%"}},{default:o(()=>[l(m,{prop:"domain",label:"域名"}),l(m,{prop:"provider",label:"来源"},{default:o(a=>[l(S,{type:a.row.provider==="letsencrypt"?"success":"info"},{default:o(()=>[n(W(a.row.provider==="letsencrypt"?"Let's Encrypt":"手动上传"),1)]),_:2},1032,["type"])]),_:1}),l(m,{prop:"expire_at",label:"过期时间"}),l(m,{prop:"created_at",label:"创建时间"}),l(m,{label:"操作",width:"150"},{default:o(a=>[l(s,{size:"small",type:"danger",link:"",onClick:Y=>T(a.row)},{default:o(()=>[...e[12]||(e[12]=[n("删除",-1)])]),_:1},8,["onClick"]),l(s,{size:"small",type:"primary",link:"",onClick:Y=>N(a.row)},{default:o(()=>[...e[13]||(e[13]=[n("下载",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[K,b.value]])]),_:1}),l(B,{modelValue:p.value,"onUpdate:modelValue":e[5]||(e[5]=a=>p.value=a),title:"上传证书",width:"600px"},{footer:o(()=>[f("span",me,[l(s,{onClick:e[4]||(e[4]=a=>p.value=!1)},{default:o(()=>[...e[14]||(e[14]=[n("取消",-1)])]),_:1}),l(s,{type:"primary",loading:g.value,onClick:F},{default:o(()=>[...e[15]||(e[15]=[n("提交",-1)])]),_:1},8,["loading"])])]),default:o(()=>[l(x,{model:r,"label-position":"top"},{default:o(()=>[l(w,{label:"证书内容 (PEM格式)"},{default:o(()=>[l(V,{modelValue:r.cert,"onUpdate:modelValue":e[2]||(e[2]=a=>r.cert=a),type:"textarea",rows:5,placeholder:"-----BEGIN CERTIFICATE-----..."},null,8,["modelValue"])]),_:1}),l(w,{label:"私钥内容 (KEY格式)"},{default:o(()=>[l(V,{modelValue:r.key,"onUpdate:modelValue":e[3]||(e[3]=a=>r.key=a),type:"textarea",rows:5,placeholder:"-----BEGIN PRIVATE KEY-----..."},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"]),l(B,{modelValue:u.value,"onUpdate:modelValue":e[8]||(e[8]=a=>u.value=a),title:"申请证书 (Let's Encrypt)",width:"500px"},{footer:o(()=>[f("span",ce,[l(s,{onClick:e[7]||(e[7]=a=>u.value=!1)},{default:o(()=>[...e[16]||(e[16]=[n("取消",-1)])]),_:1}),l(s,{type:"primary",loading:E.value,onClick:I},{default:o(()=>[...e[17]||(e[17]=[n("立即申请",-1)])]),_:1},8,["loading"])])]),default:o(()=>[l(x,{"label-position":"top"},{default:o(()=>[l(w,{label:"选择域名"},{default:o(()=>[l(j,{modelValue:_.domain_id,"onUpdate:modelValue":e[6]||(e[6]=a=>_.domain_id=a),placeholder:"请选择域名",class:"w-full"},{default:o(()=>[(v(!0),$(ae,null,se(C.value,a=>(v(),U(R,{key:a.id,label:a.domain,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),l(z,{title:"申请过程约需 1-2 分钟，请确保域名的 DNS 解析已指向本平台。",type:"info",closable:!1})]),_:1})]),_:1},8,["modelValue"])])}}});export{xe as default};
