diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index bf54e1a..657a66f 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -29,10 +29,11 @@ export const api = { pages: () => request<{ pages: SitePageSummary[] }>('/api/pages'), page: (slug: string) => request<{ page: SitePage }>(`/api/pages/${encodeURIComponent(slug)}`), boards: () => request<{ boards: Board[] }>('/api/boards'), - projects: (params?: { page?: number; limit?: number }) => { + projects: (params?: { page?: number; limit?: number; q?: string }) => { const q = new URLSearchParams(); if (params?.page) q.set('page', String(params.page)); if (params?.limit) q.set('limit', String(params.limit)); + if (params?.q?.trim()) q.set('q', params.q.trim()); const qs = q.toString(); return request<{ projects: GiteaProject[]; total: number; page: number; total_pages: number }>( `/api/projects${qs ? `?${qs}` : ''}`, diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index 25d0ade..ce01b17 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -470,8 +470,21 @@ export interface GiteaProject { full_name: string; description: string; html_url: string; + language?: string; + stars_count?: number; + forks_count?: number; updated_at_remote?: string | null; forum_user_id?: number; + owner?: { + id: number; + nickname: string; + avatar: string; + role: 'user' | 'admin'; + verified?: boolean; + exp?: number; + level?: number; + badges?: UserBadge[]; + }; synced_at: string; } diff --git a/frontend/src/components/FeedHeader.tsx b/frontend/src/components/FeedHeader.tsx index 429612e..2a04013 100644 --- a/frontend/src/components/FeedHeader.tsx +++ b/frontend/src/components/FeedHeader.tsx @@ -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 ( -
+
{title ? {title} : null} - {!filtered && inBoard && ( -
- - - 本板块 {postTotal} 帖 - - {stats && ( - - 全站 {stats.posts} 帖 · {stats.users} 会员 - - )} -
- )} - {!filtered && !inBoard && stats && ( -
- - - 会员 {stats.users} - - - - 帖子 {stats.posts} - - - - 板块 {stats.boards} - -
- )} - {filtered && ( - 共 {postTotal} 条 - )} + 共 {postTotal} 条
{isTag && (