mirror of https://github.com/allinssl/allinssl
2 lines
8.7 KiB
JavaScript
2 lines
8.7 KiB
JavaScript
import{m as e,s as t,n as a,r as s,$ as r,d as i,e as n,p as l,q as o,B as c,t as u,v as p,k as d,w as g,x as _,y as m,z as f,A as y,C as h,D as v,E as w,F as x,G as b,H as k,i as A,I as S,j as q}from"./main-Fcjzy_wF.js";import{u as j,a as F,b as P}from"./index-BzaYP_dt.js";import{T as E,H as T,O as C}from"./business-NkigeWWm.js";import{g as z,a as I,u as L,d as N}from"./access-BN9qtvTy.js";import{S as U}from"./index-C782_Rj1.js";import{A as O}from"./index-B_diYAph.js";import{N as M}from"./text-DukdqSR_.js";import{B as R,P as V}from"./index-BGTWDom3.js";import{S as H}from"./Search-DtBKjQ3H.js";import"./test-D61Aaakq.js";const{handleError:K}=j(),B=a(),$=e("auth-api-manage-store",(()=>{const e=s({ssh:"SSH",aliyun:"阿里云",tencentcloud:"腾讯云",btpanel:"宝塔","1panel":"1Panel"}),t=s({name:"",type:"btpanel",config:{url:"",api_key:"",ignore_ssl:"0"}}),a=()=>{t.value={name:"",type:"btpanel",config:{url:"",api_key:"",ignore_ssl:"0"}}};return{accessTypes:e,apiFormProps:t,fetchAccessList:async e=>{try{const t=await z(e).fetch();return{list:t.data||[],total:t.count}}catch(t){return K(t),{list:[],total:0}}},addNewAccess:async e=>{try{const{fetch:t,message:s}=I(e);s.value=!0,await t(),a()}catch(t){K(t)&&B.error(r("t_8_1745289354902"))}},updateExistingAccess:async e=>{try{const{fetch:t,message:a}=L(e);a.value=!0,await t()}catch(t){K(t)&&B.error(r("t_40_1745227838872"))}},deleteExistingAccess:async e=>{try{const{fetch:t,message:s}=N({id:e});s.value=!0,await t(),a()}catch(t){K(t)&&B.error(r("t_40_1745227838872"))}},resetApiForm:a}})),G=i({name:"AddApiForm",props:{data:{type:Object,default:()=>{}}},setup(e){const{ApiManageForm:t}=te(e);return()=>n("div",{class:"p-4"},[n(t,{labelPlacement:"top",requireMarkPlacement:"right-hanging"},null)])}});function J(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!d(e)}const{accessTypes:D,apiFormProps:Q,fetchAccessList:W,deleteExistingAccess:X,addNewAccess:Y,updateExistingAccess:Z}=(()=>{const e=$();return{...e,...t(e)}})(),{handleError:ee}=j(),te=e=>{var t;const{confirm:a}=k(),{open:i,close:l}=P({text:r("正在提交信息,请稍后...")}),{useFormInput:o,useFormRadioButton:c,useFormSwitch:u,useFormTextarea:p,useFormCustom:d}=_(),A=(null==(t=e.data)?void 0:t.id)?s({...e.data,config:JSON.parse(e.data.config)}):Q,S={name:{required:!0,message:r("t_27_1745289355721"),trigger:"input"},type:{required:!0,message:r("t_28_1745289356040"),trigger:"change"},config:{host:{required:!0,trigger:"input",validator:(e,t,a)=>{if(!C(t))return a(new Error(r("t_0_1745317313835")));a()}},port:{required:!0,trigger:"input",validator:(e,t,a)=>{if(!T(t.toString()))return a(new Error(r("t_1_1745317313096")));a()}},user:{required:!0,trigger:"input",message:r("t_3_1744164839524")},password:{required:!0,message:r("t_4_1744164840458"),trigger:"input"},key:{required:!0,message:r("t_31_1745289355715"),trigger:"input"},url:{required:!0,trigger:"input",validator:(e,t,a)=>{if(!E(t))return a(new Error(r("t_2_1745317314362")));a()}},api_key:{required:!0,message:r("t_3_1745317313561"),trigger:"input"},access_key_id:{required:!0,message:r("t_4_1745317314054"),trigger:"input"},access_key_secret:{required:!0,message:r("t_5_1745317315285"),trigger:"input"},secret_id:{required:!0,message:r("t_6_1745317313383"),trigger:"input"},secret_key:{required:!0,message:r("t_7_1745317313831"),trigger:"input"}}},q=Object.entries(D.value).map((([e,t])=>({label:t,value:e}))),j=g((()=>{var t;const a=[o(r("名称"),"name"),d((()=>n(f,{label:r("t_41_1745289354902"),path:"type"},{default:()=>{var t;return[n(m,{class:"w-full",options:q,renderLabel:z,renderTag:F,disabled:!!(null==(t=e.data)?void 0:t.id),filterable:!0,placeholder:r("t_0_1745833934390"),value:A.value.type,"onUpdate:value":e=>A.value.type=e},{empty:()=>n("span",{class:"text-[1.4rem]"},[r("t_0_1745833934390")])})]}})))];switch(A.value.type){case"ssh":a.push(d((()=>n(v,{cols:24,xGap:4},{default:()=>[n(y,{label:r("t_1_1745833931535"),span:16,path:"config.host"},{default:()=>[n(h,{value:A.value.config.host,"onUpdate:value":e=>A.value.config.host=e},null)]}),n(y,{label:r("t_2_1745833931404"),span:8,path:"config.port"},{default:()=>[n(h,{value:A.value.config.port,"onUpdate:value":e=>A.value.config.port=e},null)]})]}))),o(r("用户名"),"config.user"),c(r("认证方式"),"config.mode",[{label:r("密码"),value:"password"},{label:r("密钥"),value:"key"}]),"password"===(null==(t=A.value.config)?void 0:t.mode)?o(r("密码"),"config.password"):p(r("密钥"),"config.key",{rows:3,placeholder:r("请输入面板API密钥")}));break;case"1panel":case"btpanel":a.push(o(r("面板URL"),"config.url"),o(r("API密钥"),"config.api_key"),u(r("忽略 SSL/TLS证书错误"),"config.ignore_ssl",{checkedValue:"1",uncheckedValue:"0"},{showRequireMark:!1}));break;case"aliyun":a.push(o("AccessKeyId","config.access_key"),o("AccessKeySecret","config.access_secret"));break;case"tencentcloud":a.push(o("SecretId","config.secret_id"),o("SecretKey","config.secret_key"))}return a}));w((()=>A.value.type),(e=>{switch(e){case"ssh":A.value.config={host:"",port:22,user:"root",mode:"password",password:""};break;case"1panel":case"btpanel":A.value.config={url:"",api_key:"",ignore_ssl:"0"};break;case"aliyun":A.value.config={access_key_id:"",access_key_secret:""};break;case"tencentcloud":A.value.config={secret_id:"",secret_key:""}}}));const F=({option:e})=>n("div",{class:"flex items-center"},[e.label?n(x,null,[n(U,{iconName:`resources-${e.value}`,size:"2rem"},null),n("div",{class:"ml-[.8rem] p-[4px_0]"},[n(M,null,{default:()=>[e.label]})])]):n("span",{class:"text-[1.4rem] text-gray-400"},[r("t_0_1745833934390")])]),z=e=>n("div",{style:{display:"flex",alignItems:"center"}},[n(U,{iconName:`resources-${e.value}`,size:"2rem"},null),n("div",{class:"ml-[.8rem] p-[4px_0]"},[n(M,null,{default:()=>[e.label]})])]),{component:I,fetch:L}=b({config:j,defaultValue:A,request:async(e,t)=>{try{const t={...e,config:JSON.stringify(e.config)};if("id"in e){const{id:e,name:a,config:s}=t;await Z({id:e.toString(),name:a,config:s})}else await Y(t)}catch(a){return ee(new Error(r("表单验证失败")))}},rules:S});return a((async e=>{try{i(),await L(),e()}catch(t){return ee(t)}finally{l()}})),{ApiManageForm:I}},ae=i({name:"AuthApiManage",setup(){const{ApiTable:e,ApiTablePage:t,param:a,fetch:s,data:i,openAddForm:d}=(()=>{const{component:e,loading:t,param:a,data:s,total:i,fetch:d}=l({config:[{title:r("t_2_1745289353944"),key:"name",width:200,ellipsis:{tooltip:!0}},{title:r("t_3_1745289354664"),key:"type",width:180,render:e=>n(O,{icon:e.type,type:"success"},null)},{title:r("t_7_1745215914189"),key:"create_time",width:180},{title:r("t_0_1745295228865"),key:"update_time",width:180},{title:r("t_8_1745215914610"),key:"actions",width:180,align:"right",fixed:"right",render:e=>{let t,a;return n(u,{justify:"end"},{default:()=>[n(c,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>_(e)},J(t=r("t_11_1745215915429"))?t:{default:()=>[t]}),n(c,{size:"tiny",strong:!0,secondary:!0,type:"error",onClick:()=>m(e.id)},J(a=r("t_12_1745215914312"))?a:{default:()=>[a]})]})}}],request:W,defaultValue:{p:1,limit:10,search:""},watchValue:["p","limit"]}),{component:g}=o({param:a,total:i,alias:{page:"p",pageSize:"limit"}}),_=e=>{p({title:r("t_4_1745289354902"),area:500,component:G,componentProps:{data:e},footer:!0,onUpdateShow:e=>{e||d()}})},m=e=>{F({title:r("t_5_1745289355718"),content:r("t_6_1745289358340"),confirmText:r("t_5_1744870862719"),cancelText:r("t_4_1744870861589"),onPositiveClick:async()=>{await X(e),await d()}})};return{loading:t,fetch:d,ApiTable:e,ApiTablePage:g,param:a,data:s,accessTypes:D,openAddForm:()=>{p({title:r("t_0_1745289355714"),area:500,component:G,footer:!0,onUpdateShow:e=>{e||d()}})}}})(),g=A(["contentPadding","borderColor","headerHeight","iconColorHover"]);return S(s),()=>n("div",{class:"h-full flex flex-col",style:g.value},[n("div",{class:"mx-auto max-w-[1600px] w-full p-6"},[n(R,null,{headerLeft:()=>n(c,{type:"primary",size:"large",class:"px-5",onClick:d},{default:()=>[n(V,{class:"text-[var(--text-color-3)] w-[1.6rem]"},null),n("span",{class:"px-2"},[r("t_0_1745289355714")])]}),headerRight:()=>n(h,{value:a.value.search,"onUpdate:value":e=>a.value.search=e,onKeydown:e=>{"Enter"===e.key&&s()},onClear:()=>s(),placeholder:r("t_0_1745289808449"),clearable:!0,size:"large",class:"min-w-[300px]"},{suffix:()=>n("div",{class:"flex items-center",onClick:s},[n(H,{class:"text-[var(--text-color-3)] w-[1.6rem] cursor-pointer font-bold"},null)])}),content:()=>n("div",{class:"rounded-lg bg-white"},[n(e,{size:"medium",style:{"--n-th-text-color":"#6b7280","--n-td-text-color":"#6b7280","--n-box-shadow":"none"}},null)]),footerRight:()=>n("div",{class:"mt-4 flex justify-end"},[n(t,null,{prefix:()=>n("span",null,[r("t_15_1745227839354"),q(" "),i.value.total,q(" "),r("t_16_1745227838930")])})])})])])}});export{ae as default};
|