diff --git a/src/pages/Proxies.tsx b/src/pages/Proxies.tsx index 1aca8ce..90a37c9 100644 --- a/src/pages/Proxies.tsx +++ b/src/pages/Proxies.tsx @@ -1,24 +1,43 @@ import { For, createSignal, onMount } from 'solid-js' +import { twMerge } from 'tailwind-merge' import { useRequest } from '~/signals' import type { Proxy, ProxyProvider } from '~/types' export const Proxies = () => { const request = useRequest() const [proxies, setProxies] = createSignal([]) + const [delayMap, setDelayMap] = createSignal>({}) const [proxyProviders, setProxyProviders] = createSignal([]) + const renderDelay = (proxyname: string) => { + const delay = delayMap()[proxyname] + + if (typeof delay !== 'number' || delay === 0) { + return '' + } + return {delay}ms + } + onMount(async () => { + const { providers } = await request + .get('providers/proxies') + .json<{ providers: Record }>() + const delay = delayMap() + + Object.values(providers).forEach((provider) => { + provider.proxies.forEach((proxy) => { + delay[proxy.name] = proxy.history[proxy.history.length - 1]?.delay + }) + }) + + setDelayMap(delay) + setProxyProviders(Object.values(providers)) + const { proxies } = await request .get('proxies') .json<{ proxies: Record }>() setProxies(Object.values(proxies)) - - const { providers } = await request - .get('providers/proxies') - .json<{ providers: Record }>() - - setProxyProviders(Object.values(providers)) }) return ( @@ -26,11 +45,30 @@ export const Proxies = () => {

Proxies

-
+
{(proxy) => ( -
- {proxy.name} +
+ +
+ {proxy.name} {proxy.type} +
+
+ + {(proxyPoint) => ( +
+ {proxyPoint} {renderDelay(proxyPoint)} +
+ )} +
+
)} @@ -40,11 +78,25 @@ export const Proxies = () => {

Proxy Providers

-
+
{(proxy) => ( -
- {proxy.name} +
+ +
+ {proxy.name} +
+
+ + {(proxyPoint) => ( +
+ {proxyPoint.name} {renderDelay(proxyPoint.name)} +
+ )} +
+
)}