feat: 更新UI
This commit is contained in:
@@ -128,6 +128,10 @@ export const validateBlogImage = (files: File[]): boolean => {
|
||||
}
|
||||
|
||||
export const formatBlogWordCount = (count: number): string => {
|
||||
if (!count) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (count < 10000) return count.toString()
|
||||
|
||||
const units = ['万', '亿', '兆']
|
||||
@@ -138,8 +142,8 @@ export const formatBlogWordCount = (count: number): string => {
|
||||
unitIndex++
|
||||
}
|
||||
|
||||
// 保留一位小数
|
||||
const formattedNum = Math.round(count * 10) / 10
|
||||
// 保留两位小数,并移除末尾可能的零
|
||||
const formattedNum = count.toFixed(2).replace(/\.?0+$/, '')
|
||||
return `${formattedNum}${units[unitIndex]}`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user