feat(app): add error/loading boundaries and update dashboard routes
- Add error.tsx and loading.tsx boundaries for admin, parent, student, teacher routes - Add dashboard-error-fallback and dashboard-loading-skeleton components - Add student/learning page, parent/leave routes, teacher textbook components - Update existing app routes across auth, dashboard, and API endpoints - Update proxy middleware and next-auth type declarations
This commit is contained in:
@@ -3,8 +3,9 @@ import { getTranslations } from "next-intl/server"
|
||||
|
||||
import { BookOpen } from "lucide-react"
|
||||
|
||||
import { getTextbookById, getChaptersByTextbookId, getKnowledgePointsByTextbookId } from "@/modules/textbooks/data-access"
|
||||
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
||||
import { TextbookReader } from "@/modules/textbooks/components/textbook-reader"
|
||||
import { getSubjectLabelKey, getGradeLabelKey } from "@/modules/textbooks/constants"
|
||||
import { Badge } from "@/shared/components/ui/badge"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
||||
@@ -23,10 +24,9 @@ export default async function StudentTextbookDetailPage({
|
||||
|
||||
const { id } = await params
|
||||
|
||||
const [textbook, chapters, knowledgePoints] = await Promise.all([
|
||||
const [textbook, chapters] = await Promise.all([
|
||||
getTextbookById(id),
|
||||
getChaptersByTextbookId(id),
|
||||
getKnowledgePointsByTextbookId(id)
|
||||
])
|
||||
|
||||
if (!textbook) notFound()
|
||||
@@ -45,9 +45,9 @@ export default async function StudentTextbookDetailPage({
|
||||
<h1 className="text-lg font-bold tracking-tight truncate">{textbook.title}</h1>
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<span className="hidden sm:inline-block w-px h-4 bg-border" aria-hidden="true" />
|
||||
<Badge variant="outline" className="font-normal text-xs">{textbook.subject}</Badge>
|
||||
<Badge variant="outline" className="font-normal text-xs">{t(`subject.${getSubjectLabelKey(textbook.subject)}`)}</Badge>
|
||||
{textbook.grade && (
|
||||
<Badge variant="secondary" className="font-normal text-xs">{textbook.grade}</Badge>
|
||||
<Badge variant="secondary" className="font-normal text-xs">{t(`grade.${getGradeLabelKey(textbook.grade)}`)}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -66,7 +66,7 @@ export default async function StudentTextbookDetailPage({
|
||||
) : (
|
||||
<div className="h-full min-h-0 max-w-[1600px] mx-auto w-full">
|
||||
{/* 学生端不传 renderQuestionCreator,无题目创建权限 */}
|
||||
<TextbookReader chapters={chapters} knowledgePoints={knowledgePoints} />
|
||||
<TextbookReader key={id} chapters={chapters} textbookId={id} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -7,16 +7,10 @@ import { TextbookFilters } from "@/modules/textbooks/components/textbook-filters
|
||||
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
||||
import { getGradeNameById } from "@/modules/school/data-access"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
type SearchParams = { [key: string]: string | string[] | undefined }
|
||||
|
||||
const getParam = (params: SearchParams, key: string): string | undefined => {
|
||||
const v = params[key]
|
||||
return Array.isArray(v) ? v[0] : v
|
||||
}
|
||||
|
||||
export default async function StudentTextbooksPage({
|
||||
searchParams,
|
||||
}: {
|
||||
|
||||
Reference in New Issue
Block a user