From 012cac23de13453600bd8977abecf42649419daa Mon Sep 17 00:00:00 2001 From: freefire Date: Fri, 28 Aug 2026 03:58:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8E=BB=E6=8E=89=20Feed=20=E9=A1=B6?= =?UTF-8?q?=E6=A0=8F=E7=BB=9F=E8=AE=A1=E5=B9=B6=E5=BC=BA=E5=8C=96=E5=BC=80?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E6=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按帖子列表风格展示码桶,补齐语言/Star/Fork 与论坛作者关联回填,避免未绑定仓库与空列表。 Co-authored-by: Cursor --- frontend/src/api/client.ts | 3 +- frontend/src/api/types.ts | 13 + frontend/src/components/FeedHeader.tsx | 49 +--- frontend/src/components/FeedPageSkeleton.tsx | 11 +- frontend/src/components/ProjectListItem.tsx | 121 +++++++++ frontend/src/pages/HomePage.tsx | 3 - frontend/src/pages/ProjectsPage.tsx | 97 +++---- frontend/src/styles/global.css | 77 +++--- handler/api.go | 4 +- model/gitea.go | 29 ++- service/gitea.go | 251 +++++++++++++++++-- 11 files changed, 486 insertions(+), 172 deletions(-) create mode 100644 frontend/src/components/ProjectListItem.tsx 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 && (