feat(app): add error/loading boundaries across all dashboard routes and new routes

- 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
This commit is contained in:
SpecialX
2026-07-03 10:26:25 +08:00
parent e9a5264fe7
commit 21142f9b99
280 changed files with 7137 additions and 1855 deletions

View File

@@ -1,9 +1,11 @@
import type { JSX } from "react"
import Link from "next/link"
import { PlusCircle, BarChart3, ClipboardList } from "lucide-react"
import { getTranslations } from "next-intl/server"
import { Button } from "@/shared/components/ui/button"
import { EmptyState } from "@/shared/components/ui/empty-state"
import { ListPagination, computePagination } from "@/shared/components/ui/list-pagination"
import { WidgetBoundary } from "@/shared/components/widget-boundary"
import { requirePermission } from "@/shared/lib/auth-guard"
import { Permissions } from "@/shared/types/permissions"
import { getParam, type SearchParams } from "@/shared/lib/search-params"
@@ -13,21 +15,11 @@ import { getSubjectOptions } from "@/modules/school/data-access"
import { GradeQueryFilters } from "@/modules/grades/components/grade-query-filters"
import { GradeRecordList } from "@/modules/grades/components/grade-record-list"
import { ExportButton } from "@/modules/grades/components/export-button"
import type { GradeRecordType, GradeRecordSemester } from "@/modules/grades/types"
import { ExcelImportDialog } from "@/modules/grades/components/excel-import-dialog"
import { isGradeType, isSemester } from "@/modules/grades/lib/type-guards"
export const dynamic = "force-dynamic"
const VALID_GRADE_TYPES: ReadonlySet<string> = new Set(["exam", "quiz", "homework", "other"])
const VALID_SEMESTERS: ReadonlySet<string> = new Set(["1", "2"])
function parseGradeType(v?: string): GradeRecordType | undefined {
return v && VALID_GRADE_TYPES.has(v) ? (v as GradeRecordType) : undefined
}
function parseSemester(v?: string): GradeRecordSemester | undefined {
return v && VALID_SEMESTERS.has(v) ? (v as GradeRecordSemester) : undefined
}
const PAGE_SIZE = 20
export default async function TeacherGradesPage({
@@ -37,6 +29,7 @@ export default async function TeacherGradesPage({
}): Promise<JSX.Element> {
const sp = await searchParams
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
const t = await getTranslations("grades")
const classId = getParam(sp, "classId")
const subjectId = getParam(sp, "subjectId")
@@ -55,8 +48,8 @@ export default async function TeacherGradesPage({
currentUserId: ctx.userId,
classId: classId && classId !== "all" ? classId : undefined,
subjectId: subjectId && subjectId !== "all" ? subjectId : undefined,
type: type && type !== "all" ? parseGradeType(type) : undefined,
semester: semester && semester !== "all" ? parseSemester(semester) : undefined,
type: type && type !== "all" ? isGradeType(type) ? type : undefined : undefined,
semester: semester && semester !== "all" ? isSemester(semester) ? semester : undefined : undefined,
limit: PAGE_SIZE,
offset,
}),
@@ -76,20 +69,20 @@ export default async function TeacherGradesPage({
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
<div className="flex items-center justify-between space-y-2">
<div>
<h1 className="text-2xl font-bold tracking-tight"></h1>
<p className="text-muted-foreground"></p>
<h1 className="text-2xl font-bold tracking-tight">{t("title.list")}</h1>
<p className="text-muted-foreground">{t("page.list.description")}</p>
</div>
<div className="flex items-center gap-2">
<Button asChild variant="outline">
<Link href="/teacher/grades/stats">
<BarChart3 className="mr-2 h-4 w-4" aria-hidden="true" />
{t("page.list.stats")}
</Link>
</Button>
<Button asChild variant="outline">
<Link href="/teacher/grades/entry">
<ClipboardList className="mr-2 h-4 w-4" aria-hidden="true" />
{t("page.list.batchEntry")}
</Link>
</Button>
<ExportButton
@@ -97,10 +90,15 @@ export default async function TeacherGradesPage({
subjectId={subjectId && subjectId !== "all" ? subjectId : undefined}
variant="outline"
/>
<ExcelImportDialog
classId={classId && classId !== "all" ? classId : (classes[0]?.id ?? "")}
classes={classes.map((c) => ({ id: c.id, name: c.name }))}
subjects={allSubjects.map((s) => ({ id: s.id, name: s.name ?? "Unknown" }))}
/>
<Button asChild>
<Link href="/teacher/grades/entry">
<PlusCircle className="mr-2 h-4 w-4" aria-hidden="true" />
{t("page.list.enterGrades")}
</Link>
</Button>
</div>
@@ -110,17 +108,20 @@ export default async function TeacherGradesPage({
{total === 0 && !hasFilters ? (
<EmptyState
title="暂无成绩记录"
description="开始为您的班级录入成绩。"
title={t("page.list.emptyTitle")}
description={t("page.list.emptyDescription")}
icon={ClipboardList}
action={{
label: "录入成绩",
label: t("page.list.emptyActionLabel"),
href: "/teacher/grades/entry",
}}
/>
) : (
<div className="space-y-4">
<GradeRecordList records={pagedRecords} />
{/* P1-9: 用 WidgetBoundary 包裹独立数据区块,隔离故障域 */}
<WidgetBoundary title={t("title.list")}>
<GradeRecordList records={pagedRecords} />
</WidgetBoundary>
{total > 0 ? (
<ListPagination
page={currentPage}
@@ -129,7 +130,7 @@ export default async function TeacherGradesPage({
totalPages={totalPages}
basePath="/teacher/grades"
searchParams={sp}
itemLabel="条记录"
itemLabel={t("page.list.recordUnit")}
/>
) : null}
</div>