feat(proxies): show latency result only when possible

This commit is contained in:
kunish 2024-10-13 02:30:05 +08:00
parent dfcc750a12
commit 4314e64785
No known key found for this signature in database
GPG Key ID: 67D3ACD788F3A7CD
2 changed files with 14 additions and 14 deletions

View File

@ -68,7 +68,9 @@ export const ProxyPreviewBar = (props: {
/> />
</div> </div>
<Latency proxyName={props.now} /> <Show when={props.now}>
<Latency proxyName={props.now!} />
</Show>
</div> </div>
) )
} }

View File

@ -2,7 +2,7 @@ import { twMerge } from 'tailwind-merge'
import { Latency } from '~/components' import { Latency } from '~/components'
import { latencyQualityMap, useProxies } from '~/signals' import { latencyQualityMap, useProxies } from '~/signals'
const LatencyDots = (props: { const LatencyDot = (props: {
name: string name: string
latency?: number latency?: number
selected: boolean selected: boolean
@ -51,21 +51,19 @@ export const ProxyPreviewDots = (props: {
getLatencyByName(name), getLatencyByName(name),
])} ])}
> >
{([name, latency]) => { {([name, latency]) => (
const isSelected = props.now === name <LatencyDot
name={name}
return ( latency={latency}
<LatencyDots selected={props.now === name}
name={name} />
latency={latency} )}
selected={isSelected}
/>
)
}}
</For> </For>
</div> </div>
<Latency proxyName={props.now} /> <Show when={props.now}>
<Latency proxyName={props.now!} />
</Show>
</div> </div>
) )
} }