allinssl/build/static/js/index-DgfLI14O.js

2 lines
5.8 KiB
JavaScript

import{e,s as t,r as a,$ as r,g as o,o as n,c as l,N as s,B as i,b as c,h as d,j as u,i as p,y as m,l as _,z as y,f as g,d as f,a as h}from"./main-NRDg9AeD.js";import{u as C,E as w}from"./index-8FlkV-pQ.js";import{u as x,a as k,b}from"./index-Md2o7o2t.js";import{g as v,u as j,d as z}from"./cert-BtMV0YxJ.js";import{B as S}from"./index-C3jVa6BN.js";const{handleError:E}=x(),F=e("cert-manage-store",(()=>{const e=a({cert_id:"",cert:"",key:""});return{uploadForm:e,fetchCertList:async e=>{try{const{data:t,count:a}=await v(e).fetch();return{list:t||[],total:a}}catch(t){return E(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){E(t).default(r("t_38_1745227838813"))}},uploadNewCert:async e=>{try{const{message:t,fetch:a}=j(e);t.value=!0,await a()}catch(t){E(t)}},deleteExistingCert:async e=>{try{const{message:t,fetch:a}=z({id:e});t.value=!0,await a()}catch(t){E(t)}},resetUploadForm:()=>{e.value={cert:"",key:""}}}}));function N(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!p(e)}const{handleError:P}=x(),{useFormTextarea:U}=_(),{fetchCertList:V,downloadExistingCert:T,deleteExistingCert:M,uploadNewCert:q,uploadForm:O,resetUploadForm:R}=(()=>{const e=F();return{...e,...t(e)}})(),{confirm:B}=y(),L=()=>{const{open:e,close:t}=b({text:r("t_0_1746667592819")}),{example:a,component:o,loading:n,fetch:l}=m({config:[U(r("t_34_1745227839375"),"cert",{placeholder:r("t_35_1745227839208"),rows:6}),U(r("t_36_1745227838958"),"key",{placeholder:r("t_37_1745227839669"),rows:6})],request:q,defaultValue:O,rules:{cert:[{required:!0,message:r("t_35_1745227839208"),trigger:"input"}],key:[{required:!0,message:r("t_37_1745227839669"),trigger:"input"}]}});return B((async a=>{try{e(),await l(),a()}catch(r){P(r)}finally{t()}})),{UploadCertForm:o,example:a,loading:n,fetch:l}},H=e=>{const t=async e=>{const t=g();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:[U(r("t_34_1745227839375"),"cert",{placeholder:"",rows:8,readonly:!0},{},{suffix:[()=>{let e;return l(i,{size:"tiny",type:"primary",ghost:!0,onClick:()=>t(a)},N(e=r("t_4_1747984130327"))?e:{default:()=>[e]})}]}),U(r("t_36_1745227838958"),"key",{placeholder:"",rows:8,readonly:!0},{},{suffix:[()=>{let a;return l(i,{size:"tiny",type:"primary",ghost:!0,onClick:()=>t(e.key)},N(a=r("t_4_1747984130327"))?a:{default:()=>[a]})}]})],defaultValue:{cert:a,key:e.key}});return{ViewCertForm:o}};const A=f({name:"CertManage",setup(){const{TableComponent:e,PageComponent:t,SearchComponent:a,openUploadModal:m,getRowClassName:_}=(()=>{const{TableComponent:e,PageComponent:t,loading:a,param:p,data: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,n,i]=a.find((e=>e[0]))??["default","error","获取失败"];return l(s,{type:n,size:"small"},N(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 l(d,{justify:"end"},{default:()=>[l(i,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>f(e)},{default:()=>[c("查看")]}),l(i,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>T(e.id.toString())},N(t=r("t_25_1745227838080"))?t:{default:()=>[t]}),l(i,{size:"tiny",strong:!0,secondary:!0,type:"error",onClick:()=>g(e)},N(a=r("t_12_1745215914312"))?a:{default:()=>[a]})]})}}],request:V,defaultValue:{p:1,limit:10,search:""},alias:{page:"p",pageSize:"limit"},watchValue:["p","limit"],storage:"certManagePageSize"}),{SearchComponent:y}=C({onSearch:e=>{p.value.search=e,_()}}),g=async({id:e})=>{k({title:r("t_29_1745227838410"),content:r("t_30_1745227841739"),onPositiveClick:async()=>{try{await M(e.toString()),await _()}catch(t){P(t)}}})},f=e=>{u({title:"查看证书信息",area:600,component:()=>{const{ViewCertForm:t}=H(e);return l(t,{labelPlacement:"top"},null)},footer:!1})};return n((()=>_())),{loading:a,TableComponent:e,PageComponent:t,SearchComponent:y,getRowClassName:e=>{const t=Number(e.end_day);return t<=0?"bg-red-500/10":t<30?"bg-orange-500/10":""},openUploadModal:()=>{u({title:r("t_13_1745227838275"),area:600,component:()=>{const{UploadCertForm:e}=L();return l(e,{labelPlacement:"top"},null)},footer:!0,onUpdateShow:e=>{e||_(),R()}})},openViewModal:f}})(),y=h(["contentPadding","borderColor","headerHeight","iconColorHover"]);return()=>l("div",{class:"h-full flex flex-col",style:y.value},[l("div",{class:"mx-auto max-w-[1600px] w-full p-6"},[l(S,null,{headerLeft:()=>{let e;return l(i,{type:"primary",size:"large",class:"px-5",onClick:m},"function"==typeof(t=e=r("t_13_1745227838275"))||"[object Object]"===Object.prototype.toString.call(t)&&!p(t)?e:{default:()=>[e]});var t},headerRight:()=>l(a,{placeholder:r("t_14_1745227840904")},null),content:()=>l("div",{class:"rounded-lg"},[l(e,{size:"medium",rowClassName:_},{empty:()=>l(w,{addButtonText:r("t_1_1747047213009"),onAddClick:m},null)})]),footerRight:()=>l("div",{class:"mt-4 flex justify-end"},[l(t,null,null)])})])])}});export{A as default};