From 3693efcf6c516275e86f212a6a8ff944a5134bb9 Mon Sep 17 00:00:00 2001 From: Huanhuan Li Date: Mon, 12 Oct 2026 10:25:58 +0000 Subject: [PATCH] fix(tests): reset test item state when delay test fails (#8231) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(tests): reset test item state when delay test fails * docs(changelog): note test-item stuck-state fix Co-authored-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com> Signed-off-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com> --------- Signed-off-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com> Co-authored-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com> --- Changelog.md | 1 + src/components/test/test-item.tsx | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index ee0c8c66c..36976d462 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ 🐞 修复问题 - 修复通过 URL 导入订阅时,即使导入的订阅并非当前使用的订阅,也会重新加载当前配置的问题 +- 修复「首页」网站测速失败后卡片一直显示测试中的问题 diff --git a/src/components/test/test-item.tsx b/src/components/test/test-item.tsx index 94760d0ad..1f2ee1b78 100644 --- a/src/components/test/test-item.tsx +++ b/src/components/test/test-item.tsx @@ -1,5 +1,5 @@ import { LanguageRounded } from '@mui/icons-material' -import { Box, Divider, MenuItem, Menu, styled, alpha } from '@mui/material' +import { alpha, Box, Divider, Menu, MenuItem, styled } from '@mui/material' import { useLockFn } from 'ahooks' import { useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -29,8 +29,14 @@ export const TestItem = ({ itemData, onEdit, onDelete: removeTest }: Props) => { const onDelay = useCallback(async () => { setDelay(-2) - const result = await cmdTestDelay(url!) - setDelay(result) + try { + const result = await cmdTestDelay(url!) + setDelay(result) + } catch (err) { + // A failed test must not leave the item stuck in the loading state. + setDelay(-1) + showNotice.error(err) + } }, [url]) const onEditTest = () => {