From f5dd9b84b19a0a791d4ab03b877910dc46eac950 Mon Sep 17 00:00:00 2001
From: yangyin <1850366751@qq.com>
Date: 星期四, 31 十月 2024 16:13:03 +0800
Subject: [PATCH] 添加静态常用语的弹窗

---
 src/utils/util.ts |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/utils/util.ts b/src/utils/util.ts
index 83c85ba..77895cf 100644
--- a/src/utils/util.ts
+++ b/src/utils/util.ts
@@ -620,7 +620,9 @@
 
 export const toPercent = (num: number, havePercentSymbol = true, decimalPlaces = 1, defaultValue = '-') => {
 	if (num == null) return `${defaultValue} %`;
-	let percent = Number(num * 100).toFixed(decimalPlaces);
+	const factor = Math.pow(10, decimalPlaces);
+
+	let percent = Math.round(Number(num) * 100 * factor) / factor + '';
 	if (havePercentSymbol) {
 		percent += '%';
 	}

--
Gitblit v1.9.3