整理router

This commit is contained in:
2026-09-02 17:56:36 +08:00
parent 2bcfa1da93
commit 533f31e868
9 changed files with 47 additions and 59 deletions
+9 -1
View File
@@ -129,6 +129,15 @@ func IndexView(c *gin.Context) {
db.Order("is_top DESC, published_at DESC, created_at DESC").
Offset(offset).Limit(pageSize).Find(&posts)
// 如果摘要为空,则从内容中提取摘要
for i := range posts {
if posts[i].Summary == "" && posts[i].Content != "" && len(posts[i].Content) > 120 {
posts[i].Summary = posts[i].Content[:120]
} else {
posts[i].Summary = posts[i].Content
}
}
totalPages := int(math.Ceil(float64(total) / float64(pageSize)))
categories, tags, postCount, categoryCount, tagCount := loadSidebarData()
siteName, siteDesc := loadSiteInfo(cfg)
@@ -397,7 +406,6 @@ func SubmitComment(c *gin.Context) {
return
}
// 检查文章是否存在
// 检查文章是否存在
var post models.Post
if err := database.DB.First(&post, req.PostID).Error; err != nil {