feat: 全站评论开关,并统一后台表单控件
关闭评论后前台隐藏评论能力;外观/设置/公告改用 AdminField 与 Stepper。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -36,6 +36,21 @@ func (h *Handlers) PostComments(c *gin.Context) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "帖子不存在"})
|
||||
return
|
||||
}
|
||||
|
||||
if allow, err := h.Setting.AllowComments(); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "评论暂时不可用"})
|
||||
return
|
||||
} else if !allow {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"comments": []any{},
|
||||
"total": 0,
|
||||
"total_comments": 0,
|
||||
"page": page,
|
||||
"size": size,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
boardID, _ := h.Post.GetBoardID(uint(id))
|
||||
|
||||
comments, floors, totalComments, err := h.Comment.ListFloorPaged(uint(id), boardID, viewerID, actor, page, size)
|
||||
@@ -70,7 +85,7 @@ func (h *Handlers) CreateComment(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "评论暂时不可用"})
|
||||
return
|
||||
} else if !allow {
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "站点已关闭评论"})
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "本站不支持评论"})
|
||||
return
|
||||
}
|
||||
var req CreateCommentRequest
|
||||
|
||||
Reference in New Issue
Block a user