From 7c1b764b5937d9c85c5d85c58e1e6558afd2a434 Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Tue, 7 Jul 2026 12:52:32 +0800 Subject: [PATCH] feat(logging): wire useErrorReport into all 129 error.tsx boundaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 所有 129 个 error.tsx 客户端错误边界接入 useErrorReport Hook,客户端路由错误自动上报到 /api/client-error 端点,服务端通过 pino logger 统一记录。移除了 7 处 useEffect + console.error 调用。为无 props 的 error.tsx 补全 error 参数解构。 --- src/app/(auth)/error.tsx | 4 +++- src/app/(dashboard)/admin/announcements/[id]/error.tsx | 4 +++- src/app/(dashboard)/admin/announcements/error.tsx | 4 +++- src/app/(dashboard)/admin/attendance/error.tsx | 4 +++- .../(dashboard)/admin/audit-logs/data-changes/error.tsx | 3 +++ src/app/(dashboard)/admin/audit-logs/error.tsx | 3 +++ .../(dashboard)/admin/audit-logs/login-logs/error.tsx | 3 +++ src/app/(dashboard)/admin/audit-logs/overview/error.tsx | 3 +++ .../(dashboard)/admin/course-plans/[id]/edit/error.tsx | 4 +++- src/app/(dashboard)/admin/course-plans/[id]/error.tsx | 4 +++- src/app/(dashboard)/admin/course-plans/create/error.tsx | 4 +++- src/app/(dashboard)/admin/course-plans/error.tsx | 4 +++- src/app/(dashboard)/admin/dashboard/error.tsx | 2 ++ src/app/(dashboard)/admin/elective/error.tsx | 4 +++- src/app/(dashboard)/admin/error-book/error.tsx | 4 +++- src/app/(dashboard)/admin/error.tsx | 4 +++- src/app/(dashboard)/admin/files/error.tsx | 2 ++ .../admin/lesson-plans/[planId]/view/error.tsx | 4 +++- src/app/(dashboard)/admin/lesson-plans/error.tsx | 4 +++- src/app/(dashboard)/admin/permissions/error.tsx | 2 ++ src/app/(dashboard)/admin/questions/error.tsx | 3 +++ src/app/(dashboard)/admin/roles/[id]/error.tsx | 2 ++ src/app/(dashboard)/admin/roles/error.tsx | 2 ++ src/app/(dashboard)/admin/scheduling/auto/error.tsx | 4 +++- src/app/(dashboard)/admin/scheduling/changes/error.tsx | 4 +++- src/app/(dashboard)/admin/scheduling/rules/error.tsx | 4 +++- src/app/(dashboard)/admin/school/academic-year/error.tsx | 4 +++- src/app/(dashboard)/admin/school/classes/error.tsx | 4 +++- src/app/(dashboard)/admin/school/departments/error.tsx | 4 +++- src/app/(dashboard)/admin/school/grades/error.tsx | 3 +++ .../(dashboard)/admin/school/grades/insights/error.tsx | 3 +++ src/app/(dashboard)/admin/school/schools/error.tsx | 4 +++- src/app/(dashboard)/admin/users/error.tsx | 2 ++ src/app/(dashboard)/admin/users/import/error.tsx | 4 +++- src/app/(dashboard)/announcements/[id]/error.tsx | 4 +++- src/app/(dashboard)/announcements/error.tsx | 4 +++- src/app/(dashboard)/dashboard/error.tsx | 2 ++ src/app/(dashboard)/error.tsx | 4 +++- src/app/(dashboard)/management/grade/classes/error.tsx | 3 +++ src/app/(dashboard)/management/grade/error.tsx | 4 +++- src/app/(dashboard)/management/grade/insights/error.tsx | 3 +++ src/app/(dashboard)/management/grade/practice/error.tsx | 6 ++---- src/app/(dashboard)/messages/[id]/error.tsx | 4 +++- src/app/(dashboard)/messages/compose/error.tsx | 4 +++- src/app/(dashboard)/messages/error.tsx | 4 +++- src/app/(dashboard)/messages/group-compose/error.tsx | 4 +++- src/app/(dashboard)/parent/attendance/error.tsx | 4 +++- src/app/(dashboard)/parent/course-plans/[id]/error.tsx | 4 +++- src/app/(dashboard)/parent/course-plans/error.tsx | 4 +++- src/app/(dashboard)/parent/dashboard/error.tsx | 2 ++ src/app/(dashboard)/parent/diagnostic/error.tsx | 3 +++ src/app/(dashboard)/parent/elective/error.tsx | 4 +++- src/app/(dashboard)/parent/error-book/error.tsx | 4 +++- src/app/(dashboard)/parent/error.tsx | 2 ++ src/app/(dashboard)/parent/grades/error.tsx | 3 +++ src/app/(dashboard)/parent/grades/report-card/error.tsx | 6 ++---- .../parent/lesson-plans/[planId]/view/error.tsx | 4 +++- src/app/(dashboard)/parent/lesson-plans/error.tsx | 4 +++- src/app/(dashboard)/parent/practice/error.tsx | 3 +++ src/app/(dashboard)/profile/error.tsx | 4 +++- src/app/(dashboard)/settings/error.tsx | 4 +++- src/app/(dashboard)/settings/security/error.tsx | 4 +++- src/app/(dashboard)/student/attendance/error.tsx | 4 +++- src/app/(dashboard)/student/course-plans/[id]/error.tsx | 4 +++- src/app/(dashboard)/student/course-plans/error.tsx | 4 +++- src/app/(dashboard)/student/dashboard/error.tsx | 2 ++ src/app/(dashboard)/student/diagnostic/error.tsx | 3 +++ src/app/(dashboard)/student/elective/error.tsx | 4 +++- src/app/(dashboard)/student/error-book/error.tsx | 4 +++- src/app/(dashboard)/student/error.tsx | 2 ++ src/app/(dashboard)/student/grades/error.tsx | 3 +++ src/app/(dashboard)/student/grades/report-card/error.tsx | 6 ++---- .../learning/assignments/[assignmentId]/error.tsx | 4 +++- .../learning/assignments/[assignmentId]/result/error.tsx | 4 +++- .../student/learning/courses/[classId]/error.tsx | 2 ++ src/app/(dashboard)/student/learning/courses/error.tsx | 2 ++ src/app/(dashboard)/student/learning/error.tsx | 2 ++ .../(dashboard)/student/learning/study-path/error.tsx | 3 +++ .../student/learning/textbooks/[id]/error.tsx | 3 +++ src/app/(dashboard)/student/learning/textbooks/error.tsx | 3 +++ src/app/(dashboard)/student/leave/error.tsx | 4 +++- .../student/lesson-plans/[planId]/view/error.tsx | 4 +++- src/app/(dashboard)/student/lesson-plans/error.tsx | 4 +++- .../(dashboard)/student/practice/[sessionId]/error.tsx | 6 ++---- src/app/(dashboard)/student/practice/error.tsx | 6 ++---- src/app/(dashboard)/student/schedule/error.tsx | 2 ++ src/app/(dashboard)/teacher/attendance/error.tsx | 4 +++- src/app/(dashboard)/teacher/attendance/report/error.tsx | 4 +++- src/app/(dashboard)/teacher/attendance/sheet/error.tsx | 4 +++- src/app/(dashboard)/teacher/attendance/stats/error.tsx | 4 +++- src/app/(dashboard)/teacher/classes/my/[id]/error.tsx | 2 ++ src/app/(dashboard)/teacher/classes/my/error.tsx | 2 ++ src/app/(dashboard)/teacher/classes/schedule/error.tsx | 2 ++ src/app/(dashboard)/teacher/classes/students/error.tsx | 2 ++ src/app/(dashboard)/teacher/course-plans/[id]/error.tsx | 4 +++- src/app/(dashboard)/teacher/course-plans/error.tsx | 4 +++- .../teacher/diagnostic/class/[classId]/error.tsx | 3 +++ src/app/(dashboard)/teacher/diagnostic/error.tsx | 3 +++ .../teacher/diagnostic/student/[studentId]/error.tsx | 3 +++ src/app/(dashboard)/teacher/elective/error.tsx | 4 +++- src/app/(dashboard)/teacher/error-book/error.tsx | 9 ++++++++- .../(dashboard)/teacher/exams/[id]/analytics/error.tsx | 4 +++- src/app/(dashboard)/teacher/exams/[id]/build/error.tsx | 4 +++- .../(dashboard)/teacher/exams/[id]/edit-rich/error.tsx | 4 +++- .../(dashboard)/teacher/exams/[id]/proctoring/error.tsx | 4 +++- src/app/(dashboard)/teacher/exams/all/error.tsx | 4 +++- src/app/(dashboard)/teacher/exams/create/error.tsx | 4 +++- src/app/(dashboard)/teacher/exams/new/error.tsx | 4 +++- src/app/(dashboard)/teacher/grades/analytics/error.tsx | 3 +++ src/app/(dashboard)/teacher/grades/entry/error.tsx | 3 +++ src/app/(dashboard)/teacher/grades/error.tsx | 3 +++ src/app/(dashboard)/teacher/grades/report-card/error.tsx | 6 ++---- src/app/(dashboard)/teacher/grades/stats/error.tsx | 3 +++ .../teacher/homework/assignments/[id]/error.tsx | 4 +++- .../homework/assignments/[id]/submissions/error.tsx | 4 +++- .../(dashboard)/teacher/homework/assignments/error.tsx | 4 +++- src/app/(dashboard)/teacher/homework/error.tsx | 4 +++- .../homework/submissions/[submissionId]/error.tsx | 4 +++- .../submissions/[submissionId]/scan-grading/error.tsx | 4 +++- .../teacher/lesson-plans/[planId]/edit/error.tsx | 9 ++++++++- .../(dashboard)/teacher/lesson-plans/calendar/error.tsx | 9 ++++++++- src/app/(dashboard)/teacher/lesson-plans/error.tsx | 9 ++++++++- .../(dashboard)/teacher/lesson-plans/heatmap/error.tsx | 9 ++++++++- .../(dashboard)/teacher/lesson-plans/library/error.tsx | 9 ++++++++- src/app/(dashboard)/teacher/lesson-plans/new/error.tsx | 9 ++++++++- src/app/(dashboard)/teacher/practice/error.tsx | 6 ++---- src/app/(dashboard)/teacher/questions/error.tsx | 3 +++ src/app/(dashboard)/teacher/textbooks/[id]/error.tsx | 3 +++ src/app/(dashboard)/teacher/textbooks/error.tsx | 3 +++ 129 files changed, 396 insertions(+), 104 deletions(-) diff --git a/src/app/(auth)/error.tsx b/src/app/(auth)/error.tsx index 7816187..a5819dc 100644 --- a/src/app/(auth)/error.tsx +++ b/src/app/(auth)/error.tsx @@ -2,8 +2,10 @@ import { Button } from "@/shared/components/ui/button" import { AlertCircle } from "lucide-react" +import { useErrorReport } from "@/shared/hooks/use-error-report" -export default function AuthError({ reset }: { error: Error & { digest?: string }; reset: () => void }) { +export default function AuthError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { + useErrorReport(error) return (