mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-19 14:31:57 +08:00
Fix: meanDelay may be zero
This commit is contained in:
parent
20978b12b0
commit
2428fea986
@ -53,7 +53,7 @@ export function Proxy (props: ProxyProps) {
|
|||||||
const meanDelay = config.history?.length ? config.history.slice(-1)[0].meanDelay : undefined
|
const meanDelay = config.history?.length ? config.history.slice(-1)[0].meanDelay : undefined
|
||||||
|
|
||||||
const delayText = delay === 0 ? '-' : `${delay}ms`
|
const delayText = delay === 0 ? '-' : `${delay}ms`
|
||||||
const meanDelayText = meanDelay === undefined || meanDelay === 0 ? '' : `(${meanDelay}ms)`
|
const meanDelayText = !meanDelay ? '' : `(${meanDelay}ms)`
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const handler = () => { speedTest() }
|
const handler = () => { speedTest() }
|
||||||
@ -64,7 +64,8 @@ export function Proxy (props: ProxyProps) {
|
|||||||
const hasError = useMemo(() => delay === 0, [delay])
|
const hasError = useMemo(() => delay === 0, [delay])
|
||||||
const color = useMemo(
|
const color = useMemo(
|
||||||
() => Object.keys(TagColors).find(
|
() => Object.keys(TagColors).find(
|
||||||
threshold => (meanDelay ?? delay) <= TagColors[threshold as keyof typeof TagColors],
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
|
threshold => (meanDelay || delay) <= TagColors[threshold as keyof typeof TagColors],
|
||||||
),
|
),
|
||||||
[delay, meanDelay],
|
[delay, meanDelay],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user