import{_ as e}from"./index105.js?v=1761009159";import{c as a,t as s,r as l,v as t,x as r,e as n,B as o,z as i,C as c,y as d,G as p,an as m}from"./base-lib.js?v=1761009159";import{_ as b}from"./index109.js?v=1761009159";import{fO as u,p as f,P as _}from"./utils-lib.js?v=1761009159";import{s as h}from"./firewall.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const x={class:"p-[2rem]"},v={class:"flex items-center gap-4 mb-2"},j=a({__name:"set-firewall",props:{compData:{default:()=>({fireStatus:!1,callback:()=>{}})}},setup(a,{expose:j}){const g=a,{compData:w}=s(g),P=l([{port:"21",enabled:!0},{port:"SSH",enabled:!0,description:"SSH端口(默认：22)"},{port:"80",enabled:!0},{port:"443",enabled:!0},{port:"39000-40000",enabled:!0},{port:"PanelPort",enabled:!0,description:"面板端口"}]),y=e=>{e?P.value.forEach(e=>{e.enabled=!0}):P.value.forEach(e=>{e.enabled=!e.enabled}),S()},{BtTable:C,refresh:S}=u({request:async()=>({data:P.value,total:P.value.length}),columns:[{label:"端口",prop:"port",render:e=>n("span",{class:"text-tertiary"},[e.description||e.port])},{label:"放行",width:80,render:e=>n(m,{size:"small",modelValue:e.enabled,onChange:a=>{e.enabled=a}},null)}]});return j({onConfirm:async()=>{try{const{disabledPorts:e,enabledPorts:a}={enabledPorts:P.value.filter(e=>e.enabled).map(e=>e.port).join(","),disabledPorts:P.value.filter(e=>!e.enabled).map(e=>e.port).join(",")},s=e;return await f({icon:"question-filled",title:"启用系统防火墙",content:"启用系统防火墙，将放行以下【".concat(a,"】端口，是否继续操作？")}),await _({loading:"正在启用系统防火墙，请稍后...",message:!0,request:h({status:1,ports:s}),success:()=>{w.value.callback()}}),!0}catch(e){return!1}}}),(a,s)=>{const l=b,m=p,u=e;return t(),r("div",x,[n(l,{type:"warning",description:"开启系统防火墙会放行以下端口配置，如需调整，请手动关闭相应端口。","show-icon":"",closable:!1,class:"mb-[1rem]"}),n(u,null,{header:o(()=>[i("div",v,[n(m,{size:"small",onClick:s[0]||(s[0]=e=>y(!0))},{default:o(()=>s[2]||(s[2]=[c("全选",-1)])),_:1,__:[2]}),n(m,{size:"small",onClick:s[1]||(s[1]=e=>y(!1))},{default:o(()=>s[3]||(s[3]=[c("反选",-1)])),_:1,__:[3]})])]),content:o(()=>[n(d(C),{"max-height":350})]),_:1}),s[4]||(s[4]=i("ul",{class:"mt-20px leading-8 text-small list-disc ml-24px"},[i("li",null,"此操作将重载防火墙，未持久化的 iptables 规则会清空，请先备份保存！")],-1))])}}});export{j as default};
