2 lines
6.1 KiB
JavaScript
2 lines
6.1 KiB
JavaScript
var J=Object.defineProperty,q=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var R=(e,a,l)=>a in e?J(e,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[a]=l,u=(e,a)=>{for(var l in a||(a={}))P.call(a,l)&&R(e,l,a[l]);if(C)for(var l of C(a))O.call(a,l)&&R(e,l,a[l]);return e},E=(e,a)=>q(e,F(a));var j=(e,a)=>{var l={};for(var s in e)P.call(e,s)&&a.indexOf(s)<0&&(l[s]=e[s]);if(e!=null&&C)for(var s of C(e))a.indexOf(s)<0&&O.call(e,s)&&(l[s]=e[s]);return l};import{R as m,g as K,r as t,k as W,J as Q,j as X}from"./vendor.38e754a4.js";import{r as Y}from"./logs.4dcb9935.js";import{S}from"./Select.29a5a6ae.js";import{s as A,b as Z,d as T,e as $,u as ee,c as M,h as te,g as B,i as ae,o as ne,j as k,k as le,C as se,l as re,B as oe,n as ce,q as ie}from"./index.ee5bc09a.js";const{useState:pe,useRef:ue,useEffect:me,useCallback:de}=m;function ge(e){return m.createElement("input",u({className:A.input},e))}function xe(l){var s=l,{value:e}=s,a=j(s,["value"]);const[i,r]=pe(e),d=ue(e);me(()=>{d.current!==e&&r(e),d.current=e},[e]);const g=de(b=>r(b.target.value),[r]);return m.createElement("input",u({className:A.input,value:i,onChange:g},a))}const fe="_root_1tdl3_1",Ee="_section_1tdl3_2",he="_wrapSwitch_1tdl3_26",ve="_sep_1tdl3_32",Ce="_label_1tdl3_45";var c={root:fe,section:Ee,wrapSwitch:he,sep:ve,label:Ce};const be="_fieldset_1ghjp_1",ye="_input_1ghjp_9",Se="_cnt_1ghjp_9";var _={fieldset:be,input:ye,cnt:Se};function ke({OptionComponent:e,optionPropsList:a,selectedIndex:l,onChange:s}){const i=K("visually-hidden",_.input),r=d=>{s(d.target.value)};return m.createElement("fieldset",{className:_.fieldset},a.map((d,g)=>m.createElement("label",{key:g},m.createElement("input",{type:"radio",checked:l===g,name:"selection",value:g,"aria-labelledby":"traffic chart type "+g,onChange:r,className:i}),m.createElement("div",{className:_.cnt},m.createElement(e,u({},d))))))}const _e={legend:{display:!1},scales:{xAxes:[{display:!1}],yAxes:[{display:!1}]}},D=[23e3,35e3,46e3,33e3,9e4,68e3,23e3,45e3],we=[184e3,183e3,196e3,182e3,19e4,186e3,182e3,189e3],Ie=D;function Ne({id:e}){const a=Z.read(),l=t.exports.useMemo(()=>({labels:Ie,datasets:[E(u(u({},T),$[e].up),{data:D}),E(u(u({},T),$[e].down),{data:we})]}),[e]),s="chart-"+e;return ee(a,s,l,null,_e),m.createElement("div",{style:{width:100,padding:5}},m.createElement("canvas",{id:s}))}const{useEffect:U,useState:Le,useCallback:x,useRef:Pe,useMemo:Oe}=X,Re=[{id:0},{id:1},{id:2},{id:3}],je=[["debug","Debug"],["warning","Warning"],["info","Info"],["error","Error"],["silent","Silent"]],Ae=[{key:"port",label:"HTTP Proxy Port"},{key:"socks-port",label:"SOCKS5 Proxy Port"},{key:"mixed-port",label:"Mixed Port"},{key:"redir-port",label:"Redir Port"}],Te=[["zh","\u4E2D\u6587"],["en","English"]],$e=[["Global","Global"],["Rule","Rule"],["Direct","Direct"]],Me=e=>({configs:te(e),apiConfig:B(e)}),Be=e=>({selectedChartStyleIndex:ce(e),latencyTestUrl:ie(e),apiConfig:B(e)}),De=M(Be)(Ve);var Fe=M(Me)(Ue);function Ue({dispatch:e,configs:a,apiConfig:l}){return U(()=>{e(ae(l))},[e,l]),t.exports.createElement(De,{configs:a})}function Ve({dispatch:e,configs:a,selectedChartStyleIndex:l,latencyTestUrl:s,apiConfig:i}){const[r,d]=Le(a),g=Pe(a);U(()=>{g.current!==a&&d(a),g.current=a},[a]);const b=x(()=>{e(ne("apiConfig"))},[e]),f=x((n,o)=>{d(E(u({},r),{[n]:o}))},[r]),V=x(n=>{const o="allow-lan",p=n;f(o,p),e(k(i,{"allow-lan":p}))},[i,e,f]),h=x(({name:n,value:o})=>{switch(n){case"mode":case"log-level":f(n,o),e(k(i,{[n]:o})),n==="log-level"&&Y(E(u({},i),{logLevel:o}));break;case"redir-port":case"socks-port":case"mixed-port":case"port":if(o!==""){const p=parseInt(o,10);if(p<0||p>65535)return}f(n,o);break;default:return}},[i,e,f]),z=x(n=>h(n.target),[h]),{selectChartStyleIndex:G,updateAppConfig:w}=le(),I=x(n=>{const o=n.target,{name:p,value:L}=o;switch(p){case"port":case"socks-port":case"mixed-port":case"redir-port":{const y=parseInt(L,10);if(y<0||y>65535)return;e(k(i,{[p]:y}));break}case"latencyTestUrl":{w(p,L);break}default:throw new Error(`unknown input name ${p}`)}},[i,e,w]),H=Oe(()=>{const n=r.mode;return typeof n=="string"&&n[0].toUpperCase()+n.slice(1)},[r.mode]),{t:v,i18n:N}=W();return t.exports.createElement("div",null,t.exports.createElement(se,{title:v("Config")}),t.exports.createElement("div",{className:c.root},Ae.map(n=>r[n.key]!==void 0?t.exports.createElement("div",{key:n.key},t.exports.createElement("div",{className:c.label},n.label),t.exports.createElement(ge,{name:n.key,value:r[n.key],onChange:z,onBlur:I})):null),t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},"Mode"),t.exports.createElement(S,{options:$e,selected:H,onChange:n=>h({name:"mode",value:n.target.value})})),t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},"Log Level"),t.exports.createElement(S,{options:je,selected:r["log-level"],onChange:n=>h({name:"log-level",value:n.target.value})})),t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},"Allow LAN"),t.exports.createElement("div",{className:c.wrapSwitch},t.exports.createElement(re,{name:"allow-lan",checked:r["allow-lan"],onChange:V})))),t.exports.createElement("div",{className:c.sep},t.exports.createElement("div",null)),t.exports.createElement("div",{className:c.section},t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},v("latency_test_url")),t.exports.createElement(xe,{name:"latencyTestUrl",type:"text",value:s,onBlur:I})),t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},v("lang")),t.exports.createElement("div",null,t.exports.createElement(S,{options:Te,selected:N.language,onChange:n=>N.changeLanguage(n.target.value)}))),t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},v("chart_style")),t.exports.createElement(ke,{OptionComponent:Ne,optionPropsList:Re,selectedIndex:l,onChange:G})),t.exports.createElement("div",null,t.exports.createElement("div",{className:c.label},"Action"),t.exports.createElement(oe,{start:t.exports.createElement(Q,{size:16}),label:"Switch backend",onClick:b}))))}export{Fe as default};
|