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:modelVal
|