All checks were successful
Build Multi-Platform Binaries / build (push) Successful in 11m54s
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{k as x,S as u,V as a,U as i,a5 as ae,W as re,r as h,o as se,_ as t,Y as l,N as e,a6 as ie,a4 as T,Z as ue,j as d,$ as c,F as j,X as C,R as H}from"./vue-vendor-k28cQfDw.js";import{u as de,m as ce,N as $,n as pe,o as ke,j as w,B as k,p as m,k as I,f as E,q as ve,b as N,c as L,r as we,t as fe,v as he,w as me,x as ge,y as ye,z as xe,A as F,C as _e}from"./index-BJ4y0MF5.js";import{A as Ce}from"./ArrowBackOutline-QaNKMlLc.js";const be={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},Me=x({name:"AddOutline",render:function(g,s){return i(),u("svg",be,s[0]||(s[0]=[a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M256 112v288"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M400 256H112"},null,-1)]))}}),je={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},Ne=x({name:"CloseOutline",render:function(g,s){return i(),u("svg",je,s[0]||(s[0]=[a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M368 368L144 144"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M368 144L144 368"},null,-1)]))}}),Oe={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},Pe=x({name:"CreateOutline",render:function(g,s){return i(),u("svg",Oe,s[0]||(s[0]=[a("path",{d:"M384 224v184a40 40 0 0 1-40 40H104a40 40 0 0 1-40-40V168a40 40 0 0 1 40-40h167.48",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1),a("path",{d:"M459.94 53.25a16.06 16.06 0 0 0-23.22-.56L424.35 65a8 8 0 0 0 0 11.31l11.34 11.32a8 8 0 0 0 11.34 0l12.06-12c6.1-6.09 6.67-16.01.85-22.38z",fill:"currentColor"},null,-1),a("path",{d:"M399.34 90L218.82 270.2a9 9 0 0 0-2.31 3.93L208.16 299a3.91 3.91 0 0 0 4.86 4.86l24.85-8.35a9 9 0 0 0 3.93-2.31L422 112.66a9 9 0 0 0 0-12.66l-9.95-10a9 9 0 0 0-12.71 0z",fill:"currentColor"},null,-1)]))}}),Te={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},ze=x({name:"DownloadOutline",render:function(g,s){return i(),u("svg",Te,s[0]||(s[0]=[a("path",{d:"M336 176h40a40 40 0 0 1 40 40v208a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V216a40 40 0 0 1 40-40h40",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M176 272l80 80l80-80"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M256 48v288"},null,-1)]))}}),Ue={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},Be=x({name:"PowerOutline",render:function(g,s){return i(),u("svg",Ue,s[0]||(s[0]=[a("path",{d:"M378 108a191.41 191.41 0 0 1 70 148c0 106-86 192-192 192S64 362 64 256a192 192 0 0 1 69-148",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M256 64v192"},null,-1)]))}}),Ve={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},$e=x({name:"PushOutline",render:function(g,s){return i(),u("svg",Ve,s[0]||(s[0]=[a("path",{d:"M336 336h40a40 40 0 0 0 40-40V88a40 40 0 0 0-40-40H136a40 40 0 0 0-40 40v208a40 40 0 0 0 40 40h40",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M176 240l80-80l80 80"},null,-1),a("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M256 464V176"},null,-1)]))}}),Se={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},Ae=x({name:"SaveOutline",render:function(g,s){return i(),u("svg",Se,s[0]||(s[0]=[a("path",{d:"M380.93 57.37A32 32 0 0 0 358.3 48H94.22A46.21 46.21 0 0 0 48 94.22v323.56A46.21 46.21 0 0 0 94.22 464h323.56A46.36 46.36 0 0 0 464 417.78V153.7a32 32 0 0 0-9.37-22.63zM256 416a64 64 0 1 1 64-64a63.92 63.92 0 0 1-64 64zm48-224H112a16 16 0 0 1-16-16v-64a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16v64a16 16 0 0 1-16 16z",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1)]))}}),He={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},q=x({name:"TrashOutline",render:function(g,s){return i(),u("svg",He,s[0]||(s[0]=[ae('<path d="M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></path><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M80 112h352" fill="currentColor"></path><path d="M192 112V72h0a23.93 23.93 0 0 1 24-24h80a23.93 23.93 0 0 1 24 24h0v40" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></path><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M256 176v224"></path><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M184 176l8 224"></path><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M328 176l-8 224"></path>',6)]))}}),Ie={class:"client-view"},Le={style:{margin:"0"}},De={key:0,style:{color:"#999","font-size":"12px"}},Re={key:1,style:{color:"#666","font-size":"14px"}},Ee={style:{"font-weight":"500"}},Fe={style:{color:"#666","font-size":"12px"}},Xe=x({__name:"ClientView",setup(_){const g=re(),s=ue(),v=de(),D=ce(),y=g.params.id,O=h(!1),S=h(""),z=h(""),U=h([]),b=h(!1),B=h(""),M=h([]),K=[{label:"TCP",value:"tcp"},{label:"UDP",value:"udp"},{label:"HTTP",value:"http"},{label:"HTTPS",value:"https"},{label:"SOCKS5",value:"socks5"}],P=h(!1),A=h([]),f=h([]),W=async()=>{try{const{data:r}=await ye();A.value=(r||[]).filter(n=>n.enabled)}catch(r){console.error("Failed to load plugins",r)}},X=async()=>{await W(),f.value=[],P.value=!0},Y=r=>({proxy:"协议",app:"应用",service:"服务",tool:"工具"})[r]||r,R=async()=>{try{const{data:r}=await ke(y);O.value=r.online,S.value=r.last_ping||"",z.value=r.nickname||"",U.value=r.rules||[]}catch(r){console.error("Failed to load client",r)}};se(R);const Z=()=>{B.value=z.value,M.value=U.value.map(r=>({...r,type:r.type||"tcp"})),b.value=!0},G=()=>{b.value=!1},J=()=>{M.value.push({name:"",local_ip:"127.0.0.1",local_port:80,remote_port:8080,type:"tcp"})},Q=r=>{M.value.splice(r,1)},ee=async()=>{try{await we(y,{id:y,nickname:B.value,rules:M.value}),b.value=!1,v.success("保存成功"),R()}catch{v.error("保存失败")}},te=()=>{D.warning({title:"确认删除",content:"确定要删除此客户端吗?",positiveText:"删除",negativeText:"取消",onPositiveClick:async()=>{try{await fe(y),v.success("删除成功"),s.push("/")}catch{v.error("删除失败")}}})},le=async()=>{try{await he(y),v.success("配置已推送")}catch(r){v.error(r.response?.data||"推送失败")}},ne=()=>{D.warning({title:"确认断开",content:"确定要断开此客户端连接吗?",positiveText:"断开",negativeText:"取消",onPositiveClick:async()=>{try{await me(y),O.value=!1,v.success("已断开连接")}catch(r){v.error(r.response?.data||"断开失败")}}})},oe=async()=>{if(f.value.length===0){v.warning("请选择要安装的插件");return}try{await ge(y,f.value),v.success(`已推送 ${f.value.length} 个插件到客户端`),P.value=!1}catch(r){v.error(r.response?.data||"安装失败")}};return(r,n)=>(i(),u("div",Ie,[t(e($),{style:{"margin-bottom":"16px"}},{default:l(()=>[t(e(w),{justify:"space-between",align:"center",wrap:""},{default:l(()=>[t(e(w),{align:"center"},{default:l(()=>[t(e(k),{quaternary:"",onClick:n[0]||(n[0]=o=>e(s).push("/"))},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(Ce))]),_:1})]),default:l(()=>[n[4]||(n[4]=d(" 返回 ",-1))]),_:1}),a("h2",Le,c(z.value||e(y)),1),z.value?(i(),u("span",De,c(e(y)),1)):T("",!0),t(e(I),{type:O.value?"success":"default"},{default:l(()=>[d(c(O.value?"在线":"离线"),1)]),_:1},8,["type"]),S.value?(i(),u("span",Re," 最后心跳: "+c(S.value),1)):T("",!0)]),_:1}),t(e(w),null,{default:l(()=>[O.value?(i(),u(j,{key:0},[t(e(k),{type:"info",onClick:le},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e($e))]),_:1})]),default:l(()=>[n[5]||(n[5]=d(" 推送配置 ",-1))]),_:1}),t(e(k),{type:"success",onClick:X},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(ze))]),_:1})]),default:l(()=>[n[6]||(n[6]=d(" 安装插件 ",-1))]),_:1}),t(e(k),{type:"warning",onClick:ne},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(Be))]),_:1})]),default:l(()=>[n[7]||(n[7]=d(" 断开连接 ",-1))]),_:1})],64)):T("",!0),b.value?T("",!0):(i(),u(j,{key:1},[t(e(k),{type:"primary",onClick:Z},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(Pe))]),_:1})]),default:l(()=>[n[8]||(n[8]=d(" 编辑规则 ",-1))]),_:1}),t(e(k),{type:"error",onClick:te},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(q))]),_:1})]),default:l(()=>[n[9]||(n[9]=d(" 删除 ",-1))]),_:1})],64))]),_:1})]),_:1})]),_:1}),t(e($),{title:"代理规则"},ie({default:l(()=>[b.value?(i(),C(e(w),{key:1,vertical:"",size:12},{default:l(()=>[t(e(N),{label:"昵称","show-feedback":!1},{default:l(()=>[t(e(L),{value:B.value,"onUpdate:value":n[1]||(n[1]=o=>B.value=o),placeholder:"给客户端起个名字(可选)",style:{"max-width":"300px"}},null,8,["value"])]),_:1}),(i(!0),u(j,null,H(M.value,(o,V)=>(i(),C(e($),{key:V,size:"small"},{default:l(()=>[t(e(w),{align:"center"},{default:l(()=>[t(e(N),{label:"名称","show-feedback":!1},{default:l(()=>[t(e(L),{value:o.name,"onUpdate:value":p=>o.name=p,placeholder:"规则名称"},null,8,["value","onUpdate:value"])]),_:2},1024),t(e(N),{label:"类型","show-feedback":!1},{default:l(()=>[t(e(xe),{value:o.type,"onUpdate:value":p=>o.type=p,options:K,style:{width:"100px"}},null,8,["value","onUpdate:value"])]),_:2},1024),t(e(N),{label:"本地IP","show-feedback":!1},{default:l(()=>[t(e(L),{value:o.local_ip,"onUpdate:value":p=>o.local_ip=p,placeholder:"127.0.0.1"},null,8,["value","onUpdate:value"])]),_:2},1024),t(e(N),{label:"本地端口","show-feedback":!1},{default:l(()=>[t(e(F),{value:o.local_port,"onUpdate:value":p=>o.local_port=p,"show-button":!1},null,8,["value","onUpdate:value"])]),_:2},1024),t(e(N),{label:"远程端口","show-feedback":!1},{default:l(()=>[t(e(F),{value:o.remote_port,"onUpdate:value":p=>o.remote_port=p,"show-button":!1},null,8,["value","onUpdate:value"])]),_:2},1024),M.value.length>1?(i(),C(e(k),{key:0,quaternary:"",type:"error",onClick:p=>Q(V)},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(q))]),_:1})]),_:1},8,["onClick"])):T("",!0)]),_:2},1024)]),_:2},1024))),128)),t(e(k),{dashed:"",block:"",onClick:J},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(Me))]),_:1})]),default:l(()=>[n[13]||(n[13]=d(" 添加规则 ",-1))]),_:1})]),_:1})):(i(),u(j,{key:0},[U.value.length===0?(i(),C(e(E),{key:0,description:"暂无代理规则"})):(i(),C(e(ve),{key:1,bordered:!1,"single-line":!1},{default:l(()=>[n[12]||(n[12]=a("thead",null,[a("tr",null,[a("th",null,"名称"),a("th",null,"本地地址"),a("th",null,"远程端口"),a("th",null,"类型")])],-1)),a("tbody",null,[(i(!0),u(j,null,H(U.value,o=>(i(),u("tr",{key:o.name},[a("td",null,c(o.name||"未命名"),1),a("td",null,c(o.local_ip)+":"+c(o.local_port),1),a("td",null,c(o.remote_port),1),a("td",null,[t(e(I),{size:"small"},{default:l(()=>[d(c(o.type||"tcp"),1)]),_:2},1024)])]))),128))])]),_:1}))],64))]),_:2},[b.value?{name:"header-extra",fn:l(()=>[t(e(w),null,{default:l(()=>[t(e(k),{onClick:G},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(Ne))]),_:1})]),default:l(()=>[n[10]||(n[10]=d(" 取消 ",-1))]),_:1}),t(e(k),{type:"primary",onClick:ee},{icon:l(()=>[t(e(m),null,{default:l(()=>[t(e(Ae))]),_:1})]),default:l(()=>[n[11]||(n[11]=d(" 保存 ",-1))]),_:1})]),_:1})]),key:"0"}:void 0]),1024),t(e(pe),{show:P.value,"onUpdate:show":n[3]||(n[3]=o=>P.value=o),preset:"card",title:"安装插件到客户端",style:{width:"500px"}},{footer:l(()=>[t(e(w),{justify:"end"},{default:l(()=>[t(e(k),{onClick:n[2]||(n[2]=o=>P.value=!1)},{default:l(()=>[...n[14]||(n[14]=[d("取消",-1)])]),_:1}),t(e(k),{type:"primary",onClick:oe,disabled:f.value.length===0},{default:l(()=>[d(" 安装 ("+c(f.value.length)+") ",1)]),_:1},8,["disabled"])]),_:1})]),default:l(()=>[A.value.length===0?(i(),C(e(E),{key:0,description:"暂无可用插件"})):(i(),C(e(w),{key:1,vertical:"",size:12},{default:l(()=>[(i(!0),u(j,null,H(A.value,o=>(i(),C(e($),{key:o.name,size:"small"},{default:l(()=>[t(e(w),{justify:"space-between",align:"center"},{default:l(()=>[t(e(w),{vertical:"",size:4},{default:l(()=>[t(e(w),{align:"center"},{default:l(()=>[a("span",Ee,c(o.name),1),t(e(I),{size:"small"},{default:l(()=>[d(c(Y(o.type)),1)]),_:2},1024)]),_:2},1024),a("span",Fe,c(o.description),1)]),_:2},1024),t(e(_e),{checked:f.value.includes(o.name),"onUpdate:checked":V=>{V?f.value.push(o.name):f.value=f.value.filter(p=>p!==o.name)}},null,8,["checked","onUpdate:checked"])]),_:2},1024)]),_:2},1024))),128))]),_:1}))]),_:1},8,["show"])]))}});export{Xe as default};
|