refactor: P0-1/2/4 解耦修复 - 拆分过耦合文件 + dashboard 解耦
This commit is contained in:
@@ -43,7 +43,7 @@ app/ ──▶ modules/ ──▶ shared/
|
||||
|
||||
### P0 严重问题(必须立即修复)
|
||||
|
||||
#### P0-1 `classes/data-access.ts` 2104 行,超硬上限 2.1 倍
|
||||
#### P0-1 `classes/data-access.ts` 2104 行,超硬上限 2.1 倍 ✅ 已修复
|
||||
|
||||
**问题**:
|
||||
- 文件行数 2104,远超 1000 行硬上限
|
||||
@@ -58,18 +58,21 @@ app/ ──▶ modules/ ──▶ shared/
|
||||
**解耦方案**:
|
||||
```
|
||||
src/modules/classes/
|
||||
├── data-access.ts # 班级核心 CRUD(目标 ≤500 行)
|
||||
├── data-access-stats.ts # 班级统计查询(getHomeworkStats 等)
|
||||
├── data-access-schedule.ts # 班级课表查询(getClassSchedule 等)
|
||||
└── data-access-grades.ts # 班级成绩汇总(getClassGradeSummary 等)
|
||||
├── data-access.ts # 班级核心 CRUD(656 行)
|
||||
├── data-access-stats.ts # 班级统计查询(604 行)
|
||||
├── data-access-schedule.ts # 班级课表查询(230 行)
|
||||
├── data-access-students.ts # 学生相关查询(280 行)
|
||||
└── data-access-admin.ts # 管理员班级管理(441 行)
|
||||
```
|
||||
|
||||
**迁移步骤**:
|
||||
1. 创建 3 个新文件,按职责迁移对应函数
|
||||
2. 在 `data-access.ts` 中 re-export 以保持向后兼容
|
||||
1. ~~创建 3 个新文件,按职责迁移对应函数~~ ✅ 已创建 4 个新文件
|
||||
2. ~~在 `data-access.ts` 中 re-export 以保持向后兼容~~ ✅ 已完成
|
||||
3. 逐步更新调用方 import 路径
|
||||
4. 最终移除 re-export,强制使用新路径
|
||||
|
||||
**完成状态**:2026-06-17 已完成拆分,所有文件均 ≤800 行,通过 re-export 保持向后兼容
|
||||
|
||||
---
|
||||
|
||||
#### P0-2 `homework/data-access.ts` 1038 行,混入排名计算
|
||||
@@ -380,9 +383,9 @@ src/shared/lib/ai/
|
||||
| 1 | P0-3 修复循环依赖 | shared/lib + auth.ts | 低 |
|
||||
| 2 | P0-5 messaging 改用 dispatcher | messaging + notifications | 低 |
|
||||
| 3 | P0-6 统一 classSchedule 写入口 | classes + scheduling | 中 |
|
||||
| 4 | P0-2 拆分 homework/data-access | homework | 中 |
|
||||
| 4 | ~~P0-2 拆分 homework/data-access~~ ✅ | homework | 中 |
|
||||
| 5 | P0-4 dashboard 改用模块 data-access | dashboard + 11 个模块 | 高 |
|
||||
| 6 | P0-1 拆分 classes/data-access | classes + 多个调用方 | 高 |
|
||||
| 6 | ~~P0-1 拆分 classes/data-access~~ ✅ | classes + 多个调用方 | 高 |
|
||||
|
||||
### 第二阶段:P1 修复(建议 2-4 周)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user