chore: 清理 SSR 改造后的历史遗留死代码与误提交产物
- 删除图形验证码整条死链:service/captcha.go、APICaptcha、 GET /api/captcha、CaptchaService 装配、ErrCaptchaInvalid 及前端 api.captcha()(注册/登录已改用邮箱验证码,Verify 无任何调用方) - 删除 GET /api/posts/hot 死路由:APIHotPosts + PostService.HotPosts (热门排序走 /api/posts?sort=hot) - 删除 GET /api/posts/:id/revisions/:revId 死路由: APIPostRevisionDetail + PostService.GetRevision + ErrRevisionNotFound 及前端 api.postRevision()(历史面板仅用列表接口) - 停止跟踪误提交的 27.5MB Linux 二进制 jiang13-linux-amd64 与 .vite 依赖缓存;.gitignore 补充对应规则并移除已失效的 embed_static 条目
This commit is contained in:
@@ -1127,16 +1127,6 @@ func (h *Handlers) APIPostComments(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"comments": comments, "total": len(comments)})
|
||||
}
|
||||
|
||||
// APIHotPosts 近期活跃讨论(近 7 日有回复)
|
||||
func (h *Handlers) APIHotPosts(c *gin.Context) {
|
||||
items, err := h.Post.HotPosts(10)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"posts": items})
|
||||
}
|
||||
|
||||
// APITags 标签云(按使用次数聚合)
|
||||
func (h *Handlers) APITags(c *gin.Context) {
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "40"))
|
||||
@@ -1211,29 +1201,6 @@ func (h *Handlers) APIPostRevisions(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"revisions": revs})
|
||||
}
|
||||
|
||||
// APIPostRevisionDetail 查看某个历史版本
|
||||
func (h *Handlers) APIPostRevisionDetail(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
revID, _ := strconv.ParseUint(c.Param("revId"), 10, 64)
|
||||
post, err := h.Post.FindByID(uint(id))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "帖子不存在"})
|
||||
return
|
||||
}
|
||||
uid := h.currentUserID(c)
|
||||
isAdmin := h.isAdmin(c)
|
||||
if !isAdmin && post.UserID != uid {
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "无权查看编辑历史"})
|
||||
return
|
||||
}
|
||||
rev, err := h.Post.GetRevision(uint(id), uint(revID))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"revision": rev})
|
||||
}
|
||||
|
||||
func isClientLimitError(err error) bool {
|
||||
return errors.Is(err, service.ErrSearchKeywordTooShort) ||
|
||||
errors.Is(err, service.ErrSearchKeywordTooLong)
|
||||
|
||||
Reference in New Issue
Block a user