refactor: ♻️ 控制台精简重构(访问统计调整和添加项目相关信息)

This commit is contained in:
Ray.Hao
2024-12-08 18:57:52 +08:00
parent e3e0bec22e
commit a7c1c4e14a
20 changed files with 287 additions and 283 deletions

View File

@@ -39,3 +39,20 @@ export function isExternal(path: string) {
const isExternal = /^(https?:|http?:|mailto:|tel:)/.test(path);
return isExternal;
}
/**
* 格式化增长率,保留两位小数 并且去掉末尾的0 取绝对值
*
* @param growthRate
* @returns
*/
export function formatGrowthRate(growthRate: number) {
if (growthRate === 0) {
return "-";
}
const formattedRate = Math.abs(growthRate * 100)
.toFixed(2)
.replace(/\.?0+$/, "");
return formattedRate + "%";
}