import{a5 as _,_ as f,o as i,k as u,b as r,w as s,aH as c,c as h,p as V,d as g,f as d,aG as p,F as m,n as S,l as y,t as x,V as b,a as v,T as C}from"./index-c5287dcf.js";import{_ as k}from"./_plugin-vue_export-helper-c27b6911.js";const G={setup(){const{tm:e}=_("features/settings");return{tm:e}},data(){return{githubProxies:["https://edgeone.gh-proxy.com","https://hk.gh-proxy.com/","https://gh-proxy.com/","https://gh.llkk.cc"],githubProxyRadioControl:"0",selectedGitHubProxy:"",radioValue:"0",loadingTestingConnection:!1,testingProxies:{},proxyStatus:{}}},methods:{async testSingleProxy(e){this.testingProxies[e]=!0;const o=this.githubProxies[e];try{const a=await f.post("/api/stat/test-ghproxy-connection",{proxy_url:o});console.log(a.data),a.status===200?this.proxyStatus[e]={available:!0,latency:Math.round(a.data.data.latency)}:this.proxyStatus[e]={available:!1,latency:0}}catch{this.proxyStatus[e]={available:!1,latency:0}}finally{this.testingProxies[e]=!1}},async testAllProxies(){this.loadingTestingConnection=!0;const e=this.githubProxies.map((o,a)=>this.testSingleProxy(a));await Promise.all(e),this.loadingTestingConnection=!1}},mounted(){this.selectedGitHubProxy=localStorage.getItem("selectedGitHubProxy")||"",this.radioValue=localStorage.getItem("githubProxyRadioValue")||"0",this.githubProxyRadioControl=localStorage.getItem("githubProxyRadioControl")||"0"},watch:{selectedGitHubProxy:function(e,o){e||(e=""),localStorage.setItem("selectedGitHubProxy",e)},radioValue:function(e){localStorage.setItem("githubProxyRadioValue",e),e==="0"&&(this.selectedGitHubProxy="")},githubProxyRadioControl:function(e){localStorage.setItem("githubProxyRadioControl",e),e!=="-1"?this.selectedGitHubProxy=this.githubProxies[e]||"":this.selectedGitHubProxy=""}}},H=y("h5",null,"GitHub 加速",-1),R=y("span",null,"使用 GitHub 加速",-1),I={key:0,style:{"margin-left":"16px"}},T={class:"d-flex align-center"},B={class:"mr-2"},N={key:0};function z(e,o,a,F,t,P){return i(),u(m,null,[H,r(p,{class:"mt-2",modelValue:t.radioValue,"onUpdate:modelValue":o[0]||(o[0]=l=>t.radioValue=l),"hide-details":"true"},{default:s(()=>[r(c,{label:"不使用 GitHub 加速",value:"0"}),r(c,{value:"1"},{label:s(()=>[R,t.radioValue==="1"?(i(),h(V,{key:0,class:"ml-2",onClick:P.testAllProxies,size:"x-small",variant:"tonal",loading:t.loadingTestingConnection},{default:s(()=>[g(" 测试代理连通性 ")]),_:1},8,["onClick","loading"])):d("",!0)]),_:1})]),_:1},8,["modelValue"]),t.radioValue==="1"?(i(),u("div",I,[r(p,{modelValue:t.githubProxyRadioControl,"onUpdate:modelValue":o[2]||(o[2]=l=>t.githubProxyRadioControl=l),class:"mt-2","hide-details":"true"},{default:s(()=>[(i(!0),u(m,null,S(t.githubProxies,(l,n)=>(i(),h(c,{color:"success",key:l,value:n},{label:s(()=>[y("div",T,[y("span",B,x(l),1),t.proxyStatus[n]?(i(),u("div",N,[r(b,{color:t.proxyStatus[n].available?"success":"error",size:"x-small",class:"mr-1"},{default:s(()=>[g(x(t.proxyStatus[n].available?"可用":"不可用"),1)]),_:2},1032,["color"]),t.proxyStatus[n].available?(i(),h(b,{key:0,color:"info",size:"x-small"},{default:s(()=>[g(x(t.proxyStatus[n].latency)+"ms ",1)]),_:2},1024)):d("",!0)])):d("",!0)])]),_:2},1032,["value"]))),128)),r(c,{color:"primary",value:"-1",label:"自定义"},v({_:2},[t.githubProxyRadioControl==="-1"?{name:"label",fn:s(()=>[r(C,{density:"compact",modelValue:t.selectedGitHubProxy,"onUpdate:modelValue":o[1]||(o[1]=l=>t.selectedGitHubProxy=l),variant:"outlined",style:{width:"100vw"},placeholder:"自定义","hide-details":"true"},null,8,["modelValue"])]),key:"0"}:void 0]),1024)]),_:1},8,["modelValue"])])):d("",!0)],64)}const A=k(G,[["render",z]]);export{A as P};
