feat: 去掉 Feed 顶栏统计并强化开源码桶

按帖子列表风格展示码桶,补齐语言/Star/Fork 与论坛作者关联回填,避免未绑定仓库与空列表。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-28 03:58:04 +08:00
parent d929bf96aa
commit 012cac23de
11 changed files with 486 additions and 172 deletions

View File

@@ -1,80 +1,41 @@
import { Users, FileText, LayoutGrid } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
import type { Board, ForumStats } from '../api/types';
import { navigateFeed } from '../utils/feedCache';
interface Props {
boardId: number;
keyword: string;
tag?: string;
author?: string;
titleOnly?: boolean;
boards: Board[];
stats: ForumStats | null;
postTotal: number;
/** 搜索页用 h1首页/板块页中间栏不再展示标题 */
titleAs?: 'h1' | 'h2';
}
export default function FeedHeader({
boardId,
keyword,
tag = '',
author = '',
boards,
stats,
postTotal,
titleAs = 'h1',
}: Props) {
const nav = useNavigate();
const board = boards.find(b => b.id === boardId);
const isSearch = !!(keyword || author);
const isTag = !!tag;
const filtered = isSearch || isTag;
const inBoard = !filtered && boardId > 0 && !!board;
const TitleTag = titleAs;
let title = '';
if (isTag) title = `标签:${tag}`;
else if (isSearch) title = '搜索结果';
// 无标题且无操作时不占位
if (!filtered) return null;
return (
<div className={`feed-head${filtered ? ' feed-head--solo' : ' feed-head--stats-only'}`}>
<div className="feed-head feed-head--solo">
<div className="feed-head__title">
{title ? <TitleTag>{title}</TitleTag> : null}
{!filtered && inBoard && (
<div className="feed-head__stats">
<span className="feed-stat-chip">
<FileText aria-hidden />
<strong>{postTotal}</strong>
</span>
{stats && (
<span className="feed-stat-chip feed-stat-chip--muted" title="全站统计">
{stats.posts} · {stats.users}
</span>
)}
</div>
)}
{!filtered && !inBoard && stats && (
<div className="feed-head__stats">
<span className="feed-stat-chip">
<Users aria-hidden />
<strong>{stats.users}</strong>
</span>
<span className="feed-stat-chip">
<FileText aria-hidden />
<strong>{stats.posts}</strong>
</span>
<span className="feed-stat-chip">
<LayoutGrid aria-hidden />
<strong>{stats.boards}</strong>
</span>
</div>
)}
{filtered && (
<span className="feed-head__meta feed-head__meta--count"> {postTotal} </span>
)}
<span className="feed-head__meta feed-head__meta--count"> {postTotal} </span>
</div>
{isTag && (
<button