import { useNavigate } from 'react-router-dom'; import { navigateFeed } from '../utils/feedCache'; interface Props { keyword: string; tag?: string; author?: string; postTotal: number; /** 搜索页用 h1;首页/板块页中间栏不再展示标题 */ titleAs?: 'h1' | 'h2'; } export default function FeedHeader({ keyword, tag = '', author = '', postTotal, titleAs = 'h1', }: Props) { const nav = useNavigate(); const isSearch = !!(keyword || author); const isTag = !!tag; const filtered = isSearch || isTag; const TitleTag = titleAs; let title = ''; if (isTag) title = `标签:${tag}`; else if (isSearch) title = '搜索结果'; // 无标题且无操作时不占位 if (!filtered) return null; return (
{title ? {title} : null} 共 {postTotal} 条
{isTag && ( )}
); }