mirror of https://github.com/allinssl/allinssl
2 lines
5.0 KiB
JavaScript
2 lines
5.0 KiB
JavaScript
import{e,s as t,r as a,$ as r,d as o,c as l,g as s,h as n,N as i,B as c,j as d,k as u,i as p,y as _,m,z as f,a as y,o as h,P as g,b as x,t as w}from"./main-CTqwUdcf.js";import{u as C,a as v,b as k}from"./index-CWVIgfaI.js";import{g as b,u as j,d as E}from"./cert-CuNCbt8_.js";import{B as U}from"./index-D5VvKhY-.js";import{E as z,S as F,P}from"./index-ELdrPbNv.js";import{a as T}from"./index-DEagw1eo.js";const{handleError:q}=C(),N=e("cert-manage-store",(()=>{const e=a({cert:"",key:""});return{uploadForm:e,fetchCertList:async e=>{try{const{data:t,count:a}=await b(e).fetch();return{list:t||[],total:a}}catch(t){return q(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){q(t).default(r("t_38_1745227838813"))}},uploadNewCert:async e=>{try{const{message:t,fetch:a}=j(e);t.value=!0,await a()}catch(t){q(t)}},deleteExistingCert:async e=>{try{const{message:t,fetch:a}=E({id:e});t.value=!0,await a()}catch(t){q(t)}},resetUploadForm:()=>{e.value={cert:"",key:""}}}})),S=o({name:"UploadCert",setup(){const{UploadCertForm:e}=$();return()=>l(e,{labelPlacement:"top"},null)}});function B(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!p(e)}const{handleError:L}=C(),{useFormTextarea:M}=m(),{fetchCertList:O,downloadExistingCert:V,deleteExistingCert:H,uploadNewCert:R,uploadForm:A,resetUploadForm:G}=(()=>{const e=N();return{...e,...t(e)}})(),{confirm:K}=f(),$=()=>{const{open:e,close:t}=k({text:r("t_0_1746667592819")}),{example:a,component:o,loading:l,fetch:s}=_({config:[M(r("t_34_1745227839375"),"cert",{placeholder:r("t_35_1745227839208"),rows:6}),M(r("t_36_1745227838958"),"key",{placeholder:r("t_37_1745227839669"),rows:6})],request:R,defaultValue:A,rules:{cert:[{required:!0,message:r("t_35_1745227839208"),trigger:"input"}],key:[{required:!0,message:r("t_37_1745227839669"),trigger:"input"}]}});return K((async a=>{try{e(),await s(),a()}catch(r){L(r)}finally{t()}})),{UploadCertForm:o,example:a,loading:l,fetch:s}},D=o({name:"CertManage",setup(){const{CertTable:e,CertTablePage:t,fetch:a,data:o,param:p,openUploadModal:_}=(()=>{const{component:e,loading:t,param:a,data:o,total:p,fetch:_}=s({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,s,n]=a.find((e=>e[0]))??["default","error","获取失败"];return l(i,{type:s,size:"small"},B(n)?n:{default:()=>[n]})}},{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:150,render:e=>{let t,a;return l(d,{justify:"end"},{default:()=>[l(c,{style:{"--n-text-color":"var(--text-color-3)"},size:"tiny",strong:!0,secondary:!0,onClick:()=>V(e.id)},B(t=r("t_25_1745227838080"))?t:{default:()=>[t]}),l(c,{size:"tiny",strong:!0,secondary:!0,type:"error",onClick:()=>f(e)},B(a=r("t_12_1745215914312"))?a:{default:()=>[a]})]})}}],request:O,defaultValue:{p:1,limit:10,search:""},watchValue:["p","limit"]}),{component:m}=n({param:a,total:p,alias:{page:"p",pageSize:"limit"}}),f=async({id:e})=>{v({title:r("t_29_1745227838410"),content:r("t_30_1745227841739"),onPositiveClick:async()=>{try{await H(e),await _()}catch(t){L(t)}}})};return{loading:t,fetch:_,CertTable:e,CertTablePage:m,param:a,data:o,openUploadModal:()=>{u({title:r("t_13_1745227838275"),area:600,component:S,footer:!0,onUpdateShow:e=>{e||_(),G()}})}}})(),m=y(["contentPadding","borderColor","headerHeight","iconColorHover"]);h((()=>a()));const{theme:f,themeOverrides:C}=g();return()=>l("div",{class:"h-full flex flex-col",style:m.value},[l("div",{class:"mx-auto max-w-[1600px] w-full p-6"},[l(U,null,{headerLeft:()=>l(c,{type:"primary",size:"large",class:"px-5",onClick:_},{default:()=>[l(P,{class:"text-[var(--text-color-3)] w-[1.6rem]"},null),l("span",{class:"px-2"},[r("t_13_1745227838275")])]}),headerRight:()=>l(w,{value:p.value.search,"onUpdate:value":e=>p.value.search=e,onKeydown:e=>{"Enter"===e.key&&a()},onClear:()=>T(a,100),placeholder:r("t_14_1745227840904"),clearable:!0,size:"large",class:"min-w-[300px]"},{suffix:()=>l("div",{class:"flex items-center",onClick:a},[l(F,{class:"text-[var(--text-color-3)] w-[1.6rem] cursor-pointer font-bold"},null)])}),content:()=>l("div",{class:"rounded-lg"},[l(e,{size:"medium"},{empty:()=>l(z,{addButtonText:r("t_1_1747047213009"),onAddClick:_},null)})]),footerRight:()=>l("div",{class:"mt-4 flex justify-end"},[l(t,null,{prefix:()=>l("span",null,[r("t_15_1745227839354"),x(" "),o.value.total,x(" "),r("t_16_1745227838930")])})])})])])}});export{D as default};
|