feat: 调整 Feed 排序为新评论/新帖子/推荐帖

默认按新评论;推荐排序优先 featured,并将用户可见「精华」文案改为「推荐」。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-01 01:59:01 +08:00
parent 132ca5c82c
commit ba60a9b1c4
13 changed files with 44 additions and 40 deletions

View File

@@ -47,7 +47,7 @@ type PostListQuery struct {
Tag string // 精确标签筛选(整枚匹配,不走 keyword LIKE
Author string // 作者用户名或昵称(解析为 UserID
TitleOnly bool // 关键词仅匹配标题
Sort string // latest | reply | hot
Sort string // reply | latest | hothot=推荐优先)
ViewerID uint // 当前查看者(用于 pending 仅作者可见)
ViewerIsAdmin bool
Status string // 管理端筛选pending|published|rejected|all空则按可见性规则
@@ -365,7 +365,8 @@ func (s *PostService) List(q PostListQuery) ([]model.Post, int64, error) {
) DESC`)
db = db.Order("posts.created_at DESC")
case "hot":
db = db.Order("like_count desc, view_count desc")
// 推荐帖人工推荐featured优先再按互动
db = db.Order("featured desc, like_count desc, view_count desc")
default:
db = db.Order("id desc")
}
@@ -375,10 +376,11 @@ func (s *PostService) List(q PostListQuery) ([]model.Post, int64, error) {
func normalizePostSort(sort string) string {
switch sort {
case "reply", "hot":
case "latest", "hot":
return sort
default:
return "latest"
// 含空串 / reply默认新评论
return "reply"
}
}