Files
jiang13-forum/frontend/src/components/FeedHeader.tsx
freefire 012cac23de feat: 去掉 Feed 顶栏统计并强化开源码桶
按帖子列表风格展示码桶,补齐语言/Star/Fork 与论坛作者关联回填,避免未绑定仓库与空列表。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-28 03:58:04 +08:00

52 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 (
<div className="feed-head feed-head--solo">
<div className="feed-head__title">
{title ? <TitleTag>{title}</TitleTag> : null}
<span className="feed-head__meta feed-head__meta--count"> {postTotal} </span>
</div>
{isTag && (
<button
type="button"
className="feed-head__clear"
onClick={() => navigateFeed(nav, '/')}
>
</button>
)}
</div>
);
}