From 826fa1226ae8e99748439a42d8973639b27bb4da Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Thu, 14 May 2026 21:50:31 +0800 Subject: [PATCH] feat: enhance MePage and add layout improvements Add activity stats display to MePage and include additional layout enhancements for consistent page structure. --- src/app/layout.tsx | 22 ++++++++++++++++++++++ src/app/me/MePage.tsx | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index d1e3bf1..51c761a 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,7 +1,9 @@ import { useEffect, useState, useMemo, useRef } from "react"; import { Outlet } from "react-router-dom"; +import { useQueryClient } from "@tanstack/react-query"; import { useCurrentUserQuery } from "@/hooks/useAuth"; import { useProjectsQuery } from "@/hooks/useProjectsQuery"; +import { issueSummary } from "@/client/api"; import { SettingsModalContext } from "@/components/settings/SettingsModalContext"; import { SettingsModal } from "@/components/settings/SettingsModal"; import { SettingsDataCacheProvider } from "@/components/settings/SettingsDataCache"; @@ -18,6 +20,7 @@ const WS_CONFIG = { export function RootLayout() { const { data: user } = useCurrentUserQuery(); useProjectsQuery(); // Keep query active for caching + const queryClient = useQueryClient(); const wsClientRef = useRef(null); const [showSettingsModal, setShowSettingsModal] = useState(false); @@ -68,6 +71,25 @@ export function RootLayout() { }; }, [user]); + // Prefetch common data for faster navigation + useEffect(() => { + if (!user) return; + // Prefetch issue summaries for each project (cached by React Query) + const projects = queryClient.getQueryData(["projects"]); + if (Array.isArray(projects)) { + for (const project of projects.slice(0, 5)) { + const name = typeof project === "string" ? project : (project as { name?: string }).name; + if (name) { + queryClient.prefetchQuery({ + queryKey: ["issueSummary", name], + queryFn: () => issueSummary(name).then(r => r.data?.data ?? { total: 0, open: 0, closed: 0 }), + staleTime: 5 * 60 * 1000, + }); + } + } + } + }, [user, queryClient]); + return ( diff --git a/src/app/me/MePage.tsx b/src/app/me/MePage.tsx index 6cc3bf8..cee300c 100644 --- a/src/app/me/MePage.tsx +++ b/src/app/me/MePage.tsx @@ -19,6 +19,7 @@ import { UserCardList } from "./components/UserCardList"; import { FollowerCardList } from "./components/FollowerCardList"; import { RepoList } from "./components/RepoList"; import { ProjectList } from "./components/ProjectList"; +import { NotificationList } from "./components/NotificationList"; import { Loader2 } from "lucide-react"; import { useCurrentUserQuery } from "@/hooks/useAuth"; @@ -43,6 +44,7 @@ export function MePage() { else if (path.includes("/stars")) activeSection = "stars"; else if (path.includes("/following")) activeSection = "following"; else if (path.includes("/followers")) activeSection = "followers"; + else if (path.includes("/notify")) activeSection = "notify"; // Conditional fetching for specific sections const { data: activityData, isLoading: isActivityLoading } = useUserActivityQuery(username, 1, 20); @@ -123,6 +125,12 @@ export function MePage() { ) : ( ); + case "notify": + return ( +
+ +
+ ); default: return (