将 Markdown 编辑器替换为 TipTap WYSIWYG,新增帖子修订记录与 diff 展示;首页支持最新/回复排序与本地缓存;后台可配置编辑时限与锁定帖子;侧边栏整合板块导航并优化 Feed 布局。 Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { useNavigate } from 'react-router-dom';
|
|
import type { Board, ForumStats } from '../api/types';
|
|
|
|
interface Props {
|
|
boardId: number;
|
|
keyword: string;
|
|
boards: Board[];
|
|
stats: ForumStats | null;
|
|
postTotal: number;
|
|
}
|
|
|
|
export default function FeedHeader({ boardId, keyword, boards, stats, postTotal }: Props) {
|
|
const nav = useNavigate();
|
|
const board = boards.find(b => b.id === boardId);
|
|
|
|
const title = keyword
|
|
? `搜索:${keyword}`
|
|
: (boardId && board ? board.name : '全部帖子');
|
|
|
|
const boardHint = boardId && board ? (board.description || '') : '';
|
|
|
|
return (
|
|
<div className={`feed-head${keyword ? ' feed-head--solo' : ''}`}>
|
|
<div className="feed-head__title">
|
|
<h2 title={boardHint || undefined}>{title}</h2>
|
|
{!keyword && stats && (
|
|
<span className="feed-head__meta">
|
|
会员 <strong>{stats.users}</strong>
|
|
<span className="feed-head__dot" aria-hidden>·</span>
|
|
帖子 <strong>{stats.posts}</strong>
|
|
<span className="feed-head__dot" aria-hidden>·</span>
|
|
板块 <strong>{stats.boards}</strong>
|
|
</span>
|
|
)}
|
|
</div>
|
|
{keyword && (
|
|
<button
|
|
type="button"
|
|
className="feed-head__clear"
|
|
onClick={() => nav('/')}
|
|
>
|
|
清除搜索
|
|
</button>
|
|
)}
|
|
{keyword && (
|
|
<span className="feed-toolbar__count">共 {postTotal} 条</span>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|