From 49b797e7dc5e5c3d0f784578e2f39869e9e7a0c2 Mon Sep 17 00:00:00 2001
From: admin <572701190@qq.com>
Date: Sun, 3 May 2026 02:38:37 +0800
Subject: [PATCH] fix slow zip progress display rounding
---
WebSite/src/App.tsx | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/WebSite/src/App.tsx b/WebSite/src/App.tsx
index 422ca3d..b7d3ca2 100644
--- a/WebSite/src/App.tsx
+++ b/WebSite/src/App.tsx
@@ -99,11 +99,16 @@ const API_BASE = typeof window === 'undefined'
function progressFromJob(job: BackendJob, fallback = 0) {
if (job.status === 'completed') return 100;
if (typeof job.progress === 'number') {
- return Math.max(0, Math.min(100, Math.round(job.progress)));
+ return Math.max(0, Math.min(100, job.progress));
}
return Math.max(0, Math.min(95, fallback));
}
+function formatProgress(value: number) {
+ const bounded = Math.max(0, Math.min(100, value));
+ return Number.isInteger(bounded) ? `${bounded}` : bounded.toFixed(1);
+}
+
function readStoredDeformationJob(): StoredDeformationJob | null {
if (typeof window === 'undefined') return null;
try {
@@ -948,7 +953,7 @@ export default function App() {
>
{zipJobs.all?.status === 'running'
- ? `四状态 ZIP 打包中 ${progressFromJob(zipJobs.all, 0)}%`
+ ? `四状态 ZIP 打包中 ${formatProgress(progressFromJob(zipJobs.all, 0))}%`
: '下载四状态 ZIP'}
)}
@@ -1057,7 +1062,7 @@ export default function App() {
>
{zipJob?.status === 'running'
- ? `打包中 ${progressFromJob(zipJob, 0)}%`
+ ? `打包中 ${formatProgress(progressFromJob(zipJob, 0))}%`
: '下载本状态 DICOM ZIP'}
)}