2 lines
7.0 KiB
JavaScript
2 lines
7.0 KiB
JavaScript
var T=(a,f,t)=>new Promise((m,p)=>{var v=u=>{try{c(t.next(u))}catch(_){p(_)}},V=u=>{try{c(t.throw(u))}catch(_){p(_)}},c=u=>u.done?m(u.value):Promise.resolve(u.value).then(v,V);c((t=t.apply(a,f)).next())});import{g as R,a as h,u as A,b as N}from"./server-CW-iJxYa.js";import{e as P,C as G,E as x,d as C,r as D,c as L,w as n,a as S,o as B,b as l,g,h as o,m as w,at as O,au as H,_ as q}from"./index-C6A9XM5L.js";const W=P({ipScope:[{required:!0,message:"不能为空",trigger:"blur"}],listenPort:[{required:!0,message:"不能为空",trigger:"blur"}]}),$=G({id:"pure-globalSetting",state:()=>({endpointAddress:"",dnsServer:[],MTU:0,persistentKeepalive:0,firewallMark:"",table:"",configFilePath:""}),getters:{getGlobalSetting(a){return a},getEndpointAddress(a){return a.endpointAddress}},actions:{SET_ENDPOINT_ADDRESS(a){this.endpointAddress=a},SET_DNS_SERVER(a){this.dnsServer=a},SET_MTU(a){this.MTU=a},SET_PERSISTENT_KEEPALIVE(a){this.persistentKeepalive=a},SET_FIREWALL_MARK(a){this.firewallMark=a},SET_TABLE(a){this.table=a},SET_CONFIG_FILE_PATH(a){this.configFilePath=a},getGlobalSettingApi(){return T(this,null,function*(){return new Promise((a,f)=>{R().then(t=>{t.code===200&&(this.SET_ENDPOINT_ADDRESS(t.data.endpointAddress),this.SET_DNS_SERVER(t.data.dnsServer),this.SET_MTU(t.data.MTU),this.SET_PERSISTENT_KEEPALIVE(t.data.persistentKeepalive),this.SET_FIREWALL_MARK(t.data.firewallMark),this.SET_TABLE(t.data.table),this.SET_CONFIG_FILE_PATH(t.data.configFilePath)),a(t)}).catch(t=>{f(t)})})})},updateGlobalSettingApi(a){return T(this,null,function*(){return new Promise((f,t)=>{h(a).then(m=>{f(m)}).catch(m=>{t(m)})})})}}});function b(){return $(x)}const I=a=>(O("data-v-c0c91358"),a=a(),H(),a),z=I(()=>g("div",{class:"card-header"},[g("span",null,"服务端信息")],-1)),j={class:"server-form"},J=I(()=>g("div",{class:"card-header"},[g("span",null,"全局配置信息")],-1)),Q=C({name:"Server",__name:"server",setup(a){const f=D();let t=P({id:"",ipScope:"",listenPort:0,privateKey:"",publicKey:"",postUpScript:"",preDownScript:"",postDownScript:""});const m=D();let p=P({endpointAddress:"",dnsServer:[],MTU:0,persistentKeepalive:0,firewallMark:"",table:"",configFilePath:""});const v=()=>{A().getServerApi().then(d=>{if(d.code===200){const e=A().getServerInfo;t.id=e.id||"",t.ipScope=e.ipScope||"",t.listenPort=e.listenPort||0,t.privateKey=e.privateKey||"",t.publicKey=e.publicKey||"",t.postUpScript=e.postUpScript||"",t.preDownScript=e.preDownScript||"",t.postDownScript=e.postDownScript||""}})},V=d=>{d&&d.validate((e,s)=>{if(!e)return s;A().updateServerApi(t).then(i=>{i.code===200&&v()})})},c=()=>{b().getGlobalSettingApi().then(d=>{if(d.code===200){const e=b().getGlobalSetting;p.endpointAddress=e.endpointAddress||"",p.dnsServer=e.dnsServer||[],p.MTU=e.MTU||0,p.persistentKeepalive=e.persistentKeepalive||0,p.firewallMark=e.firewallMark||"",p.table=e.table||"",p.configFilePath=e.configFilePath||""}})},u=d=>{d&&d.validate((e,s)=>{if(!e)return s;b().updateGlobalSettingApi(p).then(i=>{i.code===200&&c()})})},_=()=>{N().then(d=>{d.code===200&&(b().SET_ENDPOINT_ADDRESS(d.data.IP),p.endpointAddress=b().getEndpointAddress)})};return v(),c(),(d,e)=>{const s=S("el-input"),i=S("el-form-item"),M=S("el-input-number"),E=S("el-button"),U=S("el-form"),y=S("el-card"),K=S("el-col"),F=S("el-select"),k=S("el-row");return B(),L(k,{gutter:10},{default:n(()=>[l(K,{span:10,style:{"padding-left":"50px"}},{default:n(()=>[l(y,{class:"left-card",style:{"max-width":"800px"}},{header:n(()=>[z]),default:n(()=>[g("div",j,[l(U,{ref_key:"serverFormRef",ref:f,model:o(t),rules:o(W),"label-position":"top"},{default:n(()=>[l(i,{prop:"ipScope",label:"子网IP段"},{default:n(()=>[l(s,{modelValue:o(t).ipScope,"onUpdate:modelValue":e[0]||(e[0]=r=>o(t).ipScope=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"listenPort",label:"监听端口"},{default:n(()=>[l(M,{modelValue:o(t).listenPort,"onUpdate:modelValue":e[1]||(e[1]=r=>o(t).listenPort=r),min:49152,max:65535},null,8,["modelValue"])]),_:1}),l(i,{prop:"privateKey",label:"私钥"},{default:n(()=>[l(s,{modelValue:o(t).privateKey,"onUpdate:modelValue":e[2]||(e[2]=r=>o(t).privateKey=r),disabled:""},null,8,["modelValue"])]),_:1}),l(i,{prop:"publicKey",label:"公钥"},{default:n(()=>[l(s,{modelValue:o(t).publicKey,"onUpdate:modelValue":e[3]||(e[3]=r=>o(t).publicKey=r),disabled:""},null,8,["modelValue"])]),_:1}),l(i,{prop:"postUpScript",label:"postUpScript"},{default:n(()=>[l(s,{modelValue:o(t).postUpScript,"onUpdate:modelValue":e[4]||(e[4]=r=>o(t).postUpScript=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"postDownScript",label:"postDownScript"},{default:n(()=>[l(s,{modelValue:o(t).preDownScript,"onUpdate:modelValue":e[5]||(e[5]=r=>o(t).preDownScript=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"postDownScript",label:"postDownScript"},{default:n(()=>[l(s,{modelValue:o(t).postDownScript,"onUpdate:modelValue":e[6]||(e[6]=r=>o(t).postDownScript=r)},null,8,["modelValue"])]),_:1}),l(i,null,{default:n(()=>[l(E,{type:"primary",onClick:e[7]||(e[7]=r=>V(f.value))},{default:n(()=>[w("确认")]),_:1})]),_:1})]),_:1},8,["model","rules"])])]),_:1})]),_:1}),l(K,{span:10,style:{"padding-left":"50px"}},{default:n(()=>[l(y,{style:{"max-width":"800px"}},{header:n(()=>[J]),default:n(()=>[l(U,{ref_key:"configFormRef",ref:m,model:o(p),"label-position":"top"},{default:n(()=>[l(i,{prop:"endpointAddress",label:"endpointAddress"},{default:n(()=>[l(s,{modelValue:o(p).endpointAddress,"onUpdate:modelValue":e[8]||(e[8]=r=>o(p).endpointAddress=r)},null,8,["modelValue"]),l(E,{size:"small",type:"warning",class:"getIp",onClick:_},{default:n(()=>[w("获取IP")]),_:1})]),_:1}),l(i,{prop:"dnsServer",label:"dnsServer"},{default:n(()=>[l(F,{modelValue:o(p).dnsServer,"onUpdate:modelValue":e[9]||(e[9]=r=>o(p).dnsServer=r),clearable:!0,"reserve-keyword":!1,"suffix-icon":"","tag-type":"success","popper-class":"options-class",placeholder:"",multiple:"",filterable:"","allow-create":"","default-first-option":""},null,8,["modelValue"])]),_:1}),l(i,{prop:"MTU",label:"MTU"},{default:n(()=>[l(s,{modelValue:o(p).MTU,"onUpdate:modelValue":e[10]||(e[10]=r=>o(p).MTU=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"persistentKeepalive",label:"persistentKeepalive"},{default:n(()=>[l(s,{modelValue:o(p).persistentKeepalive,"onUpdate:modelValue":e[11]||(e[11]=r=>o(p).persistentKeepalive=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"firewallMark",label:"firewallMark"},{default:n(()=>[l(s,{modelValue:o(p).firewallMark,"onUpdate:modelValue":e[12]||(e[12]=r=>o(p).firewallMark=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"table",label:"table"},{default:n(()=>[l(s,{modelValue:o(p).table,"onUpdate:modelValue":e[13]||(e[13]=r=>o(p).table=r)},null,8,["modelValue"])]),_:1}),l(i,{prop:"configFilePath",label:"configFilePath"},{default:n(()=>[l(s,{modelValue:o(p).configFilePath,"onUpdate:modelValue":e[14]||(e[14]=r=>o(p).configFilePath=r)},null,8,["modelValue"])]),_:1}),l(i,null,{default:n(()=>[l(E,{type:"primary",onClick:e[15]||(e[15]=r=>u(m.value))},{default:n(()=>[w("确认")]),_:1})]),_:1})]),_:1},8,["model"])]),_:1})]),_:1})]),_:1})}}}),ee=q(Q,[["__scopeId","data-v-c0c91358"]]);export{ee as default};
|