Commit Graph

208 Commits

Author SHA1 Message Date
SpecialX
2236eb36e7 refactor(logging): replace console.error in action-utils with logger 2026-07-07 12:05:00 +08:00
SpecialX
c44f19aefd feat(logging): inject x-request-id in proxy.ts 2026-07-07 12:01:55 +08:00
SpecialX
dce2561751 feat(logging): add withRequestContext HOF for Server Actions 2026-07-07 11:51:47 +08:00
SpecialX
a208fcc601 feat(logging): add pino logger with createModuleLogger 2026-07-07 11:44:49 +08:00
SpecialX
3bd3ebc12d feat(logging): add request-context with AsyncLocalStorage 2026-07-07 11:34:40 +08:00
SpecialX
c2575960eb feat(logging): add pino dependency and LOG_LEVEL env var 2026-07-07 11:29:12 +08:00
SpecialX
94f098b0f2 perf(phase1-4): 补漏性能预算重构专项遗漏项
Phase 1 配置基线:next.config.ts 新增 experimental.optimizePackageImports(lucide-react/recharts/@xyflow/react/@tiptap/* /@radix-ui/*/date-fns)+ serverExternalPackages 追加 tencentcloud-sdk-nodejs + exceljs;providers.tsx 注入 WebVitalsReporter 闭环 RUM 上报链路(之前组件存在但未注入导致生产环境零性能数据)。

Phase 2 Bundle 预算优化补漏:TipTap 三实例(shared/ui/rich-text-editor + exams/editor/exam-rich-editor + lesson-preparation/blocks/rich-text-block)之前仅文件拆分未真正 next/dynamic ssr:false,本次补齐 lazy wrapper + xxx-inner.tsx 拆分模式;ReactFlow knowledge-graph.tsx 改用 next/dynamic 加载 inner;chart.tsx 改 recharts 具名导入替代 import * as RechartsPrimitive barrel。

Phase 4 组件渲染优化补漏:12 个 recharts 图表组件(parent/grades/dashboard/homework 模块下)margin props 提取到模块级 CHART_MARGIN 常量避免 inline 重建;layout.tsx metadata 增强(metadataBase/openGraph/twitter/robots/authors/creator)+ getLocale/getMessages/auth 串行 await 改 Promise.all 并行。

同步架构文档 004/005 + known-issues.md:新增 Phase 1 配置基线规则章节 + Phase 2 文件清单修正(之前引用不存在的 question-rich-editor.tsx 和 paper-rich-editor.tsx,实际是 rich-text-editor.tsx 和 rich-text-block.tsx)+ Phase 4.9 metadata + Promise.all 规则补充。架构图 1.1.5 章节新增未完成项(React Compiler/force-dynamic 评估/Playwright 性能断言)。

验证:npx tsc --noEmit 零错误;npm run lint 零新增错误(3 errors + 12 warnings 均位于未修改的 pre-existing 文件)。
2026-07-07 00:30:47 +08:00
SpecialX
e76c626779 refactor(classes,audit,school,settings,adaptive-practice,announcements,messaging,questions,student): 组件化重构遗漏补全 - 20 个重复组件迁移
补全未被批次覆盖的 9 个模块的重复组件迁移:
- classes: 迁移 students-filters/schedule-filters/class-skeleton/class-error-boundary
- audit: 迁移 3 个 filters + audit-log-table-skeleton + audit-error-boundary
- school: 迁移 grade-insights-filters/school-skeleton/school-error-boundary
- settings: 迁移 settings-section-error-boundary
- adaptive-practice: 迁移 2 个 practice-stats-cards 到 StatsGrid
- announcements: 迁移 announcement-list-skeleton 到 SkeletonCard
- messaging: 迁移 message-list-skeleton 到 SkeletonCard
- questions: 迁移 question-filters 到 app 层
- student: 迁移 course-filters/student-schedule-filters 到 app 层
- 补充 school/settings 模块 i18n error.boundary* 键
- tsc 零错误
2026-07-06 22:22:23 +08:00
SpecialX
fa68ec0b34 refactor(lesson-preparation,ai,dashboard): 组件化重构第 3 批 - 高风险模块
- lesson-preparation: 拆分 lesson-plan-editor (594→273),新增 toolbar/dialogs/publish-button 子组件 + 持久化 Hook
- ai: 拆分 ai-chat-panel (417→218),新增 messages/input 子组件,保持流式响应状态稳定
- dashboard: 新增 DashboardShell 布局壳,4 个角色 dashboard 统一使用
- 删除 6 个重复组件(filters/skeletons/error-boundaries)
- tsc 零错误
2026-07-06 20:49:54 +08:00
SpecialX
025d4de50d refactor(homework,exams,textbooks): 组件化重构第 2 批 - 中风险模块
- homework: 拆分 take-view (428→330) + grading-view (507→170),新增 4 个子组件
- exams: 拆分 exam-assembly (467→268),新增 3 个子组件 + 1 个工具模块
- textbooks: 拆分 textbook-reader (458→291) + knowledge-graph-inner (411→267),新增 4 个子组件
- textbooks: 删除同名 section-error-boundary.tsx,改用 shared 层
- 删除 3 个重复 filter 组件,迁移到底座
- tsc 零错误
2026-07-06 19:54:39 +08:00
SpecialX
19a05091d3 refactor(grades,attendance,error-book,elective): 组件化重构第 1 批 - 低风险模块
- grades: 拆分 batch-grade-entry (457→374) + grade-record-list (523→231),新增 4 个子组件
- attendance: 迁移 stats-cards/filters 到 StatsGrid/FilterBar 底座
- error-book: 迁移 stats-cards/filters 到 StatsGrid/FilterBar 底座
- elective: 迁移 stats-cards/filters 到 StatsGrid/FilterBar 底座
- 删除 12 个重复组件,新增 app 层 filter 组件就近放置
- tsc 零错误,lint 无新增错误
2026-07-06 19:01:57 +08:00
SpecialX
11ddc8ccbe feat(shared): 组件化重构 Phase 1 - 底座收敛与补全
- 新增 ErrorBoundary 基础类组件 (ui/error-boundary.tsx)
- 新增 StatsGrid 容器 (ui/stats-grid.tsx)
- 扩展 Skeleton 新增 SkeletonCard variant
- 收敛 SectionErrorBoundary/RouteErrorBoundary/WidgetBoundary 为 ErrorBoundary preset
2026-07-06 18:00:08 +08:00
SpecialX
9ce8d6d3fd refactor(data-access): 补全剩余 37 个 data-access 文件迁移至 cacheFn
迁移范围:lesson-preparation 11 文件、attendance 3 文件、settings 4 文件、classes-invitations、跨模块接口 4 文件、adaptive-practice/ai/onboarding/invitation-codes/search/standards/scheduling/leave-requests/audit。修复 3 个 cacheFn 块位置错误。同步架构文档迁移范围至 83 文件 250+ 函数。
2026-07-06 15:12:30 +08:00
SpecialX
8fff820e1d refactor(actions): 组 C 模块迁移至 invalidateFor(lesson-preparation/elective/announcements/messaging/notifications/settings/rbac) 2026-07-05 22:53:26 +08:00
SpecialX
7cfd85d0f5 refactor(actions): 组 B 模块迁移至 invalidateFor(exams/grades/homework/attendance/leave-requests/diagnostic/error-book/adaptive-practice) 2026-07-05 22:44:38 +08:00
SpecialX
05e68a3dad refactor(actions): 组 A 模块迁移至 invalidateFor(users/school/textbooks/questions/course-plans/standards/scheduling/audit/onboarding/invitation-codes/proctoring/i18n) 2026-07-05 22:43:08 +08:00
SpecialX
0f33484bd2 fix(questions): 完成 questions/data-access.ts 遗漏的 cacheFn 迁移 2026-07-05 22:27:07 +08:00
SpecialX
841b130f4c fix(data-access): 修复 tsc 错误 + 完成 adaptive-practice/elective 迁移至 cacheFn 2026-07-05 22:24:56 +08:00
SpecialX
27374d1b2c refactor(data-access): 组 A 模块迁移至 cacheFn(users/school/rbac/textbooks/questions/course-plans/standards/files/dashboard/parent/proctoring) 2026-07-05 21:56:18 +08:00
SpecialX
6dee6b6299 refactor(data-access): 组 C 模块迁移至 cacheFn(lesson-preparation/elective/announcements/messaging/notifications/audit/onboarding/invitation-codes/scheduling/settings) 2026-07-05 21:49:18 +08:00
SpecialX
cb5b92160c feat(cache): 扩充 INVALIDATION_MAP 覆盖剩余 27 个模块
为 i18n、adaptive-practice、announcements、attendance、audit、course-plans、
diagnostic、elective、error-book、exams、grades、homework、invitation-codes、
leave-requests、lesson-preparation、messaging、notifications、onboarding、
proctoring、questions、rbac、scheduling、school、settings、standards、
textbooks、users 共 27 个模块登记写操作的失效副作用(tags/queryKeys/paths),
便于后续 actions 文件迁移调用 invalidateFor(actionId)。

- 新增 195 个 actionId(含 create/update/delete 基础动作及 batch/import/
  appeal/draft/lock/template/formative/comment/substitute 等特殊写操作)
- tags 采用模块级粒度 ["{module}"],简化迁移
- paths 从原 revalidatePath 调用中提取,动态段用父路径覆盖
- 同步扩充 CLIENT_INVALIDATION_MAP(仅 queryKeys 子集)
- 保持 classes 部分(已有)不变
- 通过 npx tsc --noEmit 与 eslint 零错误验证
2026-07-05 21:28:40 +08:00
SpecialX
a3dc22cb9e refactor(classes): 客户端组件迁移至 useQuery + queryKeys 示范
Task 19: 将 class-invitation-manager.tsx 从 initialCodes prop + 本地 codes state +
手动 Action 调用 + 手动 state 更新模式,迁移至 V5 缓存策略新 API:

- 列表查询: useActionQuery + queryKeys.classes.invitations(classId)
- 撤销 mutation: useActionMutation + actionId "classes.invitation.revoke"
  (成功后由 CLIENT_INVALIDATION_MAP 自动失效 ["classes", "invitations"] 前缀)
- 生成回调: queryClient.invalidateQueries 手动失效本班级 invitations 查询
- 移除 initialCodes prop + codes state + isSubmitting 手动管理

配套改动:
- actions-invitations.ts: 新增并导出 ClassInvitationCodeOption 强类型接口,
  listClassInvitationCodesAction 返回类型从 Array<Record<string, unknown>>
  收窄为 ClassInvitationCodeOption[]
- actions.ts barrel: 补充 type ClassInvitationCodeOption 与遗漏的
  bulkEnrollStudentsAction / bulkAssignSubjectTeachersAction 导出
- 架构文档 004/005 同步更新 hook 消费方与 actions.ts exports 清单
2026-07-05 18:57:10 +08:00
SpecialX
80dd67780c refactor(classes): actions 迁移至 invalidateFor 集中编排 2026-07-05 18:38:58 +08:00
SpecialX
220d702b44 refactor(classes): data-access 迁移至 cacheFn + 双导出 raw 版本 2026-07-05 18:27:32 +08:00
SpecialX
dd7a49504f refactor(hooks): useActionQuery/useActionMutation 接入 QueryClient + 向后兼容
- useActionQuery 新增 queryKey 入参模式:传入 queryKey 走 useQuery 跨页共享缓存;不传回退旧 useEffect + useState 模式。Hook 内部始终声明 useQuery/useState/useEffect 以遵守 React Hooks 规则,通过 isCacheMode 切换启用状态

- useActionMutation 新增 mutationFn + actionId 模式:成功后按 CLIENT_INVALIDATION_MAP[actionId] 自动 invalidateQueries;mutate(action?) 参数可选

- toast 替换为 notify(行为等价,便于未来替换 toast 库)

- 同步更新 004/005 架构文档签名说明
2026-07-05 18:15:58 +08:00
SpecialX
d6227d6e6c feat(cache): 实现 cacheFn 双层包装(react.cache + cacheStore) 2026-07-05 18:07:11 +08:00
SpecialX
92913a728f feat(cache): 实现 invalidateFor 三步编排函数 2026-07-05 18:00:09 +08:00
SpecialX
e510f191c9 feat(cache): 新增 query-keys.ts 工厂(classes 模块) 2026-07-05 17:56:04 +08:00
SpecialX
2d49f1bad8 feat(cache): 新增 index.ts 公共 API 聚合导出 2026-07-05 17:55:58 +08:00
SpecialX
6baa60b2a1 feat(cache): 新增 INVALIDATION_MAP 集中式失效映射表(classes 模块) 2026-07-05 17:52:41 +08:00
SpecialX
13409e55f1 feat(cache): 新增 store-factory(CACHE_DRIVER 切换) 2026-07-05 17:52:24 +08:00
SpecialX
1756ac21a8 feat(cache): 新增客户端失效映射子集(queryKeys only) 2026-07-05 17:52:19 +08:00
SpecialX
0058b0b311 feat(cache): 实现 MemoryCacheStore(LRU + TTL + tag 索引) 2026-07-05 17:49:51 +08:00
SpecialX
4174cd61d7 feat(cache): 实现 RedisCacheStore(多实例 + tag 索引 + fail-open) 2026-07-05 17:45:02 +08:00
SpecialX
44f997bad7 refactor(redis): 抽出共享 Redis 客户端单例至 shared/lib/redis-client.ts 2026-07-05 17:40:45 +08:00
SpecialX
fcf89dfb2c feat(cache): 新增 cache/types.ts 类型定义 2026-07-05 17:35:17 +08:00
SpecialX
bc03275262 refactor(cache): 提升 upstash-modules 类型声明至 shared/lib 2026-07-05 17:33:31 +08:00
SpecialX
16ffd44161 feat(cache): 新增 CACHE_DRIVER 环境变量 2026-07-05 17:32:01 +08:00
SpecialX
9ec1be1528 fix(design-tokens): 补充 semantic-dark.css 缺失的 --radius 令牌
审查发现 semantic-light.css 定义了 --radius 但 semantic-dark.css 缺失,导致明暗不对称。补充 --radius: 0.5rem 与 :root 一致。
2026-07-05 01:09:36 +08:00
SpecialX
214ebec976 refactor(design-tokens): 全量体系化重建设计令牌
Primitive + Semantic 双层令牌架构,HEX->HSL,明暗双份,@theme inline 暴露为 Tailwind 类。

- 新建 src/app/styles/tokens/ 6 个令牌文件(primitive/semantic-light/semantic-dark/lesson-preparation/tailwind-theme/index)
- globals.css 改为 @import 引入,477->258 行
- 清理 91 处 #hex 硬编码颜色 -> hsl(var(--*))
- 清理 10 处硬编码字体 -> var(--font-family-*)
- 清理 100 文件 Tailwind 任意值(Tier 1 映射/Tier 3 注释豁免)
- 清理 M3 Surface 死代码,升级 --lp-* 令牌(HEX->HSL + 暗色补全)
- 新建 ESLint 自定义规则 no-hardcoded-design-tokens(单词边界正则)
- eslint.config.mjs 新增 no-restricted-syntax 禁止 #hex + 自定义规则加载(pathToFileURL)
- 项目规则新增设计令牌规范强制章节
- 架构图 004/005 同步设计令牌体系节点
- known-issues.md 追加设计令牌问题分类(7 个规则表)

验证: tsc --noEmit 0 errors, npm run lint 0 errors/12 warnings(均为既有问题)
2026-07-05 01:03:19 +08:00
SpecialX
e962b67050 feat(lesson-preparation): update paper-editor, detail-panel, AI node assist, i18n
- Update actions-ai.ts and curriculum-map-view.tsx

- Update detail-panel: detail-panel, detail-props, qa-editor

- Update paper-editor: inline-node, inline-qa-dialog, paper-context-menu,

  paper-editor, textbook-tiptap-editor

- Update hooks/editor-slice.ts and lib/i18n-errors.ts

- Add hooks/use-node-ai-assist.ts and lib/ai-node-assist.ts

- Update en/zh-CN lesson-preparation i18n messages
2026-07-04 23:02:04 +08:00
SpecialX
0e4eccec21 chore(lesson-preparation): V4 lint + tsc 零错误验证
重构 anchor-migration-banner:使用 key-based remount + lazy initial state 避免 setState in effect,符合 V4 react-hooks/set-state-in-effect 规则。

验证:tsc --noEmit 0 错误;lint 中 V4 引入的错误已全部修复。剩余 6 个 lint 错误为预存无关模块问题(exams/use-exam-preview-tasks react-hooks/refs 3 个、template-picker V5-9 set-state-in-effect 1 个),13 个 warnings 均为预存代码(schedule-dialog、unread-message-badge 等),按计划要求已有的无关模块错误需记录但不要求修复。
2026-07-04 11:53:13 +08:00
SpecialX
e762490f19 refactor(lesson-preparation): print-view 适配 V4
- export.ts 已使用 order 排序,无画布依赖
- 新增 interaction block 的 flatten 逻辑(设计意图 + 对话轮次)
- 更新文档注释(12 种 Block)
2026-07-04 11:47:50 +08:00
SpecialX
5d306dc686 refactor(lesson-preparation): 删除废弃的 React Flow 画布和字符串锚点文件
- 删除 node-editor.tsx(React Flow 画布)
- 删除 nodes/lesson-node.tsx、textbook-content-node.tsx、textbook-segments.tsx、anchor-node-selector.tsx
- 删除 lib/anchor-injector.ts(字符串偏移系统)
- 删除 lib/rf-mappers.ts(React Flow 映射)
- 删除 lib/auto-layout.ts(自动布局)
- 重构 lesson-plan-readonly-view.tsx 改用线性视图(LessonPlanMobileView)
2026-07-04 11:46:31 +08:00
SpecialX
124ed97060 refactor(lesson-preparation): 主编辑器三栏布局(结构树 + 纸 + 详情面板)
- 移除 NodeEditor/NodeEditPanel 导入和 JSX
- 改为 StructureTree + PaperEditor + DetailPanel 三栏布局
- 新增 AnchorMigrationBanner
- 移除 aiContentGenerator prop(V4 DetailPanel 自带 AI 按钮)
- 删除 node-edit-panel.tsx(不再被引用)
- 删除 ai-content-generator-slot.tsx(依赖 node-edit-panel)
2026-07-04 11:44:26 +08:00
SpecialX
e29f30d278 feat(lesson-preparation): v3 锚点失效提示 banner 2026-07-04 11:41:24 +08:00
SpecialX
6dd3b1fecd feat(lesson-preparation): 注册 interaction block 到 registry 2026-07-04 11:40:46 +08:00
SpecialX
85121c49a3 fix(lesson-preparation): 重命名 TreeNodeRow.children prop 为 childItems 避免 react/no-children-prop 2026-07-04 11:36:41 +08:00
SpecialX
8ff14fce1c feat(lesson-preparation): 右栏详情面板容器 2026-07-04 11:33:03 +08:00
SpecialX
24b8ae78c6 feat(lesson-preparation): 师生交互 block(详情编辑入口) 2026-07-04 11:32:58 +08:00