feat(textbooks): 教材模块审计重构 — 跨模块解耦 + 权限 + i18n + 错误边界 + 纯函数抽取
P0 修复: - 解耦跨模块 UI 依赖:knowledge-point-dialogs 不再直接 import questions, 改为 renderQuestionCreator render prop 由页面注入 - 接入 usePermission Hook 替换 canEdit 硬编码 - 全模块 i18n 改造:新增 en/zh-CN 翻译文件,替换所有硬编码文案 - Server Action 资源归属校验:新增 verifyChapterBelongsToTextbook/ verifyKnowledgePointBelongsToTextbook,在 reorder/update/delete/create 中校验 P1 改进: - 补齐 Error Boundary:4 个 error.tsx + TextbookSectionErrorBoundary 区块包裹 - 抽取纯函数到 utils.ts/graph-layout.ts/constants.ts 并补单测(26 用例全通过) - 消除重复组件:删除 knowledge-point-panel/create-knowledge-point-dialog - 修复类型断言:chapter.children! → 守卫式访问 - 图谱 a11y:添加 role/aria-label/aria-pressed - 统一删除确认:confirm() → AlertDialog - 数据范围过滤:getTextbooksWithScope 支持学生端按年级过滤 P2 预留: - TextbookAnalytics 埋点接口 + Provider + Hook 同步 005 架构数据 JSON:补充 getTextbooksWithScope/verify*/ChapterTreeNode 等
This commit is contained in:
@@ -4220,6 +4220,34 @@
|
||||
"usedBy": [
|
||||
"questions/data-access.getKnowledgePointOptions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "getTextbooksWithScope",
|
||||
"signature": "(query?, subject?, grade?, scope?: TextbookQueryScope) => Promise<Textbook[]>",
|
||||
"purpose": "P1-1 新增:按数据范围获取教材列表,学生端强制按年级过滤",
|
||||
"usedBy": [
|
||||
"student/learning/textbooks/page.tsx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "verifyChapterBelongsToTextbook",
|
||||
"signature": "(chapterId, textbookId) => Promise<boolean>",
|
||||
"purpose": "P0-4 新增:资源归属校验,防止跨教材越权操作章节",
|
||||
"usedBy": [
|
||||
"reorderChaptersAction",
|
||||
"updateChapterContentAction",
|
||||
"deleteChapterAction",
|
||||
"createKnowledgePointAction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "verifyKnowledgePointBelongsToTextbook",
|
||||
"signature": "(kpId, textbookId) => Promise<boolean>",
|
||||
"purpose": "P0-4 新增:资源归属校验,防止跨教材越权操作知识点",
|
||||
"usedBy": [
|
||||
"updateKnowledgePointAction",
|
||||
"deleteKnowledgePointAction"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hooks": [
|
||||
@@ -4251,6 +4279,15 @@
|
||||
"questions (知识点关联)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ChapterTreeNode",
|
||||
"definition": "Chapter & { children: ChapterTreeNode[] }",
|
||||
"purpose": "P1-5 新增:buildChapterTree 返回类型,强制 children 为非空数组",
|
||||
"usedBy": [
|
||||
"textbooks/utils.buildChapterTree",
|
||||
"textbooks/components/chapter-sidebar-list.tsx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "KnowledgePoint",
|
||||
"definition": "{ id, name, description?, anchorText?, parentId?, chapterId?, level, order }",
|
||||
|
||||
Reference in New Issue
Block a user