import { useI18n } from '@solid-primitives/i18n' import { IconBrandSpeedtest } from '@tabler/icons-solidjs' import { createSignal, Show } from 'solid-js' import { Button, Collapse, ForTwoColumns, ProxyCardGroups, ProxyNodePreview, } from '~/components' import { getBtnElFromClickEvent, sortProxiesByOrderingType } from '~/helpers' import { proxiesOrderingType, useProxies } from '~/signals' import type { Proxy } from '~/types' export default () => { const [t] = useI18n() const { proxies, setProxyGroupByProxyName, latencyTestByProxyGroupName, latencyMap, } = useProxies() const [collapsedMap, setCollapsedMap] = createSignal>( {}, ) const onProxyNodeClick = async (proxy: Proxy, proxyName: string) => { void setProxyGroupByProxyName(proxy, proxyName) } const onSpeedTestClick = async (e: MouseEvent, name: string) => { const el = getBtnElFromClickEvent(e) el.classList.add('animate-pulse') e.stopPropagation() await latencyTestByProxyGroupName(name) el.classList.remove('animate-pulse') } return (

{t('proxies')}

{ const sortedProxyNames = sortProxiesByOrderingType( proxy.all ?? [], latencyMap(), proxiesOrderingType(), ) const title = ( <>
{proxy.name}
{proxy.type} :: {proxy.now}
) const content = ( { void onProxyNodeClick(proxy, name) }} /> ) return ( setCollapsedMap({ ...collapsedMap(), [`group-${proxy.name}`]: val, }) } /> ) })} />
) }