- Add error.tsx and loading.tsx boundaries for admin, parent, student, teacher routes - Add admin announcements edit, audit-logs overview, curriculum-map, invitation-codes, permissions, questions, roles routes - Add admin elective detail and components, files, course-plans, users, scheduling boundaries - Add messages group-compose route - Add parent course-plans, elective, grades report-card, practice routes - Add student course-plans, elective detail, error-book dialogs, grades report-card, learning study-path, leave, schedule boundaries - Add teacher attendance report, classes boundaries, course-plans boundaries, elective, exams analytics/edit-rich/all/create/new, grades report-card, homework boundaries, leave, lesson-plans calendar - Add auth loading, onboarding loading, api cron
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { notFound } from "next/navigation"
|
|
import type { Metadata } from "next"
|
|
import type { JSX } from "react"
|
|
import { Suspense } 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 { getMessageDetailPageData } from "@/modules/messaging/data-access"
|
|
import { MessageDetail } from "@/modules/messaging/components/message-detail"
|
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
const t = await getTranslations("messages")
|
|
return { title: t("title.detail") }
|
|
}
|
|
|
|
/**
|
|
* P2-9: 消息详情骨架屏。
|
|
*/
|
|
function MessageDetailSkeleton(): JSX.Element {
|
|
return (
|
|
<div className="space-y-6" role="status" aria-label="Loading message">
|
|
<Skeleton className="h-8 w-3/4" />
|
|
<Skeleton className="h-4 w-1/2" />
|
|
<Skeleton className="h-32 w-full" />
|
|
<div className="space-y-2">
|
|
<Skeleton className="h-4 w-full" />
|
|
<Skeleton className="h-4 w-5/6" />
|
|
<Skeleton className="h-4 w-4/5" />
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default async function MessageDetailPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ id: string }>
|
|
}): Promise<JSX.Element> {
|
|
const ctx = await requirePermission(Permissions.MESSAGE_READ)
|
|
const { id } = await params
|
|
|
|
const message = await getMessageDetailPageData(id, ctx.userId)
|
|
if (!message) notFound()
|
|
|
|
return (
|
|
<div className="flex h-full flex-col p-8">
|
|
{/* P2-8 + P2-9: 详情区块 ErrorBoundary 包裹 */}
|
|
<SectionErrorBoundary namespace="messages">
|
|
<Suspense fallback={<MessageDetailSkeleton />}>
|
|
<MessageDetail message={message} currentUserId={ctx.userId} />
|
|
</Suspense>
|
|
</SectionErrorBoundary>
|
|
</div>
|
|
)
|
|
}
|