import { createMemo } from 'solid-js' import { twMerge } from 'tailwind-merge' import { useProxies } from '~/signals/proxies' export default (props: { proxyName: string isSelected?: boolean onClick?: () => void }) => { const { proxyName, isSelected, onClick } = props const { delayMap, proxyNodeMap } = useProxies() const proxyNode = createMemo(() => proxyNodeMap()[proxyName]) const Delay = (proxyname: string) => { const delay = delayMap()[proxyname] if (typeof delay !== 'number' || delay === 0) { return '' } let textClassName = 'text-green-500' if (delay > 500) { textClassName = 'text-red-500' } else if (delay > 200) { textClassName = 'text-yellow-500' } return {delay}ms } const formatProxyType = (type: string) => { 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(proxyName)}
) }