Files
jiang13-forum/frontend/src/components/FeedHeader.tsx
freefire 1d273066b0 升级帖子编辑与 Feed 体验:TipTap 富文本、修订历史、排序与编辑时限。
将 Markdown 编辑器替换为 TipTap WYSIWYG,新增帖子修订记录与 diff 展示;首页支持最新/回复排序与本地缓存;后台可配置编辑时限与锁定帖子;侧边栏整合板块导航并优化 Feed 布局。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 03:05:45 +08:00

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>
);
}