File: /www/server/panel/BTPanel/static/js/index74.js
import{M as u,il as he,e as T,_ as x,k as R,cl as Q,Z as be,fk as fe,w as W,im as ve,io as ge,ip as Ce,c as Z,dc as ye,da as K,ga as Te,o as X,R as N,cT as Y,cU as ee,iq as xe,ir as Ee,gb as Be,cR as De,cZ as ke}from"./utils-lib.js?v=1777008528";import{u as w,c as te,o as ae}from"./useController28.js?v=1777008528";import{_ as se}from"./index118.js?v=1777008528";import{aI as oe,aJ as le,r as f,c as q,e as s,aA as ne,ay as d,x as O,aB as re,j as A,k as I,v as g,q as P,p as i,L as ue,bV as Re,Q as He}from"./base-lib.js?v=1777008528";import{b as ie,e as ce,g as pe}from"./index3.js?v=1777008528";import{_ as Fe}from"./index317.js?v=1777008528";const Le=le("CLB-HTTP-STORE",()=>{const e=f(),a=f([]),t=f(!1),n=f([]),l=f(!1),c=f([]);return{httpRowData:e,isHttpClbEdit:t,addNodeData:a,HttpNodeList:n,nodeClbHttpRefresh:l,domainList:c}}),de=()=>oe(Le()),{httpRowData:V,isHttpClbEdit:z,addNodeData:Pe,nodeClbHttpRefresh:U,domainList:we}=de(),{testLinkStatus:$}=w(),Se=async(e,a,t,n)=>{const{label:l,value:c}=n;let m=[],h=[];t.value.forEach(o=>{o.hash!==void 0&&o.hash!==null?h.push(o.hash):o.index!==void 0&&o.index!==null&&m.push(o.index)});const b=async()=>{const o=t.value.map(_=>_.load_id);switch(c){case"delete":return await Ce({load_ids:JSON.stringify(o)})}};await T({title:"批量".concat(l,"负载均衡"),area:46,component:()=>x(()=>import("./index127.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{resultTitle:"批量".concat(l,"负载均衡"),resultData:t.value,resultColumn:[{label:"名称",prop:"ps"},ie()],autoTitle:"批量".concat(l,"负载均衡")},showFooter:!0,onConfirm:async()=>{const o=u.load("正在删除,请稍候...");try{await b(),u.success("删除成功"),U.value=!0}catch(_){u.error("删除失败")}finally{o.close()}}})},M=async e=>{if(V.value=e,z.value=!!e,!z.value){const a=u.load("正在获取网站列表,请稍后...");try{const t=await he();t.msg&&t.status===!1&&u.error(t.msg),we.value=t.data.map(n=>({label:n.site_name,value:n.site_id}))}catch(t){}finally{a.close()}}T({isAsync:!0,title:"".concat(e?"编辑【".concat(e.ps,"】"):"添加HTTP负载均衡"),area:110,btn:"".concat(e?"保存":"确认"),compData:e||{},component:()=>x(()=>import("./index466.js?v=1777008528"),__vite__mapDeps([]),import.meta.url)})},G={load_id:"",name:"",site_name:"",http_alg:"round_robin",ps:"",request:"",error:"",qps:"",upstream_time:"",last_request_time:"",nodes:[]},rt=()=>{var e;try{const a=V.value||{};return{...G,...a,http_alg:((e=a==null?void 0:a.http_config)==null?void 0:e.http_alg)||"round_robin",nodes:(a==null?void 0:a.nodes)||[]}}catch(a){return{...G}}},ut=async()=>{const e=await R({loading:"正在获取节点列表,请稍后...",request:Q()});e.msg&&e.status===!1&&u.error(e.msg);const a=e.data.data.map(t=>({label:t.remarks,value:t.id,server_ip:t.server_ip,version:t.version,useful_version:t.useful_version}));T({title:"添加节点",area:54,btn:["添加","取消"],compData:{nodes:a},component:()=>x(()=>import("./index467.js?v=1777008528"),__vite__mapDeps([]),import.meta.url)})},it=async(e,a)=>{var b;$.value=!0;const{port:t,node_site_id:n,node_site_name:l,target_type:c,...m}=e.value,h=c==="site"?a.some(o=>o.label===l):!0;try{const o=/^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;if(!e.value.node_id)return u.error("请选择负载均衡节点");if(!be(l)&&!o.test(l)){u.error("请输入正确的节点网站格式");return}if(!t)return u.error("请输入端口");const _={port:Number(t),...h?{node_site_id:n,node_site_name:l}:{node_site_name:l},...m};await te({mod_name:"node",sub_mod_name:"load",def_name:"check_http_node",ws_callback:"check_http_node",data:{..._}},{loading:!1})}catch(o){}finally{if(!h){if(!e.value.node_id)return $.value=!1;const{data:o}=await fe({node_id:e.value.node_id}),_=(b=o.data.find(C=>C.site_name==l))==null?void 0:b.site_id;e.value.node_site_id=_,a.push({label:l,value:_,port:Number(t)})}$.value=!1}},$e=async e=>{await W({icon:"warning-filled",title:"删除负载均衡【".concat(e.ps,"】"),content:"即将删除负载均衡,是否继续操作?"}),await R({loading:"正在删除负载均衡,请稍后...",request:ve({load_id:e.load_id}),message:!0,success:a=>{U.value=!0}})},Ne=e=>{V.value=e,T({title:"配置高级设置",area:[80,60],btns:!1,compData:e,component:()=>x(()=>import("./index378.js?v=1777008528").then(a=>a.i),__vite__mapDeps([]),import.meta.url)})},ct=e=>{Pe.value.splice(e,1)},pt=async e=>{try{return(await R({request:ge(e),message:!0,loading:"正在设置负载均衡,请稍后...",success:t=>{t.msg&&t.status===!1&&(u.error(t.msg)||u.success("设置成功"))}})).status}catch(a){return!1}finally{U.value=!0}},dt=e=>{const a=[],t=/http_(\d{3})/g;let n;for(;(n=t.exec(e))!==null;)a.push(n[1]);return a},Oe=[{label:"删除",value:"delete",event:Se}],qe=e=>a=>a.label.toLowerCase().indexOf(e.toLowerCase())===0,_t=(e,a)=>(t,n)=>{if(a!=="any"){const l=t?e.filter(qe(t)):e;n(l)}else n([])},Ae={class:"node-clb-http"},Ie={class:"flex items-center"},Ve={class:"flex items-center"},Ue=q({__name:"index",setup(e){const{mainHeight:a}=Z(),{nodesStatusList:t}=w(),{httpRowData:n,isHttpClbEdit:l,nodeClbHttpRefresh:c}=de(),m=ee(Oe),{BtOperation:h}=ye({options:[{type:"button",label:"添加负载均衡",active:!0,onClick:()=>M()}]}),{BtTable:b,BtPage:o,BtRefresh:_,BtSearch:C,BtColumn:B,BtBatch:D,BtErrorMask:r,refresh:E,config:H,classList:F}=K({request:async p=>{const{p:L,limit:y,search:S}=p,{data:k}=await Te({page:L,page_size:y,search:S});return k.msg&&k.status===!1&&u.error(k.msg),{data:k.data,total:X(k.page),other:{}}},columns:[ce({type:"page",key:"load_id"}),{label:"负载均衡名称",prop:"ps"},{label:"网站",prop:"site_name",width:180,isCustom:!0},{label:"节点数量",prop:"nodes",isCustom:!0,render:p=>s(re,{trigger:"hover",title:"节点详细信息",placement:"bottom","popper-class":"node-clb-popover",width:"auto","open-delay":100,"close-delay":0},{default:()=>s(ne,{data:p.nodes,style:{width:"auto"},"max-height":"480px"},{default:()=>[s(d,{prop:"node_remarks",label:"节点",width:"120"},null),s(d,{prop:"node_site_name",label:"节点网站",width:"120"},null),s(d,{prop:"port",label:"端口"},null),s(d,{prop:"path",label:"验证路径"},null),s(d,{prop:"node_status",label:"节点状态"},{default:({row:L})=>{const y=t.value.find(S=>S.value===L.node_status);return s("span",null,[(y==null?void 0:y.label)||"/"])}}),s(d,{prop:"weight",label:"权重"},null),s(d,{prop:"max_fail",label:"最大失败次数","min-width":"100"},null),s(d,{prop:"fail_timeout",label:"恢复时间(秒)","min-width":"100"},null),s(d,{prop:"ps",label:"备注"},null)]}),reference:()=>s("div",{style:"color: var(--el-base-tertiary);"},[p.nodes.length,s("span",{class:"ml-4px size-12px bt-ico-ask"},[O("!")])])})},{label:"请求数",prop:"requests",isCustom:!0},{label:"错误数",prop:"errors",isCustom:!0},{label:"并发数",prop:"qps",isCustom:!0},{label:"回源耗时(秒)",prop:"max_upstream_time",isCustom:!0,render:p=>s("div",null,[p.max_upstream_time])},{label:"上次访问",prop:"last_update",isCustom:!0,render:p=>s("div",null,[p.last_update===0?"--":N(p.last_update)])},pe([{onClick:ae,title:"日志"},{onClick:M,title:"编辑"},{onClick:Ne,title:"配置"},{onClick:$e,title:"删除"}])],extension:[m,Y(c)]});return(p,L)=>{const y=se;return A(),I("div",Ae,[s(y,null,{"header-left":g(()=>[P("div",Ie,[s(i(h))])]),"header-right":g(()=>[P("div",Ve,[s(i(C),{class:ue(["mr-[10px]","!w-[210px]"]),placeholder:"请输入负载名称"}),s(i(_),{class:"mr-[10px]"}),s(i(B))])]),content:g(()=>[s(i(b),{"min-height":i(a)},null,8,["min-height"])]),"footer-left":g(()=>[s(i(D))]),"footer-right":g(()=>[s(i(o))]),_:1})])}}}),ze=le("CLB-TCPUDP-STORE",()=>{const e=f(),a=f(!1),t=f([]),n=f(!1);return{tcpudpRowData:e,isTcpudpClbEdit:a,addTcpudpNodeData:t,nodeClbTcpudpRefresh:n}}),_e=()=>oe(ze()),{tcpudpRowData:v,isTcpudpClbEdit:Me,nodeClbTcpudpRefresh:me}=_e(),{testLinkStatus:j}=w(),Ge=async(e,a,t,n)=>{const{label:l,value:c}=n;let m=[],h=[];t.value.forEach(o=>{o.hash!==void 0&&o.hash!==null?h.push(o.hash):o.index!==void 0&&o.index!==null&&m.push(o.index)});const b=async()=>{switch(c){case"delete":return await Ee({load_ids:JSON.stringify(t.value.map(o=>o.load_id))})}};await T({title:"批量".concat(l,"负载均衡"),area:46,component:()=>x(()=>import("./index127.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{resultTitle:"批量".concat(l,"负载均衡"),resultData:t.value,resultColumn:[{label:"名称",prop:"ps"},ie()],autoTitle:"批量".concat(l,"负载均衡")},showFooter:!0,onConfirm:async()=>{const o=u.load("正在删除,请稍候...");try{await b(),u.success("删除成功"),me.value=!0}catch(_){u.error("删除失败")}finally{o.close()}}})},J=e=>{v.value=e,Me.value=!!e,T({isAsync:!0,title:"".concat(e?"编辑【".concat(e.ps,"】"):"添加TCP/UDP负载均衡"),area:74,btn:"".concat(e?"保存":"确认"),compData:e||{},component:()=>x(()=>import("./index340.js?v=1777008528"),__vite__mapDeps([]),import.meta.url)})},mt=()=>{var e,a,t,n,l,c,m,h,b,o,_,C,B,D;try{return{load_id:((e=v.value)==null?void 0:e.load_id)||0,name:((a=v.value)==null?void 0:a.name)||"",type:((n=(t=v.value)==null?void 0:t.tcp_config)==null?void 0:n.type)||"tcp",host:((c=(l=v.value)==null?void 0:l.tcp_config)==null?void 0:c.host)||"127.0.0.1",port:((h=(m=v.value)==null?void 0:m.tcp_config)==null?void 0:h.port)||null,proxy_timeout:((o=(b=v.value)==null?void 0:b.tcp_config)==null?void 0:o.proxy_timeout)||8,proxy_connect_timeout:((C=(_=v.value)==null?void 0:_.tcp_config)==null?void 0:C.proxy_connect_timeout)||86400,ps:((B=v.value)==null?void 0:B.ps)||"",nodes:((D=v.value)==null?void 0:D.nodes)||[]}}catch(r){return{}}},ht=async()=>{const e=await R({loading:"正在获取节点列表,请稍后...",request:Q()});e.msg&&e.status===!1&&u.error(e.msg);const a=e.data.data.map(t=>({label:t.remarks,value:t.id,server_ip:t.server_ip,version:t.version,useful_version:t.useful_version}));T({title:"添加节点",area:56,btn:!0,compData:{nodes:a},component:()=>x(()=>import("./index341.js?v=1777008528"),__vite__mapDeps([]),import.meta.url)})},bt=async e=>{try{j.value=!0;const{port:a,...t}=e;if(t.node_id=="")return u.error("请选择负载均衡节点"),!1;const n={type:"tcp",port:Number(a),...t};await te({mod_name:"node",sub_mod_name:"load",def_name:"check_tcp_node",ws_callback:"check_tcp_node",data:{...n}},{loading:!1})}catch(a){}finally{j.value=!1}},je=async e=>{try{await W({icon:"warning-filled",title:"删除负载均衡【".concat(e.ps,"】"),content:"即将删除负载均衡,是否继续操作?"}),await R({loading:"正在删除负载均衡,请稍后...",request:xe({load_id:e.load_id}),message:!0,success:a=>{me.value=!0}})}catch(a){}},Je=[{label:"删除",value:"delete",event:Ge}],Qe={class:"node-clb-tcpudp"},We={class:"flex items-center"},Ze={class:"flex items-center"},Ke=q({__name:"index",setup(e){const{mainHeight:a}=Z(),{nodeClbTcpudpRefresh:t}=_e(),n=[{content:"添加负载均衡",dropdownClass:"bg-white",splitButton:!0,active:!0,event:()=>J()}],l=ee(Je),{BtTable:c,BtPage:m,BtRefresh:h,BtColumn:b,BtBatch:o,BtSearch:_,BtErrorMask:C,classList:B,config:D}=K({request:async r=>{const{p:E,limit:H,search:F}=r,{data:p}=await Be({page:E,page_size:H,search:F});return p.msg&&p.status===!1&&u.error(p.msg),{data:p.data,total:X(p.page),other:{}}},columns:[ce({type:"page",key:"load_id"}),{label:"负载均衡名称",prop:"ps"},{label:"监听地址",prop:"host",isCustom:!0,render:r=>s("span",null,[r.tcp_config.host,O(":"),r.tcp_config.port])},{label:"节点数量",prop:"nodes",isCustom:!0,render:r=>s(re,{trigger:"hover",title:"节点详细信息",placement:"bottom","popper-class":"node-clb-popover",width:"auto","open-delay":100,"close-delay":0},{default:()=>s(ne,{data:r==null?void 0:r.nodes,"max-height":"480px"},{default:()=>[s(d,{prop:"host",label:"节点IP",width:"110"},null),s(d,{prop:"requests",label:"请求数"},null),s(d,{prop:"errors",label:"错误数"},null),s(d,{prop:"qps",label:"并发数"},null),s(d,{prop:"max_upstream_time",label:"回源耗时(秒)",width:"120"},null),s(d,{prop:"ps",label:"备注",width:"120"},null),s(d,{prop:"last_update",label:"上次访问",width:"150"},{default:()=>{var E;return[((E=r==null?void 0:r.nodes)==null?void 0:E.last_update)===0?"--":N(r==null?void 0:r.nodes.last_update)]}})]}),reference:()=>s("div",{style:"color: var(--el-base-tertiary);"},[r.nodes.length,s("span",{class:"ml-4px size-12px bt-ico-ask"},[O("!")])])})},{label:"请求数",prop:"requests",isCustom:!0},{label:"错误数",prop:"errors",isCustom:!0},{label:"并发数",prop:"qps",isCustom:!0},{label:"回源耗时(秒)",prop:"max_upstream_time",isCustom:!0,render:r=>s("span",null,[r.max_upstream_time])},{label:"上次访问",prop:"last_update",isCustom:!0,render:r=>s("div",null,[r.last_update===0?"--":N(r.last_update)])},pe([{onClick:ae,title:"日志"},{onClick:J,title:"编辑"},{onClick:je,title:"删除"}])],extension:[l,Y(t)]});return(r,E)=>{const H=Fe,F=se;return A(),I("div",Qe,[s(F,null,{"header-left":g(()=>[P("div",We,[s(H,{options:n})])]),"header-right":g(()=>[P("div",Ze,[s(i(_),{class:ue(["mr-[10px]","!w-[210px]"]),placeholder:"请输入负载名称"}),s(i(h),{class:"mr-[10px]"}),s(i(b))])]),content:g(()=>[s(i(c),{"min-height":i(a)},null,8,["min-height"])]),"footer-left":g(()=>[s(i(o))]),"footer-right":g(()=>[s(i(m))]),_:1})])}}}),Xe={class:"node-clb module-ui"},Ye=q({__name:"index",setup(e){const{activeTabs:a}=w(),t=f([{label:"HTTP",name:"http",render:()=>s(Ue,null,null)},{label:"TCP/UDP",name:"tcpudp",lazy:!0,render:()=>s(Ke,null,null)}]);return Re(()=>{}),(n,l)=>{const c=De;return A(),I("div",Xe,[s(c,{type:"card",modelValue:i(a),"onUpdate:modelValue":l[0]||(l[0]=m=>He(a)?a.value=m:null),options:i(t)},null,8,["modelValue","options"])])}}}),et=ke(Ye,[["__scopeId","data-v-f13a3ba9"]]),ft=Object.freeze(Object.defineProperty({__proto__:null,default:et},Symbol.toStringTag,{value:"Module"}));export{pt as H,ht as a,bt as b,de as c,_t as d,dt as e,ut as f,it as g,rt as h,ft as i,ct as r,mt as t,_e as u};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = []
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}