2026年3月14日14:37:06

This commit is contained in:
Alex-larget
2026-03-14 14:37:17 +08:00
parent db4b4b8b87
commit 8778a42429
452 changed files with 92375 additions and 1014 deletions

View File

@@ -146,13 +146,14 @@ func checkUserChapterAccess(db *gorm.DB, userID, chapterID string, isPremium boo
return cnt > 0
}
// previewContent 取内容的前 20%最多前 200 个字符),并追加省略提示
// previewContent 取内容的前 50%不少于 100 个字符),并追加省略提示
func previewContent(content string) string {
total := utf8.RuneCountInString(content)
if total == 0 {
return ""
}
limit := total / 5
// 截取前 50% 的内容,保证有足够的预览长度
limit := total / 2
if limit < 100 {
limit = 100
}