import { Users, FileText, LayoutGrid } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import type { Board, ForumStats } from '../api/types'; interface Props { boardId: number; keyword: string; tag?: string; boards: Board[]; stats: ForumStats | null; postTotal: number; /** 搜索页用 h1;首页/板块页中间栏不再展示标题 */ titleAs?: 'h1' | 'h2'; } export default function FeedHeader({ boardId, keyword, tag = '', boards, stats, postTotal, titleAs = 'h1' }: Props) { const nav = useNavigate(); const board = boards.find(b => b.id === boardId); const filtered = !!(keyword || tag); const inBoard = !filtered && boardId > 0 && !!board; /** 侧栏已有「全部帖子 / 板块名」,中间栏不再重复;仅搜索/标签保留标题 */ const title = tag ? `标签:${tag}` : (keyword ? `搜索:${keyword}` : ''); const TitleTag = titleAs; return (
{title ? {title} : null} {!filtered && inBoard && (
本板块 {postTotal} {stats && ( 全站 {stats.posts} 帖 · {stats.users} 会员 )}
)} {!filtered && !inBoard && stats && (
会员 {stats.users} 帖子 {stats.posts} 板块 {stats.boards}
)}
{filtered && ( )} {filtered && ( 共 {postTotal} 条 )}
); }