import{K as a,as as e,fn as l,_ as t}from"./utils-lib.js?v=1761009159";import{c as s,r as o,g as i,e as n,c1 as u,G as r,C as d,ay as p,aw as _,al as m,ak as c,q as v,a6 as b,v as h,x as f,y as w}from"./base-lib.js?v=1761009159";import{b as x,h as y,j as g,F as j}from"./form-item.js?v=1761009159";import{u as k,h as C,c as V,a as D,r as H}from"./index62.js?v=1761009159";import{c as I}from"./useController10.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./index105.js?v=1761009159";import"./column.js?v=1761009159";import"./index219.js?v=1761009159";const q={class:"p-[2rem]"},E=t(s({__name:"index",setup(t,{expose:s}){const{isHttpClbEdit:E,addNodeData:F,httpRowData:N,nodeClbHttpRefresh:P,domainList:R}=k(),U=o([{label:"轮询 - 按照权重依次分配请求到上游服务器",value:"round_robin"},{label:"coockie跟随 - 基于coockie选择实际的上游服务，保证每位访问者每次访问到同一个上游服务器",value:"sticky_cookie"},{label:"IP跟随 - 基于访问者的IP地址选择实际的上游服务，保证每位访问者每次访问到同一个上游服务器（拥有CDN的网站不推荐使用）",value:"ip_hash"},{label:"最少链接 - 每次优先选择当前链接数量较少的上游服务器来处理访问者的请求",value:"least_conn"}]),{BtForm:B,submit:G}=a({data:C,options:a=>i(()=>[x("名称","ps",{attrs:{disabled:E.value,class:"!w-[320px]",placeholder:"请输入负载均衡名称"},rules:[{required:!0,message:"请输入负载均衡名称"},{validator:(a,e,l)=>{e.length>=3?l():l(new Error("请输入至少大于3个字符"))},trigger:["blur","change"]}]}),!E.value&&y("选择网站",()=>n(u,{modelValue:a.value.site_name,"onUpdate:modelValue":e=>a.value.site_name=e,"fetch-suggestions":V(R.value),clearable:!0,class:"inline-input !w-[32rem]",onSelect:a=>a.value.value,"value-key":"label",placeholder:"请输入或选择网站"},null),"site_name"),g("负载方式","http_alg",U.value,{attrs:{placeholder:"请选择负载方式",class:"!w-[74rem]"}}),j(()=>n("div",null,[n("div",{class:"flex justify-between items-center mb-5"},[n(r,{type:"primary",onClick:D},{default:()=>[d("添加负载均衡节点")]})]),n(p,{data:F.value,"table-layout":"auto"},{default:()=>[n(_,{prop:"node_remarks",label:"负载均衡节点",width:"120"},null),n(_,{prop:"node_site_name",label:"节点网站",width:"120"},null),n(_,{prop:"port",label:"端口",width:"70"},null),n(_,{prop:"path",label:"验证路径",width:"100"},null),n(_,{prop:"node_status",label:"节点状态"},{default:({row:a})=>n(m,{modelValue:a.node_status,"onUpdate:modelValue":e=>a.node_status=e,style:"width: 70px"},{default:()=>[n(c,{label:"参与",value:"online"},null),n(c,{label:"备份",value:"backup"},null),n(c,{label:"停用",value:"down"},null)]})}),n(_,{prop:"weight",label:"权重",width:"60"},null),n(_,{prop:"max_fail",label:"最大失败次数",width:"90"},null),n(_,{prop:"fail_timeout",label:"恢复时间（秒）",width:"100"},null),n(_,{prop:"ps",label:"备注"},null),n(_,{label:"操作",width:"60"},{default:a=>n("span",{class:"bt-link",onClick:()=>H(a.$index)},[d("删除")])})]})]))]),submit:async(a,t,s)=>{var o;try{await t();let{ps:s,site_name:i,http_alg:n,site_id:u,load_id:r}=a.value;const d=e(F.value);u=null==(o=R.value.find(a=>a.label===i))?void 0:o.value;const p={ps:s,site_name:i,...l(u)?{}:{site_id:u},http_config:{http_alg:n,proxy_next_upstream:"error timeout http_500 http_502 http_503 http_504"},nodes:d};return E.value&&(p.http_config.proxy_next_upstream=a.value.http_config.proxy_next_upstream,p.site_id=a.value.site_id,p.load_id=r,p.name=a.value.name),await I({mod_name:"node",sub_mod_name:"load",def_name:E.value?"modify_http_load":"create_http_load",ws_callback:E.value?"modify_http_load":"create_http_load",data:{...p}}),P.value=!0,!0}catch(i){return!1}}});return s({onConfirm:G}),v(()=>{l(N.value)||(F.value=e(N.value.nodes))}),b(()=>{F.value=[]}),(a,e)=>(h(),f("div",q,[n(w(B))]))}}),[["__scopeId","data-v-530db14a"]]);export{E as default};
