From c53d9624ca42cd9fba4d5f6d3b44b2912dedf878 Mon Sep 17 00:00:00 2001 From: kunish Date: Tue, 5 Sep 2023 02:42:54 +0800 Subject: [PATCH] refactor: specialType --- src/components/ProxyNodeCard.tsx | 22 +++++++++++----------- src/helpers/proxies.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/ProxyNodeCard.tsx b/src/components/ProxyNodeCard.tsx index 1e3cdb8..d3152c6 100644 --- a/src/components/ProxyNodeCard.tsx +++ b/src/components/ProxyNodeCard.tsx @@ -1,7 +1,7 @@ -import { createMemo } from 'solid-js' +import { createMemo, Show } from 'solid-js' import { twMerge } from 'tailwind-merge' import { Latency } from '~/components' -import { filterGroupType, formatProxyType } from '~/helpers' +import { filterSpecialProxyType, formatProxyType } from '~/helpers' import { useProxies } from '~/signals' export const ProxyNodeCard = (props: { @@ -12,6 +12,14 @@ export const ProxyNodeCard = (props: { const { proxyName, isSelected, onClick } = props const { proxyNodeMap } = useProxies() const proxyNode = createMemo(() => proxyNodeMap()[proxyName]) + const specialType = () => + filterSpecialProxyType(proxyNode()?.type) + ? proxyNode()?.xudp + ? 'xudp' + : proxyNode()?.udp + ? 'udp' + : null + : null return (
{formatProxyType(proxyNode()?.type)} - {filterGroupType(proxyNode()?.type) ? ( - - {' :: '} - {proxyNode()?.xudp && 'x'} - {proxyNode()?.udp && 'udp'} - - ) : ( - {proxyNode()?.now} - )} + {` :: ${specialType()}`}
diff --git a/src/helpers/proxies.ts b/src/helpers/proxies.ts index 0d2958a..f2d2680 100644 --- a/src/helpers/proxies.ts +++ b/src/helpers/proxies.ts @@ -34,7 +34,7 @@ export const formatProxyType = (type = '') => { return t } -export const filterGroupType = (type = '') => { +export const filterSpecialProxyType = (type = '') => { const t = type.toLowerCase() const conditions = [ 'selector',