fix: 书库阅读页/帖子详情页/SiteDocMasthead/TOC 等前端细节修复

This commit is contained in:
2026-10-02 01:47:14 +08:00
parent 7912b67ddc
commit 11f2131e4b
4 changed files with 18 additions and 9 deletions

View File

@@ -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} 小时`;
}