2 lines
5.8 KiB
JavaScript
2 lines
5.8 KiB
JavaScript
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-67d01e14.js";import{i as m}from"./http-77971bb6.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:"protocolSTCP","onUpdate:modelValue":l[6]||(l[6]=t=>e.value.protocol=t),disabled:!r.value.allow_stcp,class:"form-check-input",type:"radio",value:"stcp"},null,8,G),[[i,e.value.protocol]]),I]),o("div",J,[s(o("input",{id:"protocolSUDP","onUpdate:modelValue":l[7]||(l[7]=t=>e.value.protocol=t),disabled:!r.value.allow_sudp,class:"form-check-input",type:"radio",value:"sudp"},null,8,K),[[i,e.value.protocol]]),O]),o("div",Q,[s(o("input",{id:"protocolXTCP","onUpdate:modelValue":l[8]||(l[8]=t=>e.value.protocol=t),disabled:!r.value.allow_xtcp,class:"form-check-input",type:"radio",value:"xtcp"},null,8,W),[[i,e.value.protocol]]),Y])])):p("",!0),Z,o("div",oo,[s(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]]),eo]),e.value.protocol==="http"||e.value.protocol==="https"?(d(),c("div",lo,[to,o("div",so,[s(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]]),ao])])):p("",!0),e.value.protocol==="tcp"||e.value.protocol==="udp"?(d(),c("div",ro,[co,o("div",io,[s(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]]),no])])):p("",!0),e.value.protocol==="stcp"||e.value.protocol==="sudp"||e.value.protocol==="xtcp"?(d(),c("div",uo,[po,o("div",vo,[s(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]]),_o])])):p("",!0),o("button",{class:"btn btn-primary",onClick:b},"创建")],64))}};export{bo as default};
|