fix: 书库阅读页/帖子详情页/SiteDocMasthead/TOC 等前端细节修复
This commit is contained in:
@@ -167,3 +167,11 @@ export function estimateReadingMinutes(text: string, fallbackLen = 0): number {
|
||||
const len = text.trim().length > 0 ? text.trim().length : fallbackLen;
|
||||
return Math.max(1, Math.ceil(len / 400));
|
||||
}
|
||||
|
||||
/** 阅读时长展示:≥60 分钟换算成「X 小时 Y 分钟」,避免大分钟数需口算 */
|
||||
export function formatReadingDuration(minutes: number): string {
|
||||
if (minutes < 60) return `${minutes} 分钟`;
|
||||
const h = Math.floor(minutes / 60);
|
||||
const m = minutes % 60;
|
||||
return m > 0 ? `${h} 小时 ${m} 分钟` : `${h} 小时`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user