2026年3月14日14:37:06
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user