import{l as e,t as a,K as l,x as t,u as s,a4 as o,$ as r,A as i,z as p,a3 as u,q as n,a1 as c,v as m}from"./utils-lib.js?v=20260328163632";import{B as d}from"./index91.js?v=20260328163632";import{u as v}from"./index92.js?v=20260328163632";import{j as _,k as x,l as f,m as y}from"./safety.js?v=20260328163632";import{u as b}from"./index30.js?v=20260328163632";import{r as g,c as h,k as j,V as I,_ as k,Y as w,o as P,J as V,W as C,O as z,a3 as S,N as q,X as K,Z as O}from"./base-lib.js?v=20260328163632";import{ax as R,au as W}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";import"./logs.js?v=20260328163632";const{rowData:A}=b(),B=[{label:e("所有"),value:"all"},{label:e("IPV4"),value:"0.0.0.0"},{label:e("IPV6"),value:"::"}],D=g({formAttrs:{labelWidth:"100px"},formItems:[]}),N=h((()=>(D.value.formItems=[{label:A.value?e("本地IP"):e("IP类型"),children:[{type:A.value?"input":"select",key:"local_ip",attrs:{options:B,disabled:!!A.value,class:"!w-240px"}}]},{label:e("本地端口"),ruleKey:"local_port",rules:[l({message:e("请输入本地端口")})],children:[{type:"input",key:"local_port",attrs:{class:"!w-240px",placeholder:e("请输入本地端口"),disabled:!!A.value,clearable:!0}}]},{label:e("远程IP"),ruleKey:"remote_ip",rules:[l({message:e("请输入远程IP")})],children:[{type:"input",key:"remote_ip",attrs:{class:"!w-240px",placeholder:e("请输入远程IP地址"),clearable:!0}}]},{label:e("远程端口"),ruleKey:"remote_port",rules:[l({message:e("请输入远程端口")})],children:[{type:"input",key:"remote_port",attrs:{class:"!w-240px",placeholder:e("请输入远程端口"),clearable:!0}}]}],D.value))),[F,H,J]=a(N),U=async()=>{await J.value.validate();const a=A.value?_:x;return 0===(await t({loading:e("正在{0}规则",[A.value?e("修改"):e("添加")]),request:a(H.value),message:!0,data:{status:Number},success:()=>{te()}})).status},X=j({__name:"index",setup:(e,{expose:a})=>((async()=>{var e,a,l,t;Object.assign(H.value,{local_ip:(null==(e=A.value)?void 0:e.local_ip)||"all",local_port:(null==(a=A.value)?void 0:a.local_port)||"",remote_ip:(null==(l=A.value)?void 0:l.remote_ip)||"",remote_port:(null==(t=A.value)?void 0:t.remote_port)||""})})(),a({onConfirm:U}),(e,a)=>(I(),k(w(F),{class:"p-20px"})))}),{isWin:Y}=s(),{rowData:Z}=b(),$=g(""),E=[{content:e("【0.0.0.0】表示本地IPV4地址，【::】表示本地IPV6地址")},{content:e("将本地【IPV4/IPV6】某个端口的流量转发到远程服务器的指定端口")},{content:e("本地端口必须是【未使用】状态，远程服务器端口必须是【已使用】状态")}],G=a=>{Z.value=a||null,i({title:e(a?"修改端口转发规则":"添加端口转发规则"),area:440,component:X,showFooter:!0})},L=g({columns:[...Y.value?[]:[{title:e("协议"),key:"protocol"}],{title:e("本地IP地址"),key:"local_ip"},{title:e("本地端口号"),key:"local_port"},{title:e("远程IP地址"),key:"remote_ip"},{title:e("远程端口号"),key:"remote_port"},o([{onClick:G,title:e("编辑")},{onClick:async a=>{const{local_ip:l,local_port:s,remote_ip:o,remote_port:r}=a;let i={local_ip:l,local_port:s,remote_ip:o,remote_port:r};Y.value||(i.protocol=a.protocol),await p({icon:"warning-filled",title:e("删除端口转发规则【本地端口：{0} -> 远程端口：{1}】",[s,r]),content:e("删除选中规则后，该本地端口将停止转发至远程端口，是否继续操作？")}),await t({loading:e("正在删除规则，请稍后..."),request:f(i),message:!0,success:()=>{te()}})},title:e("删除")}])],data:[]}),M=g({page:1,pageSize:20,itemCount:0,pageSlot:5}),[Q,T]=r(L),[ee]=u(M),{BtOperation:ae}=v({options:[{active:!0,label:e("添加端口转发"),onClick:()=>G()}]}),le=()=>{M.value.page=1,te()},te=(e={search:$.value,p:M.value.page,limit:M.value.pageSize})=>{t({request:y(e),success:e=>{L.value.data=e.data.list,M.value.itemCount=e.data.page.total}})},se=()=>{oe(),te()},oe=()=>{$.value="",Object.assign(M.value,{page:1,itemCount:0})},re={class:"text-14px text-[var(--text-color-2)]"},ie=j({__name:"index",setup:(a,{expose:l})=>(P(se),V(oe),l({init:se}),(a,l)=>{const t=W,s=R;return I(),C("div",null,[z(s,{justify:"space-between"},{default:S((()=>[z(w(ae),{class:"gap-10px"}),z(t,{size:10},{default:S((()=>[z(w(n),{modelValue:w($),"onUpdate:modelValue":l[0]||(l[0]=e=>q($)?$.value=e:null),placeholder:w(e)("请输入IP地址/端口号"),class:"!w-[220px]",onSearch:w(le)},null,8,["modelValue","placeholder","onSearch"]),z(w(d),{onRefresh:l[1]||(l[1]=()=>w(te)())})])),_:1})])),_:1}),z(w(Q),{"scroll-x":600,class:"py-10px"}),z(s,{justify:"end"},{default:S((()=>[z(w(ee),{"show-size-picker":"","page-sizes":w(c)([10,20,50,100]),onRefresh:w(te)},{suffix:S((()=>[K("span",re,O(w(e)("共 {0} 条",[w(M).itemCount])),1)])),_:1},8,["page-sizes","onRefresh"])])),_:1}),z(w(m),{class:"!mt-10px",options:w(E)},null,8,["options"])])})});export{ie as default};
