From 263547ebb7b388ad110cedc2a1962ff564e97470 Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Thu, 12 Dec 2024 19:21:08 +0800 Subject: [PATCH] refactor: Simplify average calculations in Detail component - Streamlined the calculation of average RPM and average TPM by removing unnecessary function calls and directly applying the `toFixed(3)` method within the JSX. - Improved code readability and maintainability by reducing the number of lines and enhancing clarity in the calculation logic. --- web/src/pages/Detail/index.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/web/src/pages/Detail/index.js b/web/src/pages/Detail/index.js index e202f086..66c49c77 100644 --- a/web/src/pages/Detail/index.js +++ b/web/src/pages/Detail/index.js @@ -490,20 +490,16 @@ const Detail = (props) => { - {renderNumber( - times / - ((Date.parse(end_timestamp) - - Date.parse(start_timestamp)) / - 60000), - ).toFixed(3)} + {(times / + ((Date.parse(end_timestamp) - + Date.parse(start_timestamp)) / + 60000)).toFixed(3)} - {renderNumber( - consumeTokens / - ((Date.parse(end_timestamp) - - Date.parse(start_timestamp)) / - 60000), - ).toFixed(3)} + {(consumeTokens / + ((Date.parse(end_timestamp) - + Date.parse(start_timestamp)) / + 60000)).toFixed(3)}