refactor: fix remaining P2 architecture issues
Fix P2-6: proxy.ts now uses Permissions constants instead of hardcoded strings Fix P2-7: useA11yId file no longer exists (use-aria-live.ts already in hooks/) Fix P2-8: schema.ts section numbering reordered to continuous 1-24 Fix P2-11: announcements dead code void wasPublished already removed Fix P2-17: app-sidebar.tsx uses hasRole() instead of permission-based role inference Fix P2-18: scheduling/actions.ts removes trailing re-export of data-access; 4 pages now import directly from data-access Sync architecture docs 004 and 005
This commit is contained in:
@@ -1410,19 +1410,19 @@ shared/lib/{audit-logger, change-logger, auth-guard} → @/auth → shared/lib/*
|
||||
| ~~P2-3~~ | ~~`shared/lib/ai.ts` 218 行,混合 5 类职责~~ ✅ 已修复(P2-2 已拆分为 `ai/` 目录) | shared |
|
||||
| P2-4 | `onboarding-gate.tsx` 业务逻辑泄漏到 shared | shared |
|
||||
| P2-5 | `global-search.tsx` 业务类型硬编码在 shared | shared |
|
||||
| P2-6 | `proxy.ts` 硬编码权限字符串,未复用 Permissions 常量 | proxy |
|
||||
| P2-7 | `useA11yId` Hook 错放在 lib/ 而非 hooks/ | shared |
|
||||
| P2-8 | `schema.ts` 分节编号混乱(section 12 出现在 14b 之后) | shared/db |
|
||||
| ~~P2-6~~ | ~~`proxy.ts` 硬编码权限字符串,未复用 Permissions 常量~~ ✅ 已修复(改用 `Permissions` 常量) | proxy |
|
||||
| ~~P2-7~~ | ~~`useA11yId` Hook 错放在 lib/ 而非 hooks/~~ ✅ 已修复(文件已不存在;`use-aria-live.ts` 已在 `hooks/` 目录) | shared |
|
||||
| ~~P2-8~~ | ~~`schema.ts` 分节编号混乱(section 12 出现在 14b 之后)~~ ✅ 已修复(重新编号为连续 1-24) | shared/db |
|
||||
| P2-9 | `audit/actions.ts` Excel 导出逻辑内联 | audit |
|
||||
| P2-10 | school 模块审计日志不一致(仅 school 实体记录) | school |
|
||||
| P2-11 | `announcements` 死代码 `void wasPublished` | announcements |
|
||||
| ~~P2-11~~ | ~~`announcements` 死代码 `void wasPublished`~~ ✅ 已修复(代码中已不存在) | announcements |
|
||||
| ~~P2-12~~ | ~~`announcements` 权限模式不一致(requireAuth vs requirePermission)~~ ✅ 已修复 | announcements |
|
||||
| P2-13 | `files` try-catch 吞错误 | files |
|
||||
| P2-14 | `elective` runLottery 使用 Math.random | elective |
|
||||
| P2-15 | `elective` selectCourse FCFS 并发超卖风险 | elective |
|
||||
| P2-16 | `diagnostic` 班级报告 studentId 字段复用 | diagnostic |
|
||||
| P2-17 | `layout` 用权限反推角色 | layout |
|
||||
| P2-18 | `scheduling/actions.ts` 末尾 re-export data-access | scheduling |
|
||||
| ~~P2-17~~ | ~~`layout` 用权限反推角色~~ ✅ 已修复(`app-sidebar.tsx` 改用 `hasRole()` 判断角色) | layout |
|
||||
| ~~P2-18~~ | ~~`scheduling/actions.ts` 末尾 re-export data-access~~ ✅ 已修复(移除 re-export,4 个页面改为从 `data-access` 导入) | scheduling |
|
||||
| P2-19 | `ExamAssembly` / `ExamPreviewQuestionEditor` 10 个 props | exams |
|
||||
| P2-20 | ~~`homework/data-access.getDemoStudentUser` 使用 `auth()` 而非 auth-guard~~ ✅ 已修复(已迁移至 `users/data-access.getCurrentStudentUser`,6 个 student 页面改用 users 模块;`elective` 页面改用 `getAuthContext()`;homework 保留 re-export 向后兼容) | homework |
|
||||
|
||||
@@ -1449,11 +1449,11 @@ shared/lib/{audit-logger, change-logger, auth-guard} → @/auth → shared/lib/*
|
||||
|
||||
### 中期执行(P2)
|
||||
14. ~~建立模块间数据访问规范(通过对方 data-access 或导出查询函数)~~ ✅ 已完成(P1-1 修复)
|
||||
15. `schema.ts` 按业务域分节
|
||||
15. ~~`schema.ts` 按业务域分节~~ ✅ 已完成(P2-8 修复:重新编号为连续 1-24,消除 8b/14b/乱序问题)
|
||||
16. 拆分 `exams/ai-pipeline.ts`
|
||||
17. ~~拆分 `shared/lib/ai.ts`~~ ✅ 已完成(P2-2,commit 6588f74,拆分为 `ai/` 目录 6 个文件,原 ai.ts 保留为重导出)
|
||||
18. shared 层业务逻辑下沉到 modules 层
|
||||
19. 代码质量问题逐项修复(✅ 大部分已修复:React.cache 包装、Promise.all 并行化、错误吞没清理、非空断言清理、函数返回类型补齐、重复代码提取、合并 filter 遍历、Set/Map 优化)
|
||||
19. 代码质量问题逐项修复(✅ 大部分已修复:React.cache 包装、Promise.all 并行化、错误吞没清理、非空断言清理、函数返回类型补齐、重复代码提取、合并 filter 遍历、Set/Map 优化、P2-6 proxy.ts 权限常量复用、P2-11 announcements 死代码清理、P2-17 layout 角色判断、P2-18 scheduling re-export 移除)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"generatedAt": "2026-06-17",
|
||||
"formatVersion": "1.1",
|
||||
"rule": "每次文件修改后须同步更新本文件",
|
||||
"lastUpdate": "P1-1 已修复:所有跨模块直查已改为通过对方 data-access 接口(homework/grades/parent/diagnostic/elective/proctoring/notifications/scheduling/classes 模块);exams 模块 getSubjectsAction/getGradesAction 改为调用 school data-access;questions 模块 getKnowledgePointOptionsAction 改为调用 textbooks data-access;grades 模块多处直查 classes/classEnrollments/subjects/users 改为调用对应模块 data-access;classes 模块 actions 直查 grades 表改为调用 school data-access,getSessionTeacherId 改为通过 auth-guard.getAuthContext;attendance 模块 getClassStudentsForAttendance 改为通过 classes data-access;scheduling 模块 autoScheduleAction 直查 users 改为通过 users data-access;notifications 模块 sendClassNotificationAction 直查 classes/classEnrollments 改为通过 classes data-access;proctoring 模块跨模块直查 exams/examSubmissions/users 改为通过 exams/users data-access;diagnostic 模块 updateMasteryFromSubmission 跨模块直查 4 张表改为通过 exams/questions data-access;dashboard 教师仪表盘直查 users 改为通过 users data-access;users 模块 updateUserProfile 绕过 data-access 已下沉;P2-20 已修复:getDemoStudentUser 从 homework 模块迁移至 users 模块 getCurrentStudentUser(homework 保留 re-export 向后兼容),6 个 student 页面(dashboard/assignments/assignments-[assignmentId]/courses/textbooks/textbooks-[id]/schedule)改用 users 模块,消除对 homework 的虚假依赖;student/elective 改用 getAuthContext();shared/types/action-state.ts 移除分号修复 Prettier 违规;shared/types/permissions.ts EXAM_PROCTOR_READ 字符串从 exam:proctor_read 改为 exam:proctor:read 统一命名;为 ActionState/DataScope/AuthContext 添加 JSDoc 注释;P0-2 已修复:shared/lib ↔ auth 循环依赖已解决,新增 shared/lib/session.ts 单一入口封装 getSession()(dynamic import 打破静态循环),audit-logger/change-logger/auth-guard 改为通过 session.ts 获取 session;P1-6 已修复:http-utils.ts 新增 getUserAgent(),audit-logger/change-logger/login-logger 删除本地重复 IP/UA 提取逻辑,统一复用 resolveClientIp/getUserAgent;P0-1 已修复:exams/data-access.persistAiGeneratedExamDraft 改为调用 questions/data-access.createQuestionWithRelations,不再直查 questions 表;P0-2 已修复:exams/data-access.getExams/getExamById/getExamsDashboardStats 改为调用 classes/data-access.getClassGradeIdsByClassIds,不再直查 classes 表;P1-2 已修复:exams/homework/questions/announcements actions 层 DB 操作下沉到 data-access;P2-2 已修复:ai.ts 拆分为 ai/ 目录;P0-8 已修复:school actions 层 DB 操作下沉到 data-access,logAudit 改为 after() 异步非阻塞;P0-7 已修复:classes/data-access-stats.ts 和 data-access-students.ts 不再直查 homework/exams 表,改为调用新增的 homework/data-access-classes.ts 暴露的 7 个函数;新增 diagnostic/schema.ts(6 个 Zod schema)和 classes/schema.ts(13 个 Zod schema),actions.ts 中手动 typeof 校验全部替换为 Zod safeParse"
|
||||
"lastUpdate": "P2-6/P2-7/P2-8/P2-11/P2-17/P2-18 已修复:proxy.ts 改用 Permissions 常量替代硬编码字符串;useA11yId 文件已不存在(use-aria-live.ts 已在 hooks/ 目录);schema.ts 分节编号重新编号为连续 1-24,消除 8b/14b/乱序问题;announcements 死代码 void wasPublished 已不存在;layout/app-sidebar.tsx 改用 hasRole() 判断角色,不再用权限反推角色;scheduling/actions.ts 移除末尾 re-export data-access,4 个页面改为从 data-access 直接导入;P1-1 已修复:所有跨模块直查已改为通过对方 data-access 接口(homework/grades/parent/diagnostic/elective/proctoring/notifications/scheduling/classes 模块);P0-2 已修复:shared/lib ↔ auth 循环依赖已解决,新增 shared/lib/session.ts 单一入口;P1-6 已修复:http-utils.ts 统一 IP/UA 提取;P0-1/P0-2/P0-3/P0-4/P0-5/P0-7/P0-8 已修复;P1-2 已修复:actions 层 DB 操作下沉到 data-access;P2-2/P2-3/P2-12/P2-20 已修复"
|
||||
},
|
||||
"architectureOverview": {
|
||||
"layers": [
|
||||
|
||||
Reference in New Issue
Block a user