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

@@ -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 不写进 URLlatest / hot 显式带上
if (sort !== 'reply') p.set('sort', sort);
const qs = p.toString();
if (boardId) {