From 626c0fcd9a6bf7f550f294bf3974db625827ef5c Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 1 Feb 2026 23:42:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(data-annotation):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A0=87=E6=B3=A8=E4=BB=BB=E5=8A=A1=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 toSafeCount 工具函数确保数值安全处理 - 支持 totalCount 和 total_count 字段兼容性 - --- .../DataAnnotation/Home/DataAnnotation.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx b/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx index 778c7a1..cb2eabd 100644 --- a/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx +++ b/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx @@ -57,6 +57,9 @@ export default function DataAnnotation() { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRows, setSelectedRows] = useState([]); + const toSafeCount = (value: unknown) => + typeof value === "number" && Number.isFinite(value) ? value : 0; + const handleAnnotate = (task: AnnotationTaskListItem) => { const projectId = task.id; if (!projectId) { @@ -207,8 +210,20 @@ export default function DataAnnotation() { width: 100, align: "center" as const, render: (value: number, record: AnnotationTaskListItem) => { - const total = record.totalCount || 0; - const annotated = value || 0; + const total = toSafeCount(record.totalCount ?? record.total_count); + const annotatedRaw = toSafeCount( + value ?? record.annotatedCount ?? record.annotated_count + ); + const segmentationEnabled = + record.segmentationEnabled ?? record.segmentation_enabled; + const inProgressRaw = segmentationEnabled + ? toSafeCount(record.inProgressCount ?? record.in_progress_count) + : 0; + const shouldExcludeInProgress = + total > 0 && annotatedRaw + inProgressRaw > total; + const annotated = shouldExcludeInProgress + ? Math.max(annotatedRaw - inProgressRaw, 0) + : annotatedRaw; const percent = total > 0 ? Math.round((annotated / total) * 100) : 0; return (