diff --git a/src/renderer/src/components/ExecutionReportDialog.tsx b/src/renderer/src/components/ExecutionReportDialog.tsx index 4494460..99f77f4 100644 --- a/src/renderer/src/components/ExecutionReportDialog.tsx +++ b/src/renderer/src/components/ExecutionReportDialog.tsx @@ -61,6 +61,7 @@ export const ExecutionReportDialog: React.FC = ({ const showProgress = isExecuting && progress const isProgressing = !!showProgress + // Update timer during progress React.useEffect(() => { if (!showProgress || !startTime) return @@ -71,6 +72,27 @@ export const ExecutionReportDialog: React.FC = ({ return () => clearInterval(interval) }, [showProgress, startTime]) + // Update time when execution completes + React.useEffect(() => { + if (showProgress === false && startTime && isExecuting === false) { + setNow(Date.now()) + } + }, [showProgress, isExecuting, startTime]) + + const elapsedTime = React.useMemo(() => { + if (!startTime) return null + + const elapsedMs = now - startTime + const elapsedSeconds = Math.floor(elapsedMs / 1000) + const minutes = Math.floor(elapsedSeconds / 60) + const seconds = elapsedSeconds % 60 + + return { + totalSeconds: elapsedSeconds, + formatted: minutes > 0 ? `${minutes}分${seconds}秒` : `${seconds}秒` + } + }, [startTime, now]) + const estimatedTime = React.useMemo(() => { if (!showProgress || !startTime || !progress) return null @@ -204,6 +226,15 @@ export const ExecutionReportDialog: React.FC = ({ )} + {elapsedTime && ( +
+
+ 已运行 + {elapsedTime.formatted} +
+
+ )} + {estimatedTime && (
@@ -307,6 +338,29 @@ export const ExecutionReportDialog: React.FC = ({ )}
+ {elapsedTime && ( +
+ + + + + + 总耗时:{elapsedTime.formatted} + +
+ )} + {hasErrors && (
错误详情
diff --git a/src/renderer/src/hooks/useCleaner.ts b/src/renderer/src/hooks/useCleaner.ts index 19e4153..b9c0e10 100644 --- a/src/renderer/src/hooks/useCleaner.ts +++ b/src/renderer/src/hooks/useCleaner.ts @@ -471,10 +471,15 @@ export function useCleaner() { setIsRunning(false) setIsExecuting(false) setProgress(null) - setStartTime(null) + // Note: Don't clear startTime here - it's needed for the execution report dialog + // startTime will be reset when the dialog closes and a new execution starts } } + const resetStartTime = useCallback(() => { + setStartTime(null) + }, []) + const handleExportResults = async () => { if (filteredResults.length === 0) { showWarning('没有数据可导出') @@ -554,6 +559,7 @@ export function useCleaner() { handleAssignManagerOnSelect, progress, startTime, + resetStartTime, handleValidation, handleCheckboxToggle, handleConfirmDeletion, diff --git a/src/renderer/src/pages/CleanerPage.tsx b/src/renderer/src/pages/CleanerPage.tsx index a661806..df8069c 100644 --- a/src/renderer/src/pages/CleanerPage.tsx +++ b/src/renderer/src/pages/CleanerPage.tsx @@ -64,6 +64,7 @@ const CleanerPage: React.FC = () => { handleAssignManagerOnSelect, progress, startTime, + resetStartTime, handleValidation, handleCheckboxToggle, handleConfirmDeletion, @@ -509,7 +510,10 @@ const CleanerPage: React.FC = () => { {/* Execution Report Dialog */} setIsReportDialogOpen(false)} + onClose={() => { + setIsReportDialogOpen(false) + resetStartTime() + }} ordersProcessed={reportData?.ordersProcessed} materialsDeleted={reportData?.materialsDeleted} materialsSkipped={reportData?.materialsSkipped}