From ba60a9b1c48c9e9d7188ccd969d75b7d53915741 Mon Sep 17 00:00:00 2001 From: freefire Date: Tue, 1 Sep 2026 01:59:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=20Feed=20=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=B8=BA=E6=96=B0=E8=AF=84=E8=AE=BA/=E6=96=B0?= =?UTF-8?q?=E5=B8=96=E5=AD=90/=E6=8E=A8=E8=8D=90=E5=B8=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 默认按新评论;推荐排序优先 featured,并将用户可见「精华」文案改为「推荐」。 Co-authored-by: Cursor --- frontend/src/components/FeaturedIcon.tsx | 8 ++++---- frontend/src/components/FeedSortBar.tsx | 18 ++++++++++-------- frontend/src/components/PostListItem.tsx | 4 ++-- frontend/src/components/PostManageMenu.tsx | 2 +- frontend/src/components/VirtualPostList.tsx | 2 +- frontend/src/layouts/MainLayout.tsx | 2 +- frontend/src/pages/HomePage.tsx | 2 +- .../src/pages/admin/AdminDashboardPage.tsx | 2 +- frontend/src/pages/admin/AdminPostsPage.tsx | 6 +++--- frontend/src/styles/global.css | 18 +++++++++--------- handler/api.go | 8 ++++---- model/models.go | 2 +- service/post.go | 10 ++++++---- 13 files changed, 44 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/FeaturedIcon.tsx b/frontend/src/components/FeaturedIcon.tsx index 63e5e9f..61d9f86 100644 --- a/frontend/src/components/FeaturedIcon.tsx +++ b/frontend/src/components/FeaturedIcon.tsx @@ -1,4 +1,4 @@ -import { Sparkles } from 'lucide-react'; +import { BadgeCheck } from 'lucide-react'; import { cn } from '@/lib/utils'; interface Props { @@ -6,13 +6,13 @@ interface Props { size?: number; } -/** 精华帖标识 */ +/** 推荐帖标识 */ export default function FeaturedIcon({ className, size = 16 }: Props) { return ( - ); diff --git a/frontend/src/components/FeedSortBar.tsx b/frontend/src/components/FeedSortBar.tsx index d7e7e02..1b8abe8 100644 --- a/frontend/src/components/FeedSortBar.tsx +++ b/frontend/src/components/FeedSortBar.tsx @@ -1,7 +1,7 @@ import { useRef } from 'react'; import { boardPath, type PermalinkOpts } from '../utils/permalink'; import { getCachedForumLimits } from '../hooks/useForumLimits'; -import { Clock, MessageCircle, Flame } from 'lucide-react'; +import { Clock, MessageCircle, BadgeCheck } from 'lucide-react'; import { cn } from '@/lib/utils'; import { moveTabIndex } from '../hooks/useOverlayA11y'; @@ -13,9 +13,9 @@ const SORT_OPTIONS: { hint: string; icon: typeof Clock; }[] = [ - { key: 'latest', label: '最新发帖', hint: '按发布时间', icon: Clock }, - { key: 'reply', label: '最新回复', hint: '最近有人回复', icon: MessageCircle }, - { key: 'hot', label: '热门讨论', hint: '按互动热度', icon: Flame }, + { key: 'reply', label: '新评论', hint: '最近有人评论', icon: MessageCircle }, + { key: 'latest', label: '新帖子', hint: '按发帖时间', icon: Clock }, + { key: 'hot', label: '推荐帖', hint: '站内推荐', icon: BadgeCheck }, ]; interface Props { @@ -24,14 +24,15 @@ interface Props { postTotal?: number; } +/** 解析 URL sort;缺省为新评论(reply) */ export function parseFeedSort(raw: string | null): FeedSort { - if (raw === 'reply' || raw === 'hot') return raw; - return 'latest'; + if (raw === 'latest' || raw === 'hot') return raw; + return 'reply'; } export function buildHomeUrl( boardId: number, - sort: FeedSort = 'latest', + sort: FeedSort = 'reply', opts?: { keyword?: string; tag?: string; author?: string; titleOnly?: boolean; permalink?: PermalinkOpts }, ) { const p = new URLSearchParams(); @@ -47,7 +48,8 @@ export function buildHomeUrl( } else if (author) { p.set('author', author); } - if (sort !== 'latest') p.set('sort', sort); + // 默认 reply 不写进 URL;latest / hot 显式带上 + if (sort !== 'reply') p.set('sort', sort); const qs = p.toString(); if (boardId) { diff --git a/frontend/src/components/PostListItem.tsx b/frontend/src/components/PostListItem.tsx index d75a087..6fed018 100644 --- a/frontend/src/components/PostListItem.tsx +++ b/frontend/src/components/PostListItem.tsx @@ -70,9 +70,9 @@ function PostListItem({ post, sort = 'latest', boardId = 0, onSelect }: Props) { 板块置顶 )} {post.featured && ( - + - 精华 + 推荐 )} {post.status === 'pending' && ( diff --git a/frontend/src/components/PostManageMenu.tsx b/frontend/src/components/PostManageMenu.tsx index 46e2e16..f058729 100644 --- a/frontend/src/components/PostManageMenu.tsx +++ b/frontend/src/components/PostManageMenu.tsx @@ -147,7 +147,7 @@ export default function PostManageMenu({ 展示 - {post.featured ? '取消精华' : '设为精华'} + {post.featured ? '取消推荐' : '设为推荐'} diff --git a/frontend/src/components/VirtualPostList.tsx b/frontend/src/components/VirtualPostList.tsx index b607107..6d8b9d6 100644 --- a/frontend/src/components/VirtualPostList.tsx +++ b/frontend/src/components/VirtualPostList.tsx @@ -56,7 +56,7 @@ function getMobileFeedScrollEl(): HTMLElement | null { export default function VirtualPostList({ posts, - sort = 'latest', + sort = 'reply', loading, hasMore, showPagination, diff --git a/frontend/src/layouts/MainLayout.tsx b/frontend/src/layouts/MainLayout.tsx index 76c15c7..ac39070 100644 --- a/frontend/src/layouts/MainLayout.tsx +++ b/frontend/src/layouts/MainLayout.tsx @@ -216,7 +216,7 @@ export default function MainLayout() { }; }, [refreshUnreadMessages]); - // 标签云:进页/离开发帖页时拉取;不跟 posts-refresh 联动(置顶/精华等不改标签) + // 标签云:进页/离开发帖页时拉取;不跟 posts-refresh 联动(置顶/推荐等不改标签) useEffect(() => { if (isCompose || !showTagCloud) return; let cancelled = false; diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index b9eb43c..8f24fda 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -230,7 +230,7 @@ export default function HomePage() { tag: tag || '', author: tag ? '' : author, title_only: !tag && titleOnly ? '1' : '', - sort: sort === 'latest' ? '' : sort, + sort, }); const batch = Array.isArray(data.posts) ? data.posts : []; const total = data.total ?? 0; diff --git a/frontend/src/pages/admin/AdminDashboardPage.tsx b/frontend/src/pages/admin/AdminDashboardPage.tsx index 4e4f594..10f929f 100644 --- a/frontend/src/pages/admin/AdminDashboardPage.tsx +++ b/frontend/src/pages/admin/AdminDashboardPage.tsx @@ -245,7 +245,7 @@ export default function AdminDashboardPage() { ) : '—'} - {p.featured ? 精华 : null} + {p.featured ? 推荐 : null} {p.pinned ? 全局置顶 : null} {p.board_pinned ? 板块置顶 : null} {!p.featured && !p.pinned && !p.board_pinned ? '—' : null} diff --git a/frontend/src/pages/admin/AdminPostsPage.tsx b/frontend/src/pages/admin/AdminPostsPage.tsx index b785130..a0e1a6d 100644 --- a/frontend/src/pages/admin/AdminPostsPage.tsx +++ b/frontend/src/pages/admin/AdminPostsPage.tsx @@ -218,7 +218,7 @@ export default function AdminPostsPage() { ? '回收站中的帖子可恢复或永久删除;永久删除后不可撤销' : tab === 'pending' ? '审核普通用户提交的帖子;通过后公开,拒绝后仅作者可见并私信通知' - : '精华、全局置顶、板块置顶、锁定编辑/讨论、删除(移入回收站);支持按标题、标签或正文搜索'} + : '推荐、全局置顶、板块置顶、锁定编辑/讨论、删除(移入回收站);支持按标题、标签或正文搜索'}

@@ -337,7 +337,7 @@ export default function AdminPostsPage() { 作者 标签 评论 - 精华 + 推荐 全局置顶 板块置顶 编辑锁 @@ -396,7 +396,7 @@ export default function AdminPostsPage() { )}