PortIO/public/build/assets/Create-7479ebe3.js

2 lines
6.1 KiB
JavaScript

import{r as m,h as w,i as y,o as n,c as d,a as o,j as r,v as u,k as T,F as v,e as U,t as _,l as c,b as p}from"./app-22d7fab3.js";import{i as h}from"./http-1f667af7.js";const S=o("h3",null,"创建隧道",-1),x=o("h5",null,"好的名称是好的开始。",-1),V={class:"form-floating mb-3"},g=o("label",{for:"tunnelName"},"隧道名称",-1),C={class:"form-floating mb-3"},D=["value"],H=o("label",{for:"serverSelect"},"服务器",-1),M={class:"text-muted mb-3"},N={key:0},B={class:"form-check form-check-inline"},L=["disabled"],R=o("label",{class:"form-check-label",for:"protocolHTTP"},"HTTP",-1),X={class:"form-check form-check-inline"},A=["disabled"],F=o("label",{class:"form-check-label",for:"protocolHTTPS"},"HTTPS",-1),$={class:"form-check form-check-inline"},j=["disabled"],E=o("label",{class:"form-check-label",for:"protocolTCP"},"TCP",-1),q={class:"form-check form-check-inline"},z=["disabled"],G=o("label",{class:"form-check-label",for:"protocolUDP"},"UDP",-1),I={class:"form-check form-check-inline"},J=["disabled"],K=o("label",{class:"form-check-label",for:"protocolSTCP"},"STCP",-1),O={class:"form-check form-check-inline"},Q=["disabled"],W=o("label",{class:"form-check-label",for:"protocolSUDP"},"SUDP",-1),Y={class:"form-check form-check-inline"},Z=["disabled"],oo=o("label",{class:"form-check-label",for:"protocolXTCP"},"XTCP",-1),eo=o("h5",{class:"mt-3"},"本地服务的地址",-1),lo={class:"form-floating mb-3"},to=o("label",{for:"localAddress"},"本地地址",-1),so={key:1},ao=o("h5",null,"自定义域名",-1),ro={class:"form-floating mb-3"},no=o("label",{for:"customDomain"},"自定义域名",-1),co={key:2},io=o("h5",null,"外部端口",-1),uo={class:"input-group mb-3"},po={class:"form-floating"},mo=o("label",{for:"remotePort"},"外部端口",-1),_o={key:3},vo=o("h5",null,"访问密钥",-1),ho={class:"form-floating mb-3"},fo=o("label",{for:"sk"},"访问密钥",-1),wo={name:"Create",setup(bo){const s=m({id:"",name:"",allow_http:!0,allow_https:!0,allow_tcp:!0,allow_udp:!0,allow_stcp:!0,allow_sudp:!0,allow_xtcp:!0,min_port:1e4,max_port:65535}),i=m([]),e=m({name:"",protocol:"http",server_id:"",local_address:"",custom_domain:"",remote_port:"",sk:""});h.get("/servers").then(a=>{i.value=a.data,!e.value.server_id&&i.value.length>0&&(e.value.server_id=i.value[0].id)});function f(){s.value=i.value.find(l=>l.id===e.value.server_id);const a=new URLSearchParams(window.location.search);a.set("server_id",e.value.server_id),window.history.replaceState({},"",`${window.location.pathname}?${a.toString()}`)}function b(){const a=s.value.min_port,l=s.value.max_port;e.value.remote_port=Math.floor(Math.random()*(l-a+1))+a}w(()=>e.value.server_id,f);const k=async()=>{const a=new URLSearchParams(window.location.search);e.value.server_id=a.get("server_id")};y(()=>{k()});const P=()=>{h.post("/tunnels",e.value).then(a=>{(a.status===200||a.status===201)&&alert("创建成功")})};return(a,l)=>(n(),d(v,null,[S,x,o("div",V,[r(o("input",{id:"tunnelName","onUpdate:modelValue":l[0]||(l[0]=t=>e.value.name=t),class:"form-control",placeholder:"起一个易于辨别的名字",type:"text"},null,512),[[u,e.value.name]]),g]),o("div",C,[r(o("select",{id:"serverSelect","onUpdate:modelValue":l[1]||(l[1]=t=>e.value.server_id=t),class:"form-select"},[(n(!0),d(v,null,U(i.value,t=>(n(),d("option",{value:t.id},_(t.name),9,D))),256))],512),[[T,e.value.server_id]]),H]),o("div",M,"端口范围 "+_(s.value.min_port)+"-"+_(s.value.max_port),1),s.value?(n(),d("div",N,[o("div",B,[r(o("input",{id:"protocolHTTP","onUpdate:modelValue":l[2]||(l[2]=t=>e.value.protocol=t),disabled:!s.value.allow_http,class:"form-check-input",type:"radio",value:"http"},null,8,L),[[c,e.value.protocol]]),R]),o("div",X,[r(o("input",{id:"protocolHTTPS","onUpdate:modelValue":l[3]||(l[3]=t=>e.value.protocol=t),disabled:!s.value.allow_https,class:"form-check-input",type:"radio",value:"https"},null,8,A),[[c,e.value.protocol]]),F]),o("div",$,[r(o("input",{id:"protocolTCP","onUpdate:modelValue":l[4]||(l[4]=t=>e.value.protocol=t),disabled:!s.value.allow_tcp,class:"form-check-input",type:"radio",value:"tcp"},null,8,j),[[c,e.value.protocol]]),E]),o("div",q,[r(o("input",{id:"protocolUDP","onUpdate:modelValue":l[5]||(l[5]=t=>e.value.protocol=t),disabled:!s.value.allow_udp,class:"form-check-input",type:"radio",value:"udp"},null,8,z),[[c,e.value.protocol]]),G]),o("div",I,[r(o("input",{id:"protocolSTCP","onUpdate:modelValue":l[6]||(l[6]=t=>e.value.protocol=t),disabled:!s.value.allow_stcp,class:"form-check-input",type:"radio",value:"stcp"},null,8,J),[[c,e.value.protocol]]),K]),o("div",O,[r(o("input",{id:"protocolSUDP","onUpdate:modelValue":l[7]||(l[7]=t=>e.value.protocol=t),disabled:!s.value.allow_sudp,class:"form-check-input",type:"radio",value:"sudp"},null,8,Q),[[c,e.value.protocol]]),W]),o("div",Y,[r(o("input",{id:"protocolXTCP","onUpdate:modelValue":l[8]||(l[8]=t=>e.value.protocol=t),disabled:!s.value.allow_xtcp,class:"form-check-input",type:"radio",value:"xtcp"},null,8,Z),[[c,e.value.protocol]]),oo])])):p("",!0),eo,o("div",lo,[r(o("input",{id:"localAddress","onUpdate:modelValue":l[9]||(l[9]=t=>e.value.local_address=t),class:"form-control",placeholder:"比如 127.0.0.1:80",type:"text"},null,512),[[u,e.value.local_address]]),to]),e.value.protocol==="http"||e.value.protocol==="https"?(n(),d("div",so,[ao,o("div",ro,[r(o("input",{id:"customDomain","onUpdate:modelValue":l[10]||(l[10]=t=>e.value.custom_domain=t),class:"form-control",placeholder:"比如 example.com",type:"text"},null,512),[[u,e.value.custom_domain]]),no])])):p("",!0),e.value.protocol==="tcp"||e.value.protocol==="udp"?(n(),d("div",co,[io,o("div",uo,[o("div",po,[r(o("input",{id:"remotePort","onUpdate:modelValue":l[11]||(l[11]=t=>e.value.remote_port=t),class:"form-control",placeholder:"比如 25565",type:"text"},null,512),[[u,e.value.remote_port]]),mo]),o("button",{class:"btn btn-outline-primary",type:"button",onClick:b},"随机端口")])])):p("",!0),e.value.protocol==="stcp"||e.value.protocol==="sudp"||e.value.protocol==="xtcp"?(n(),d("div",_o,[vo,o("div",ho,[r(o("input",{id:"sk","onUpdate:modelValue":l[12]||(l[12]=t=>e.value.sk=t),class:"form-control",placeholder:"比如 25565",type:"text"},null,512),[[u,e.value.sk]]),fo])])):p("",!0),o("button",{class:"btn btn-primary",onClick:P},"创建")],64))}};export{wo as default};