From f0fbe098381c2b33c84b2eb5427f9db4b227e364 Mon Sep 17 00:00:00 2001 From: "riolu.rs" Date: Tue, 5 Sep 2023 01:30:17 +0800 Subject: [PATCH] fix(proxies): group type does not show UDP --- src/components/ProxyNodeCard.tsx | 12 ++++++++++-- src/helpers/proxies.ts | 17 ++++++++++++++++- src/pages/Proxies.tsx | 2 +- src/signals/proxies.ts | 4 ++++ src/types/index.d.ts | 1 + 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/components/ProxyNodeCard.tsx b/src/components/ProxyNodeCard.tsx index c2a14d2..1e3cdb8 100644 --- a/src/components/ProxyNodeCard.tsx +++ b/src/components/ProxyNodeCard.tsx @@ -1,7 +1,7 @@ import { createMemo } from 'solid-js' import { twMerge } from 'tailwind-merge' import { Latency } from '~/components' -import { formatProxyType } from '~/helpers' +import { filterGroupType, formatProxyType } from '~/helpers' import { useProxies } from '~/signals' export const ProxyNodeCard = (props: { @@ -32,7 +32,15 @@ export const ProxyNodeCard = (props: { )} > {formatProxyType(proxyNode()?.type)} - {proxyNode()?.udp && ' :: udp'} + {filterGroupType(proxyNode()?.type) ? ( + + {' :: '} + {proxyNode()?.xudp && 'x'} + {proxyNode()?.udp && 'udp'} + + ) : ( + {proxyNode()?.now} + )}
diff --git a/src/helpers/proxies.ts b/src/helpers/proxies.ts index e29381e..0d2958a 100644 --- a/src/helpers/proxies.ts +++ b/src/helpers/proxies.ts @@ -28,12 +28,27 @@ export const formatProxyType = (type = '') => { const t = type.toLowerCase() if (t.includes('shadowsocks')) { - return t.replace('shadowsocks', 'ss') + return 'ss' } return t } +export const filterGroupType = (type = '') => { + const t = type.toLowerCase() + const conditions = [ + 'selector', + 'direct', + 'reject', + 'urltest', + 'loadbalance', + 'fallback', + 'relay', + ] + + return !conditions.includes(t) +} + export const sortProxiesByOrderingType = ( proxyNames: string[], proxyLatencyMap: Record, diff --git a/src/pages/Proxies.tsx b/src/pages/Proxies.tsx index abcaa3d..0b7e069 100644 --- a/src/pages/Proxies.tsx +++ b/src/pages/Proxies.tsx @@ -71,7 +71,7 @@ export default () => {
- {proxy.type} :: {proxy.now} + {proxy.type} {proxy.now?.length > 0 && ` :: ${proxy.now}`}
{ newProxyNodeMap[proxy.name] = { udp: proxy.udp, + xudp: proxy.xudp, type: proxy.type, + now: proxy.now, name: proxy.name, } newLatencyMap[proxy.name] = latency diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 338ebf0..bda0cf1 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -28,6 +28,7 @@ export type ProxyNode = { tfo: boolean udp: boolean xudp: boolean + now: string id: string extra: Record history: {