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:
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
@@ -10,14 +11,15 @@ export default function DiagnosticClassError({
|
||||
error: Error & { digest?: string }
|
||||
reset: () => void
|
||||
}) {
|
||||
const t = useTranslations("diagnostic")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title="班级学情诊断加载失败"
|
||||
description="抱歉,加载班级诊断数据时发生了意外错误。请稍后重试。"
|
||||
title={t("error.classLoadFailed")}
|
||||
description={t("error.classLoadFailedDesc")}
|
||||
action={{
|
||||
label: "重试",
|
||||
label: t("error.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import type { JSX } from "react"
|
||||
import { notFound } from "next/navigation"
|
||||
import { Stethoscope } from "lucide-react"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { getClassMasterySummary } from "@/modules/diagnostic/data-access"
|
||||
import { ClassDiagnosticView } from "@/modules/diagnostic/components/class-diagnostic-view"
|
||||
import { WidgetBoundary } from "@/modules/grades/components/widget-boundary"
|
||||
import {
|
||||
DiagnosticServiceProvider,
|
||||
} from "@/modules/diagnostic/services/diagnostic-service-context"
|
||||
import { defaultDiagnosticService } from "@/modules/diagnostic/services/default-diagnostic-service"
|
||||
import { createMonitoredDiagnosticService } from "@/modules/diagnostic/services/monitored-diagnostic-service"
|
||||
import {
|
||||
DiagnosticMonitorProvider,
|
||||
} from "@/modules/diagnostic/services/diagnostic-monitor-context"
|
||||
import { noopDiagnosticMonitor } from "@/modules/diagnostic/services/diagnostic-monitor"
|
||||
import { WidgetBoundary } from "@/shared/components/widget-boundary"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
@@ -16,6 +26,7 @@ export default async function ClassDiagnosticPage({
|
||||
}): Promise<JSX.Element> {
|
||||
const { classId } = await params
|
||||
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
||||
const t = await getTranslations("diagnostic")
|
||||
|
||||
// DataScope 校验:教师只能查看所教班级,学生/家长不可访问
|
||||
if (ctx.dataScope.type === "class_taught" && !ctx.dataScope.classIds.includes(classId)) {
|
||||
@@ -31,19 +42,29 @@ export default async function ClassDiagnosticPage({
|
||||
notFound()
|
||||
}
|
||||
|
||||
// v2-P2-7: 包装默认服务以添加监控埋点(默认 no-op,生产环境可注入真实实现)
|
||||
const monitoredService = createMonitoredDiagnosticService(
|
||||
defaultDiagnosticService,
|
||||
noopDiagnosticMonitor,
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
||||
<div>
|
||||
<h1 className="flex items-center gap-2 text-2xl font-bold tracking-tight">
|
||||
<Stethoscope className="h-6 w-6" aria-hidden="true" />
|
||||
Class Diagnostic
|
||||
{t("title.teacherClass")}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Class-level knowledge point mastery overview and student attention list.
|
||||
{t("title.teacherClassDesc")}
|
||||
</p>
|
||||
</div>
|
||||
<WidgetBoundary title="班级学情诊断" skeletonHeight={400}>
|
||||
<ClassDiagnosticView summary={summary} />
|
||||
<WidgetBoundary title={t("title.teacherClass")} skeletonHeight={400}>
|
||||
<DiagnosticMonitorProvider monitor={noopDiagnosticMonitor}>
|
||||
<DiagnosticServiceProvider service={monitoredService}>
|
||||
<ClassDiagnosticView summary={summary} />
|
||||
</DiagnosticServiceProvider>
|
||||
</DiagnosticMonitorProvider>
|
||||
</WidgetBoundary>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
@@ -10,14 +11,15 @@ export default function TeacherDiagnosticError({
|
||||
error: Error & { digest?: string }
|
||||
reset: () => void
|
||||
}) {
|
||||
const t = useTranslations("diagnostic")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title="学情诊断页面加载失败"
|
||||
description="抱歉,页面加载时发生了意外错误。请稍后重试。"
|
||||
title={t("error.pageTitle")}
|
||||
description={t("error.pageDescription")}
|
||||
action={{
|
||||
label: "重试",
|
||||
label: t("error.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
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 { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||
import { getDiagnosticReports } from "@/modules/diagnostic/data-access-reports"
|
||||
import { ReportList } from "@/modules/diagnostic/components/report-list"
|
||||
import {
|
||||
DiagnosticServiceProvider,
|
||||
} from "@/modules/diagnostic/services/diagnostic-service-context"
|
||||
import { defaultDiagnosticService } from "@/modules/diagnostic/services/default-diagnostic-service"
|
||||
import { createMonitoredDiagnosticService } from "@/modules/diagnostic/services/monitored-diagnostic-service"
|
||||
import {
|
||||
DiagnosticMonitorProvider,
|
||||
} from "@/modules/diagnostic/services/diagnostic-monitor-context"
|
||||
import { noopDiagnosticMonitor } from "@/modules/diagnostic/services/diagnostic-monitor"
|
||||
import type { DiagnosticReportType, DiagnosticReportStatus } from "@/modules/diagnostic/types"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
@@ -20,12 +30,12 @@ const VALID_REPORT_STATUSES: ReadonlySet<string> = new Set([
|
||||
"archived",
|
||||
])
|
||||
|
||||
function parseReportType(v?: string): DiagnosticReportType | undefined {
|
||||
return v && VALID_REPORT_TYPES.has(v) ? (v as DiagnosticReportType) : undefined
|
||||
function isReportType(v: string): v is DiagnosticReportType {
|
||||
return VALID_REPORT_TYPES.has(v)
|
||||
}
|
||||
|
||||
function parseReportStatus(v?: string): DiagnosticReportStatus | undefined {
|
||||
return v && VALID_REPORT_STATUSES.has(v) ? (v as DiagnosticReportStatus) : undefined
|
||||
function isReportStatus(v: string): v is DiagnosticReportStatus {
|
||||
return VALID_REPORT_STATUSES.has(v)
|
||||
}
|
||||
|
||||
export default async function TeacherDiagnosticPage({
|
||||
@@ -35,33 +45,44 @@ export default async function TeacherDiagnosticPage({
|
||||
}): Promise<JSX.Element> {
|
||||
const sp = await searchParams
|
||||
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
||||
const t = await getTranslations("diagnostic")
|
||||
|
||||
const reportType = getParam(sp, "reportType")
|
||||
const status = getParam(sp, "status")
|
||||
const reportTypeParam = getParam(sp, "reportType")
|
||||
const statusParam = getParam(sp, "status")
|
||||
|
||||
const reports = await getDiagnosticReports(
|
||||
{
|
||||
reportType: reportType && reportType !== "all" ? parseReportType(reportType) : undefined,
|
||||
status: status && status !== "all" ? parseReportStatus(status) : undefined,
|
||||
},
|
||||
ctx.dataScope,
|
||||
const reportType =
|
||||
reportTypeParam && reportTypeParam !== "all" && isReportType(reportTypeParam)
|
||||
? reportTypeParam
|
||||
: undefined
|
||||
const status =
|
||||
statusParam && statusParam !== "all" && isReportStatus(statusParam)
|
||||
? statusParam
|
||||
: undefined
|
||||
|
||||
const reports = await getDiagnosticReports({ reportType, status }, ctx.dataScope)
|
||||
|
||||
// v2-P2-2: 移除客户端 filter,DataScope 过滤已在 data-access 层完成
|
||||
// class_members scope 的学生已通过 filters.studentId 在 data-access 层过滤
|
||||
|
||||
// v2-P2-7: 包装默认服务以添加监控埋点(默认 no-op,生产环境可注入真实实现)
|
||||
const monitoredService = createMonitoredDiagnosticService(
|
||||
defaultDiagnosticService,
|
||||
noopDiagnosticMonitor,
|
||||
)
|
||||
|
||||
// 学生角色仅查看自己的报告;其他角色查看全部
|
||||
const visibleReports =
|
||||
ctx.dataScope.type === "class_members"
|
||||
? reports.reports.filter((r) => r.studentId === ctx.userId)
|
||||
: reports.reports
|
||||
|
||||
return (
|
||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">Learning Diagnostic</h1>
|
||||
<h1 className="text-2xl font-bold tracking-tight">{t("title.teacherReportList")}</h1>
|
||||
<p className="text-muted-foreground">
|
||||
View and manage diagnostic reports based on knowledge point mastery.
|
||||
{t("title.teacherReportListDesc")}
|
||||
</p>
|
||||
</div>
|
||||
<ReportList reports={visibleReports} />
|
||||
<DiagnosticMonitorProvider monitor={noopDiagnosticMonitor}>
|
||||
<DiagnosticServiceProvider service={monitoredService}>
|
||||
<ReportList reports={reports.reports} />
|
||||
</DiagnosticServiceProvider>
|
||||
</DiagnosticMonitorProvider>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
@@ -10,14 +11,15 @@ export default function DiagnosticStudentError({
|
||||
error: Error & { digest?: string }
|
||||
reset: () => void
|
||||
}) {
|
||||
const t = useTranslations("diagnostic")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title="学生学情诊断加载失败"
|
||||
description="抱歉,加载学生诊断数据时发生了意外错误。请稍后重试。"
|
||||
title={t("error.studentLoadFailed")}
|
||||
description={t("error.studentLoadFailedDesc")}
|
||||
action={{
|
||||
label: "重试",
|
||||
label: t("error.retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { JSX } from "react"
|
||||
import { notFound } from "next/navigation"
|
||||
import { Stethoscope } from "lucide-react"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import {
|
||||
@@ -10,7 +11,7 @@ import {
|
||||
import { getDiagnosticReports } from "@/modules/diagnostic/data-access-reports"
|
||||
import { getStudentActiveClassId } from "@/modules/classes/data-access"
|
||||
import { StudentDiagnosticView } from "@/modules/diagnostic/components/student-diagnostic-view"
|
||||
import { WidgetBoundary } from "@/modules/grades/components/widget-boundary"
|
||||
import { WidgetBoundary } from "@/shared/components/widget-boundary"
|
||||
import type { MasteryRadarPoint } from "@/modules/diagnostic/types"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
@@ -22,6 +23,7 @@ export default async function StudentDiagnosticPage({
|
||||
}): Promise<JSX.Element> {
|
||||
const { studentId } = await params
|
||||
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
||||
const t = await getTranslations("diagnostic")
|
||||
|
||||
// DataScope 二次校验:学生只能看自己,家长只能看子女
|
||||
if (ctx.dataScope.type === "class_members" && ctx.userId !== studentId) {
|
||||
@@ -67,18 +69,18 @@ export default async function StudentDiagnosticPage({
|
||||
<div>
|
||||
<h1 className="flex items-center gap-2 text-2xl font-bold tracking-tight">
|
||||
<Stethoscope className="h-6 w-6" aria-hidden="true" />
|
||||
Student Diagnostic
|
||||
{t("title.teacherStudent")}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Knowledge point mastery analysis and diagnostic reports.
|
||||
{t("title.teacherStudentDesc")}
|
||||
</p>
|
||||
</div>
|
||||
<WidgetBoundary title="学生学情诊断" skeletonHeight={400}>
|
||||
<WidgetBoundary title={t("title.teacherStudent")} skeletonHeight={400}>
|
||||
<StudentDiagnosticView
|
||||
summary={summary}
|
||||
reports={reports}
|
||||
classAverageMastery={classAverageMastery}
|
||||
practiceHrefBase="/teacher/questions"
|
||||
role="teacher"
|
||||
/>
|
||||
</WidgetBoundary>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user