import{l as e,K as a,t as s,x as t,a4 as l,$ as o,A as i,z as p,a3 as r,q as n,a1 as u}from"./utils-lib.js?v=20260328163632";import{B as c}from"./index91.js?v=20260328163632";import{u as d}from"./index92.js?v=20260328163632";import{u as m,o as v}from"./index30.js?v=20260328163632";import{n as f,o as x,p as g,q as y,r as b,t as h}from"./safety.js?v=20260328163632";import{r as j,k as I,V as P,_,Y as w,O as k,o as C,J as z,W as q,a3 as S,N as A,X as O,Z as V}from"./base-lib.js?v=20260328163632";import{ax as K,au as R}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";import"./logs.js?v=20260328163632";const{tabActive:B,rowData:N}=m(),W=j({formAttrs:{labelWidth:"100px"},formItems:[{label:e("IP地址"),ruleKey:"ips",rules:[a({message:e("请输入IP地址")})],children:[{type:"input",key:"ips",attrs:{class:"!w-290px",placeholder:e("参考格式：127.0.0.1,192.168.1.0/24"),clearable:!0,onInput:e=>{F.value.ps=e}}}]},{label:e("备注"),ruleKey:"ps",rules:[a({message:e("请输入备注")})],children:[{type:"input",key:"ps",attrs:{class:"!w-290px",placeholder:e("请输入备注"),clearable:!0}}]}]}),[D,F,H]=s(W),J=async()=>{await H.value.validate();const a="drop"===B.value?f:x;return 0===(await t({loading:e("正在{0}IP规则",[N.value?e("修改"):e("添加")]),request:a(F.value),message:!0,data:{status:Number},success:()=>{T()}})).status},U=I({__name:"index",setup:(e,{expose:a})=>((async()=>{var e,a;Object.assign(F.value,{ips:(null==(e=N.value)?void 0:e.ip)||"",ps:(null==(a=N.value)?void 0:a.ps)||""})})(),a({onConfirm:J}),(e,a)=>(P(),_(w(D),{class:"p-20px"})))}),{tabActive:X}=m(),Y=j(""),Z=j({columns:[{title:e("IP地址"),key:"ip"},{title:e("IP归属地"),key:"area.info"},{title:e("类型"),key:"type",render:a=>k("span",null,["drop"===a.type?e("拦截"):e("放行")])},{title:e("备注"),key:"ps"},l([{onClick:async a=>{const{ip:s,ps:l}=a;await p({icon:"warning-filled",title:e("删除IP规则【{0}】",[s]),content:e("删除选中的规则后，该IP将使用默认放行的方式，是否继续操作？")});const o="drop"===X.value?b:h;await t({loading:e("正在删除IP规则，请稍后..."),request:o({ips:s,ps:l}),message:!0,success:()=>{T()}})},title:e("删除")}])],data:[]}),$=j({page:1,pageSize:20,itemCount:0,pageSlot:5}),[E,G]=o(Z),[L]=r($),{BtOperation:M}=d({options:[{active:!0,label:e("添加IP规则"),onClick:()=>{i({title:e("添加IP规则"),area:470,component:U,showFooter:!0})}},{label:e("导出规则"),onClick:()=>{v({title:"drop"===X.value?e("导出屏蔽IP列表"):e("导出IP白名单列表"),data:{request:"drop"===X.value?g:y}})}}]}),Q=()=>{$.value.page=1,T()},T=(e={search:Y.value,p:$.value.page,limit:$.value.pageSize})=>{const a="drop"===X.value?g:y;t({request:a(e),success:e=>{Z.value.data=e.data.list,$.value.itemCount=e.data.page.total}})},ee=()=>{ae(),T()},ae=()=>{Y.value="",Object.assign($.value,{page:1,itemCount:0})},se={class:"text-14px text-[var(--text-color-2)]"},te=I({__name:"index",setup:(a,{expose:s})=>(C(ee),z(ae),s({init:ee}),(a,s)=>{const t=R,l=K;return P(),q("div",null,[k(l,{justify:"space-between"},{default:S((()=>[k(w(M),{class:"gap-10px"}),k(t,{size:10},{default:S((()=>[k(w(n),{modelValue:w(Y),"onUpdate:modelValue":s[0]||(s[0]=e=>A(Y)?Y.value=e:null),placeholder:w(e)("请输入IP/端口"),class:"!w-[220px]",onSearch:w(Q)},null,8,["modelValue","placeholder","onSearch"]),k(w(c),{onRefresh:s[1]||(s[1]=()=>w(T)())})])),_:1})])),_:1}),k(w(E),{"scroll-x":600,class:"py-10px"}),k(l,{justify:"end"},{default:S((()=>[k(w(L),{"show-size-picker":"","page-sizes":w(u)([10,20,50,100]),onRefresh:w(T)},{suffix:S((()=>[O("span",se,V(w(e)("共 {0} 条",[w($).itemCount])),1)])),_:1},8,["page-sizes","onRefresh"])])),_:1})])})});export{te as default};
