feat:增加AList博客

This commit is contained in:
2025-12-18 10:13:00 +08:00
parent 228109ee81
commit fb404f2bcf
13 changed files with 162 additions and 45 deletions

View File

@@ -18,6 +18,30 @@ export const countWord = (data: string)=> {
return count
}
export const formatNumberUnit = (num: number, fixed = 1) => {
if (typeof num !== 'number') {
num = parseFloat(num);
}
if (isNaN(num)) return '0';
const absNum = Math.abs(num);
let result;
if (absNum >= 100000000) {
// 亿
result = (num / 100000000).toFixed(fixed) + '亿';
} else if (absNum >= 10000) {
// 万
result = (num / 10000).toFixed(fixed) + '万';
} else {
result = num.toFixed(0);
}
// 移除多余的 .0
return result.replace(/\.0+($|亿|万)/, '$1');
}
/**
* 判断是否为移动端
*/