From d93635c9610733f4528616ea4ff584b036cd3d45 Mon Sep 17 00:00:00 2001 From: freefire Date: Thu, 17 Sep 2026 01:22:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E7=AB=99=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=BC=80=E5=85=B3=EF=BC=8C=E5=B9=B6=E7=BB=9F=E4=B8=80=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E8=A1=A8=E5=8D=95=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关闭评论后前台隐藏评论能力;外观/设置/公告改用 AdminField 与 Stepper。 Co-authored-by: Cursor --- backend/handler/comment.go | 17 +- backend/handler/user.go | 15 + .../admin/announcements/AnnouncementAdmin.tsx | 31 +-- .../app/admin/appearance/AppearanceAdmin.tsx | 234 +++++++++++++++- frontend/app/admin/appearance/page.tsx | 4 +- frontend/app/admin/settings/SettingsAdmin.tsx | 258 ++---------------- frontend/app/globals.css | 153 ++++++++++- frontend/app/layout.tsx | 15 +- frontend/app/login/page.tsx | 4 +- frontend/app/page.tsx | 16 +- frontend/app/post/[id]/page.tsx | 98 +++++-- frontend/app/u/[id]/UserProfileContent.tsx | 10 +- frontend/app/u/[id]/page.tsx | 31 ++- frontend/components/CommentSection.tsx | 66 +---- .../components/CommentsPolicyProvider.tsx | 52 ++++ frontend/components/CommentsUnsupported.tsx | 25 ++ frontend/components/MobilePostBar.tsx | 22 +- frontend/components/PostInteractPanels.tsx | 13 +- frontend/components/PostRow.tsx | 31 ++- frontend/components/admin/AdminField.tsx | 81 ++++++ .../components/admin/AdminSearchField.tsx | 12 +- frontend/components/admin/AdminStepper.tsx | 94 +++++++ frontend/components/admin/index.ts | 2 + frontend/components/home/BoardPanels.tsx | 69 +++-- frontend/components/home/CommunityPanels.tsx | 104 ++++--- frontend/components/home/FeedTabs.tsx | 9 +- frontend/lib/api.ts | 2 +- 27 files changed, 989 insertions(+), 479 deletions(-) create mode 100644 frontend/components/CommentsPolicyProvider.tsx create mode 100644 frontend/components/CommentsUnsupported.tsx create mode 100644 frontend/components/admin/AdminField.tsx create mode 100644 frontend/components/admin/AdminStepper.tsx diff --git a/backend/handler/comment.go b/backend/handler/comment.go index fa8383b..ba2fdbc 100644 --- a/backend/handler/comment.go +++ b/backend/handler/comment.go @@ -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 diff --git a/backend/handler/user.go b/backend/handler/user.go index ed232f7..736cb0b 100644 --- a/backend/handler/user.go +++ b/backend/handler/user.go @@ -151,6 +151,21 @@ func (h *Handlers) UserComments(c *gin.Context) { return } + if allow, err := h.Setting.AllowComments(); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "评论暂时不可用"}) + return + } else if !allow { + page, _ := strconv.Atoi(c.DefaultQuery("page", "1")) + size, _ := strconv.Atoi(c.DefaultQuery("size", "20")) + c.JSON(http.StatusOK, gin.H{ + "comments": []any{}, + "total": 0, + "page": page, + "size": size, + }) + return + } + page, _ := strconv.Atoi(c.DefaultQuery("page", "1")) size, _ := strconv.Atoi(c.DefaultQuery("size", "20")) diff --git a/frontend/app/admin/announcements/AnnouncementAdmin.tsx b/frontend/app/admin/announcements/AnnouncementAdmin.tsx index 2909dbb..9fa380c 100644 --- a/frontend/app/admin/announcements/AnnouncementAdmin.tsx +++ b/frontend/app/admin/announcements/AnnouncementAdmin.tsx @@ -25,6 +25,7 @@ import { toast } from "@/lib/toast"; import ConfirmDialog from "@/components/ConfirmDialog"; import { AdminEmpty, + AdminField, AdminIconButton, AdminPageHeader, AdminSegmented, @@ -155,29 +156,24 @@ export default function AnnouncementAdmin({ {form.id == null ? "新建公告" : "编辑公告"}

- - setForm({ ...form, title: e.target.value })} + onChange={(title) => setForm({ ...form, title })} placeholder="请输入公告标题" />
- - setForm({ ...form, tag: e.target.value })} + onChange={(tag) => setForm({ ...form, tag })} placeholder="公告" />
@@ -213,14 +209,13 @@ export default function AnnouncementAdmin({ />
- -