mirror of https://github.com/allinssl/allinssl
2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
import{e,s as t,r as a,$ as r,g as o,h as l,c as n,N as s,B as i,b as c,j as d,k as u,i as p,y as m,m as _,z as y,ab as f,d as g,a as h,o as w,ac as C,t as x}from"./main-BO_qvVyv.js";import{u as k,a as b,b as v}from"./index-fspvPnRK.js";import{g as j,u as z,d as E}from"./cert-Dqp0xB-w.js";import{B as F}from"./index-CT47IChd.js";import{E as N,S as U}from"./index-B1WGBnOF.js";import{a as S}from"./index-kqNzwJC_.js";const{handleError:T}=k(),V=e("cert-manage-store",(()=>{const e=a({cert_id:"",cert:"",key:""});return{uploadForm:e,fetchCertList:async e=>{try{const{data:t,count:a}=await j(e).fetch();return{list:t||[],total:a}}catch(t){return T(t),{list:[],total:0}}},downloadExistingCert:e=>{try{const t=document.createElement("a");t.href="/v1/cert/download?id="+e,t.target="_blank",t.click()}catch(t){T(t).default(r("t_38_1745227838813"))}},uploadNewCert:async e=>{try{const{message:t,fetch:a}=z(e);t.value=!0,await a()}catch(t){T(t)}},deleteExistingCert:async e=>{try{const{message:t,fetch:a}=E({id:e});t.value=!0,await a()}catch(t){T(t)}},resetUploadForm:()=>{e.value={cert:"",key:""}}}}));function P(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!p(e)}const{handleError:O}=k(),{useFormTextarea:q}=_(),{fetchCertList:M,downloadExistingCert:R,deleteExistingCert:B,uploadNewCert:L,uploadForm:H,resetUploadForm:A}=(()=>{const e=V();return{...e,...t(e)}})(),{confirm:I}=y(),K=()=>{const{open:e,close:t}=v({text:r("t_0_1746667592819")}),{example:a,component:o,loading:l,fetch:n}=m({config:[q(r("t_34_1745227839375"),"cert",{placeholder:r("t_35_1745227839208"),rows:6}),q(r("t_36_1745227838958"),"key",{placeholder:r("t_37_1745227839669"),rows:6})],request:L,defaultValue:H,rules:{cert:[{required:!0,message:r("t_35_1745227839208"),trigger:"input"}],key:[{required:!0,message:r("t_37_1745227839669"),trigger:"input"}]}});return I((async a=>{try{e(),await n(),a()}catch(r){O(r)}finally{t()}})),{UploadCertForm:o,example:a,loading:l,fetch:n}},$=e=>{const t=async e=>{const t=f();try{await navigator.clipboard.writeText(e),t.success("复制成功")}catch(a){try{const a=document.createElement("textarea");a.value=e,document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),t.success("复制成功")}catch(r){t.error("复制失败")}}},a=e.cert+(e.issuer_cert?"\n"+e.issuer_cert:""),{component:o}=m({config:[q(r("t_34_1745227839375"),"cert",{placeholder:"",rows:8,readonly:!0},{},{suffix:[()=>{let e;return n(i,{size:"tiny",type:"primary",ghost:!0,onClick:()=>t(a)},P(e=r("t_4_1747984130327"))?e:{default:()=>[e]})}]}),q(r("t_36_1745227838958"),"key",{placeholder:"",rows:8,readonly:!0},{},{suffix:[()=>{let a;return n(i,{size:"tiny",type:"primary",ghost:!0,onClick:()=>t(e.key)},P(a=r("t_4_1747984130327"))?a:{default:()=>[a]})}]})],defaultValue:{cert:a,key:e.key}});return{ViewCertForm:o}};const D=g({name:"CertManage",setup(){const{CertTable:e,CertTablePage:t,fetch:a,data:m,param:_,openUploadModal:y,getRowClassName:f}=(()=>{const{component:e,loading:t,param:a,data:p,total:m,fetch:_}=o({config:[{title:r("t_17_1745227838561"),key:"domains",width:200,ellipsis:{tooltip:!0}},{title:r("t_18_1745227838154"),key:"issuer",width:200,ellipsis:{tooltip:!0}},{title:r("t_21_1745227837972"),key:"source",width:100,render:e=>"upload"!==e.source?r("t_22_1745227838154"):r("t_23_1745227838699")},{title:r("t_19_1745227839107"),key:"end_day",width:100,render:e=>{const t=Number(e.end_day),a=[[t<=0,"error",r("t_0_1746001199409")],[t<30,"warning",r("t_1_1745999036289",{days:e.end_day})],[t>30,"success",r("t_0_1745999035681",{days:e.end_day})]],[o,l,i]=a.find((e=>e[0]))??["default","error","获取失败"];return n(s,{type:l,size:"small"},P(i)?i:{default:()=>[i]})}},{title:r("t_20_1745227838813"),key:"end_time",width:150},{title:r("t_24_1745227839508"),key:"create_time",width:150},{title:r("t_8_1745215914610"),key:"actions",fixed:"right",align:"right",width:200,render:e=>{let t,a;return n(d,{justify:"end"},{default:()=>[n(i,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>g(e)},{default:()=>[c("查看")]}),n(i,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>R(e.id.toString())},P(t=r("t_25_1745227838080"))?t:{default:()=>[t]}),n(i,{size:"tiny",strong:!0,secondary:!0,type:"error",onClick:()=>f(e)},P(a=r("t_12_1745215914312"))?a:{default:()=>[a]})]})}}],request:M,defaultValue:{p:1,limit:10,search:""},watchValue:["p","limit"]}),{component:y}=l({param:a,total:m,alias:{page:"p",pageSize:"limit"}}),f=async({id:e})=>{b({title:r("t_29_1745227838410"),content:r("t_30_1745227841739"),onPositiveClick:async()=>{try{await B(e.toString()),await _()}catch(t){O(t)}}})},g=e=>{u({title:"查看证书信息",area:600,component:()=>{const{ViewCertForm:t}=$(e);return n(t,{labelPlacement:"top"},null)},footer:!1})};return{loading:t,fetch:_,CertTable:e,CertTablePage:y,getRowClassName:e=>{const t=Number(e.end_day);return t<=0?"bg-red-500/10":t<30?"bg-orange-500/10":""},param:a,data:p,openUploadModal:()=>{u({title:r("t_13_1745227838275"),area:600,component:()=>{const{UploadCertForm:e}=K();return n(e,{labelPlacement:"top"},null)},footer:!0,onUpdateShow:e=>{e||_(),A()}})},openViewModal:g}})(),g=h(["contentPadding","borderColor","headerHeight","iconColorHover"]);w((()=>a()));const{theme:k,themeOverrides:v}=C();return()=>n("div",{class:"h-full flex flex-col",style:g.value},[n("div",{class:"mx-auto max-w-[1600px] w-full p-6"},[n(F,null,{headerLeft:()=>{let e;return n(i,{type:"primary",size:"large",class:"px-5",onClick:y},"function"==typeof(t=e=r("t_13_1745227838275"))||"[object Object]"===Object.prototype.toString.call(t)&&!p(t)?e:{default:()=>[e]});var t},headerRight:()=>n(x,{value:_.value.search,"onUpdate:value":e=>_.value.search=e,onKeydown:e=>{"Enter"===e.key&&a()},onClear:()=>S(a,100),placeholder:r("t_14_1745227840904"),clearable:!0,size:"large",class:"min-w-[300px]"},{suffix:()=>n("div",{class:"flex items-center",onClick:a},[n(U,{class:"text-[var(--text-color-3)] w-[1.6rem] cursor-pointer font-bold"},null)])}),content:()=>n("div",{class:"rounded-lg"},[n(e,{size:"medium",rowClassName:f},{empty:()=>n(N,{addButtonText:r("t_1_1747047213009"),onAddClick:y},null)})]),footerRight:()=>n("div",{class:"mt-4 flex justify-end"},[n(t,null,{prefix:()=>n("span",null,[r("t_15_1745227839354"),c(" "),m.value.total,c(" "),r("t_16_1745227838930")])})])})])])}});export{D as default};
|