import { createMemo } from 'solid-js' import { twMerge } from 'tailwind-merge' import { useProxies } from '~/signals/proxies' import { getClassNameByDelay } from '~/utils/proxies' export default (props: { proxyName: string isSelected?: boolean onClick?: () => void }) => { const { proxyName, isSelected, onClick } = props const { proxyNodeMap } = useProxies() const proxyNode = createMemo(() => proxyNodeMap()[proxyName]) const Delay = (delay: number | undefined) => { if (typeof delay !== 'number' || delay === 0) { return '' } const color = getClassNameByDelay(delay) const textClassName = `text-${color}` return {delay}ms } const formatProxyType = (type = '') => { const t = type.toLowerCase() if (t.includes('shadowsocks')) { return t.replace('shadowsocks', 'ss') } return t } return (
onClick?.()} data-tip={proxyName} >
{proxyName}
{formatProxyType(proxyNode()?.type)} {proxyNode()?.udp && ' :: udp'}
{Delay(proxyNode()?.delay)}
) }