import { Suspense } from "react" import type { JSX } from "react" import { getTranslations } from "next-intl/server" import { requirePermission } from "@/shared/lib/auth-guard" import { Permissions } from "@/shared/types/permissions" import { SectionErrorBoundary } from "@/shared/components/section-error-boundary" import { getNotifications } from "@/modules/notifications/data-access" import { NotificationList } from "@/modules/notifications/components/notification-list" import { MessageListSection } from "@/modules/messaging/components/message-list-section" import { MessageListSkeleton } from "@/modules/messaging/components/message-list-skeleton" import { Card, CardContent, CardHeader } from "@/shared/components/ui/card" import { Skeleton } from "@/shared/components/ui/skeleton" export const dynamic = "force-dynamic" export async function generateMetadata() { const t = await getTranslations("messages") return { title: t("title.list") } } /** * P2-9: 通知列表区块骨架屏(Suspense fallback)。 */ function NotificationListSkeleton(): JSX.Element { return (
{Array.from({ length: 3 }).map((_, i) => ( ))}
) } /** * P2-9: 通知列表区块(Server Component,流式加载)。 */ async function NotificationListSection({ userId }: { userId: string }): Promise { const result = await getNotifications(userId, { page: 1, pageSize: 20 }) return } export default async function MessagesPage(): Promise { const t = await getTranslations("messages") const ctx = await requirePermission(Permissions.MESSAGE_READ) return (

{t("title.list")}

{t("description.list")}

{/* P2-8 + P2-9: 消息列表区块独立 Suspense + ErrorBoundary,局部失败不影响通知区块 */} }> {/* P2-8 + P2-9: 通知列表区块独立 Suspense + ErrorBoundary */} }>
) }