From 09a4dbe04c321c47a87c0938da46c0bfddcee6f3 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Wed, 15 Jul 2026 14:39:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20formatDuration=20=E4=B8=8D=E5=8F=96?= =?UTF-8?q?=E6=95=B4=E5=AF=BC=E8=87=B4=E6=98=BE=E7=A4=BA=E6=B5=AE=E7=82=B9?= =?UTF-8?q?=E6=95=B0=E7=A7=92=EF=BC=88=E5=A6=82=209.542993=E7=A7=92?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 全局搜索发现 4 处 formatDuration 函数中 seconds % 60 未做取整, 当后端返回浮点数 total_duration 时直接拼接显示。 修复:先 Math.round(seconds) 再取模,影响页面: - 剪辑计划列表页(EditPlans.tsx) - 模板库页面(TemplateLibrary.tsx) - 查重详情页(DuplicationDetail.tsx) - 查重结果页(DuplicationResults.tsx) --- apps/web/src/pages/duplication/DuplicationDetail.tsx | 5 +++-- apps/web/src/pages/duplication/DuplicationResults.tsx | 5 +++-- apps/web/src/pages/edit-plans/EditPlans.tsx | 5 +++-- apps/web/src/pages/templates/TemplateLibrary.tsx | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/web/src/pages/duplication/DuplicationDetail.tsx b/apps/web/src/pages/duplication/DuplicationDetail.tsx index 39ad49949..ada59f3a9 100644 --- a/apps/web/src/pages/duplication/DuplicationDetail.tsx +++ b/apps/web/src/pages/duplication/DuplicationDetail.tsx @@ -33,8 +33,9 @@ const formatSize = (bytes: number) => { /** 格式化时长 */ const formatDuration = (seconds?: number) => { if (!seconds) return "-"; - const m = Math.floor(seconds / 60); - const s = seconds % 60; + const totalSec = Math.round(seconds); + const m = Math.floor(totalSec / 60); + const s = totalSec % 60; return m > 0 ? `${m}分${s}秒` : `${s}秒`; }; diff --git a/apps/web/src/pages/duplication/DuplicationResults.tsx b/apps/web/src/pages/duplication/DuplicationResults.tsx index d2bb87da5..e150b215c 100644 --- a/apps/web/src/pages/duplication/DuplicationResults.tsx +++ b/apps/web/src/pages/duplication/DuplicationResults.tsx @@ -59,8 +59,9 @@ const formatSize = (bytes: number) => { /** 格式化时长 */ const formatDuration = (seconds?: number) => { if (!seconds) return "-"; - const m = Math.floor(seconds / 60); - const s = seconds % 60; + const totalSec = Math.round(seconds); + const m = Math.floor(totalSec / 60); + const s = totalSec % 60; return m > 0 ? `${m}分${s}秒` : `${s}秒`; }; diff --git a/apps/web/src/pages/edit-plans/EditPlans.tsx b/apps/web/src/pages/edit-plans/EditPlans.tsx index 89e590526..f78a4a8f2 100644 --- a/apps/web/src/pages/edit-plans/EditPlans.tsx +++ b/apps/web/src/pages/edit-plans/EditPlans.tsx @@ -86,8 +86,9 @@ const STATUS_CONFIG: Record< /** 格式化时长 */ const formatDuration = (seconds: number): string => { if (seconds <= 0) return "-"; - const m = Math.floor(seconds / 60); - const s = seconds % 60; + const totalSec = Math.round(seconds); + const m = Math.floor(totalSec / 60); + const s = totalSec % 60; if (m === 0) return `${s}秒`; return `${m}分${s > 0 ? `${s}秒` : ""}`; }; diff --git a/apps/web/src/pages/templates/TemplateLibrary.tsx b/apps/web/src/pages/templates/TemplateLibrary.tsx index 859af06ff..333b0c4c7 100644 --- a/apps/web/src/pages/templates/TemplateLibrary.tsx +++ b/apps/web/src/pages/templates/TemplateLibrary.tsx @@ -92,8 +92,9 @@ const gradientForCategory = (category: string): string => { /** 格式化时长 */ const formatDuration = (seconds: number | undefined | null): string => { if (!seconds || seconds <= 0) return "0秒"; - const m = Math.floor(seconds / 60); - const s = seconds % 60; + const totalSec = Math.round(seconds); + const m = Math.floor(totalSec / 60); + const s = totalSec % 60; if (m === 0) return `${s}秒`; return `${m}分${s > 0 ? `${s}秒` : ""}`; };