2023-08-14 04:07:49 +00:00
|
|
|
import{r as v,h as k,i as P,o as d,c,a as o,j as s,v as u,k as w,F as _,e as T,l as i,b as p,t as U}from"./app-6d22deb1.js";import{i as m}from"./http-4cf683c0.js";const y=o("h3",null,"创建隧道",-1),S=o("h5",null,"好的名称是好的开始。",-1),V={class:"form-floating mb-3"},g=o("label",{for:"tunnelName"},"隧道名称",-1),x={class:"form-floating mb-3"},C=["value"],D=o("label",{for:"serverSelect"},"服务器",-1),H={key:0},M={class:"form-check form-check-inline"},N=["disabled"],B=o("label",{class:"form-check-label",for:"protocolHTTP"},"HTTP",-1),L={class:"form-check form-check-inline"},R=["disabled"],X=o("label",{class:"form-check-label",for:"protocolHTTPS"},"HTTPS",-1),A={class:"form-check form-check-inline"},F=["disabled"],$=o("label",{class:"form-check-label",for:"protocolTCP"},"TCP",-1),j={class:"form-check form-check-inline"},E=["disabled"],q=o("label",{class:"form-check-label",for:"protocolUDP"},"UDP",-1),z={class:"form-check form-check-inline"},G=["disabled"],I=o("label",{class:"form-check-label",for:"protocolSTCP"},"STCP",-1),J={class:"form-check form-check-inline"},K=["disabled"],O=o("label",{class:"form-check-label",for:"protocolSUDP"},"SUDP",-1),Q={class:"form-check form-check-inline"},W=["disabled"],Y=o("label",{class:"form-check-label",for:"protocolXTCP"},"XTCP",-1),Z=o("h5",{class:"mt-3"},"本地服务的地址",-1),oo={class:"form-floating mb-3"},eo=o("label",{for:"localAddress"},"本地地址",-1),lo={key:1},to=o("h5",null,"自定义域名",-1),so={class:"form-floating mb-3"},ao=o("label",{for:"customDomain"},"自定义域名",-1),ro={key:2},co=o("h5",null,"外部端口",-1),io={class:"form-floating mb-3"},no=o("label",{for:"remotePort"},"外部端口",-1),uo={key:3},po=o("h5",null,"访问密钥",-1),vo={class:"form-floating mb-3"},_o=o("label",{for:"sk"},"访问密钥",-1),bo={name:"Create",setup(mo){const r=v({id:"",name:"",allow_http:!0,allow_https:!0,allow_tcp:!0,allow_udp:!0,allow_stcp:!0,allow_sudp:!0,allow_xtcp:!0}),n=v([]),e=v({name:"",protocol:"http",server_id:"",local_address:"",custom_domain:"",remote_port:"",sk:""});m.get("/servers").then(a=>{n.value=a.data,!e.value.server_id&&n.value.length>0&&(e.value.server_id=n.value[0].id)});function h(){r.value=n.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()}`)}k(()=>e.value.server_id,h);const f=async()=>{const a=new URLSearchParams(window.location.search);e.value.server_id=a.get("server_id")};P(()=>{f()});const b=()=>{m.post("/tunnels",e.value).then(a=>{(a.status===200||a.status===201)&&alert("创建成功")})};return(a,l)=>(d(),c(_,null,[y,S,o("div",V,[s(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",x,[s(o("select",{id:"serverSelect","onUpdate:modelValue":l[1]||(l[1]=t=>e.value.server_id=t),class:"form-select"},[(d(!0),c(_,null,T(n.value,t=>(d(),c("option",{value:t.id},U(t.name),9,C))),256))],512),[[w,e.value.server_id]]),D]),r.value?(d(),c("div",H,[o("div",M,[s(o("input",{id:"protocolHTTP","onUpdate:modelValue":l[2]||(l[2]=t=>e.value.protocol=t),disabled:!r.value.allow_http,class:"form-check-input",type:"radio",value:"http"},null,8,N),[[i,e.value.protocol]]),B]),o("div",L,[s(o("input",{id:"protocolHTTPS","onUpdate:modelValue":l[3]||(l[3]=t=>e.value.protocol=t),disabled:!r.value.allow_https,class:"form-check-input",type:"radio",value:"https"},null,8,R),[[i,e.value.protocol]]),X]),o("div",A,[s(o("input",{id:"protocolTCP","onUpdate:modelValue":l[4]||(l[4]=t=>e.value.protocol=t),disabled:!r.value.allow_tcp,class:"form-check-input",type:"radio",value:"tcp"},null,8,F),[[i,e.value.protocol]]),$]),o("div",j,[s(o("input",{id:"protocolUDP","onUpdate:modelValue":l[5]||(l[5]=t=>e.value.protocol=t),disabled:!r.value.allow_udp,class:"form-check-input",type:"radio",value:"udp"},null,8,E),[[i,e.value.protocol]]),q]),o("div",z,[s(o("input",{id:"pro
|