/** * 培训模块预览 harness 的接口 mock 数据与路由(仅 training-preview 本地验证用)。 * vite.training-preview.config.ts 以中间件形式拦截 /api/v1/training/*, * 返回与后端一致的封包 { success: true, data },让培训面板无后端渲染演示数据。 */ const NOW = new Date() const month = (offset: number, day: number) => { const d = new Date(NOW.getFullYear(), NOW.getMonth() + offset, day, 9, 0, 0) return d.toISOString() } export const TRAINING_MOCK = { depts: [ { id: 'dept-a', tenant_id: 1, parent_id: '', name: '冲压车间', code: 'CY', sort: 1 }, { id: 'dept-b', tenant_id: 1, parent_id: '', name: '技术部', code: 'JS', sort: 2 }, ], demands: [ { id: 'd1', code: `AP-${NOW.getFullYear()}-0001`, year: NOW.getFullYear(), dept_id: 'dept-a', dept_name: '冲压车间', submitter_id: 'm1', course_name: '叉车年度复训', post_scope: '叉车操作员', lecturer_name: '', planned_time: `${NOW.getFullYear() + 1}-3`, train_type: '内部', location: '一楼展厅', remark: '', check_status: 'pending', check_msg: '', status: 'submitted' }, { id: 'd2', code: `AP-${NOW.getFullYear()}-0002`, year: NOW.getFullYear(), dept_id: 'dept-b', dept_name: '技术部', submitter_id: 'm3', course_name: '品质工具(APQP)专题', post_scope: '品质岗', lecturer_name: '', planned_time: `${NOW.getFullYear() + 1}-5`, train_type: '外部', location: '技术部实训区', remark: '', check_status: 'passed', check_msg: '', status: 'confirmed' }, ], courses: [ { id: 'c1', code: 'CRS-0001', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0001`, name: '冲压B车间安全生产教育培训', mode: 'online', type: 'required', lecturer_id: 'u-m1', hours: 0.75, credits: 1, exam_enabled: true, dept_ids: ['dept-a'], post_scope: '全员必修', description: '', material_ids: ['mt1'], tags: ['安全'], status: 'published', creator_id: '', created_at: month(0, 2), updated_at: month(0, 2), }, { id: 'c2', code: 'CRS-0002', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0002`, name: '六轴机械手调试培训', mode: 'offline', type: 'required', lecturer_id: 'u-m2', hours: 4, credits: 2, exam_enabled: false, dept_ids: ['dept-b'], post_scope: '技术级以上', description: '', material_ids: [], tags: ['技能'], status: 'published', creator_id: '', created_at: month(-1, 20), updated_at: month(-1, 20), }, { id: 'c3', code: 'CRS-0003', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0003`, name: 'TOPGP系统培训', mode: 'online', type: 'elective', lecturer_id: 'u-m1', hours: 0.5, credits: 1, exam_enabled: false, dept_ids: [], post_scope: '', description: '', material_ids: [], tags: ['系统'], status: 'published', creator_id: '', created_at: month(-2, 11), updated_at: month(-2, 11), }, { id: 'c4', code: 'CRS-0004', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0004`, name: '产品品质培训(冲压)', mode: 'online', type: 'required', lecturer_id: 'u-m1', hours: 0.67, credits: 1, exam_enabled: true, dept_ids: ['dept-a'], post_scope: '品质岗', description: '', material_ids: ['mt2', 'mt3'], tags: ['品质'], status: 'published', creator_id: '', created_at: month(0, 28), updated_at: month(0, 28), }, { id: 'c5', code: 'CRS-0005', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0005`, name: '组装安全生产教育训练', mode: 'offline', type: 'required', lecturer_id: 'u-m3', hours: 2, credits: 1, exam_enabled: false, dept_ids: ['dept-a'], post_scope: '全员必修', description: '', material_ids: [], tags: ['安全'], status: 'published', creator_id: '', created_at: month(0, 5), updated_at: month(0, 5), }, { id: 'c6', code: 'CRS-0006', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0006`, name: '新员工入职引导', mode: 'online', type: 'required', lecturer_id: 'u-m3', hours: 1, credits: 1, exam_enabled: false, dept_ids: [], post_scope: '全员必修', description: '', material_ids: ['mt4'], tags: ['入职'], status: 'published', creator_id: '', created_at: month(0, 30), updated_at: month(0, 30), }, // 草稿课程:目录页仅展示已发布课程,此条应被前端过滤 { id: 'c7', code: 'CRS-0007', plan_code: `MP-${NOW.getFullYear()}${String(NOW.getMonth() + 1).padStart(2, '0')}-0007`, name: '模具保养必修课(草稿)', mode: 'offline', type: 'required', lecturer_id: 'u-m2', hours: 2, credits: 1, exam_enabled: false, dept_ids: [], post_scope: '', description: '', material_ids: [], tags: [], status: 'draft', creator_id: '', created_at: month(0, 1), updated_at: month(0, 1), }, ], myTasks: [ { id: 't1', course_id: 'c1', course_name: '冲压B车间安全生产教育培训', member_id: 'me', deadline: month(0, 20), status: 'doing' }, { id: 't2', course_id: 'c4', course_name: '产品品质培训(冲压)', member_id: 'me', deadline: month(0, 25), status: 'done' }, { id: 't3', course_id: 'c6', course_name: '新员工入职引导', member_id: 'me', deadline: month(1, 10), status: 'pending' }, ], // 课程学习情况(管理端):课程+学员唯一任务行 courseLearning: [ { id: 'cl1', course_id: 'c1', course_name: '冲压B车间安全生产教育培训', member_id: 'm1', employee_no: '91001', post: '培训运营工程师', dept_name: '设备部', deadline: month(0, 11), status: 'done' }, { id: 'cl2', course_id: 'c1', course_name: '冲压B车间安全生产教育培训', member_id: 'm2', employee_no: '23107', post: '冲压技师', dept_name: '生产一部', deadline: month(0, 11), status: 'pending' }, { id: 'cl3', course_id: 'c1', course_name: '冲压B车间安全生产教育培训', member_id: 'm3', employee_no: '24130', post: '质检员', dept_name: '品质部', deadline: month(0, 11), status: 'doing' }, { id: 'cl4', course_id: 'c1', course_name: '冲压B车间安全生产教育培训', member_id: 'm4', employee_no: '24512', post: '装配技工', dept_name: '生产二部', deadline: month(-1, 20), status: 'overdue' }, ], members: [ { id: 'm1', tenant_id: 1, user_id: 'u-m1', employee_no: '91001', dept_id: 'dept-a', post: '培训运营工程师', roles: ['hr'], lecturer_rate: 0, status: 'active' }, { id: 'm2', tenant_id: 1, user_id: 'u-m2', employee_no: '23107', dept_id: 'dept-a', post: '冲压技师', roles: ['trainee'], lecturer_rate: 0, status: 'active' }, { id: 'm3', tenant_id: 1, user_id: 'u-m3', employee_no: '24130', dept_id: 'dept-b', post: '质检员', roles: ['trainee'], lecturer_rate: 0, status: 'active' }, ], papers: [ { id: 'p1', session_id: 's1', bank_id: 'b1', name: 'TPM_Bank(A卷)', total_score: 50, pass_score: 30, version: 'A', question_ids: [] }, ], examRecords: [ { id: 'er1', paper_id: 'p1', session_id: 's1', member_id: 'm1', score: 45, submitted_at: month(0, 4), paper_name: 'TPM_Bank(A卷)', course_name: '冲压B车间安全生产教育培训', total_score: 50, pass_score: 30 }, { id: 'er2', paper_id: 'p1', session_id: 's1', member_id: 'm2', score: 10, submitted_at: month(0, 4), paper_name: 'TPM_Bank(A卷)', course_name: '冲压B车间安全生产教育培训', total_score: 50, pass_score: 30 }, ], enrollments: [ { id: 'e1', session_id: 's1', member_id: 'm1', status: 'completed', reason: '' }, { id: 'e2', session_id: 's1', member_id: 'm2', status: 'enrolled', reason: '' }, { id: 'e3', session_id: 's1', member_id: 'm3', status: 'enrolled', reason: '' }, ], signRecords: [ { id: 'sr1', session_id: 's1', member_id: 'm1', signed_at: month(0, 4), channel: 'wecom_scan', distance_m: 12, status: 'normal', abnormal_flags: [], reviewed_by: '' }, { id: 'sr2', session_id: 's1', member_id: 'm2', signed_at: month(0, 4), channel: 'wecom_scan', distance_m: 30, status: 'late', abnormal_flags: [], reviewed_by: '' }, ], wrongBook: [ { id: 'w1', question_id: 'q1', stem: '冲压机双手启动按钮的作用是什么?', question_type: 'single', knowledge_point: '安全操作规范', wrong_count: 3, mastered: false }, { id: 'w2', question_id: 'q2', stem: '模具安装前需确认哪些事项?', question_type: 'multiple', knowledge_point: '模具保养', wrong_count: 1, mastered: false }, ], profile: { member_id: 'me', name: '林知夏', dept_name: '技术部', points: 3, avg_score: 45, study_hours: 1.2, course_count: 3, dimensions: [], competency: 10, pass_line: 75, }, aiAnalysis: { scope: 'course', course_id: 'c1', course_name: '冲压B车间安全生产教育培训', stats: { learning: { total: 4, done: 1, doing: 1, pending: 1, overdue: 1, completion_rate: 25 }, exam: { expected: 4, taken: 2, passed: 1, failed: 1, avg_score: 27.5, pass_rate: 50 }, sign: { expected: 3, signed: 2, late: 1, absent: 1, abnormal: 0 }, wrong_questions: [ { knowledge_point: '安全操作规范', wrong_count: 3, error_rate: 0.5 }, { knowledge_point: '模具保养', wrong_count: 1, error_rate: 0.33 }, ], }, analysis: [ '## 总体评价', '', '当前课程整体完成率 25%,明显偏低;考试及格率 50%,平均分 27.5 分,掌握情况不理想。', '', '## 学习情况', '', '- 共 4 项学习任务:已完成 1、学习中 1、待学习 1、**已逾期 1**,需优先催办逾期任务。', '', '## 考试情况', '', '- 应考 4 人,已考 2 人,及格 1 人;「安全操作规范」知识点错误率达 50%,建议集中补训。', '', '## 改进建议', '', '1. 对逾期学员逐人催办,并同步课长督办;', '2. 组织未考学员安排补考,确保应考尽考;', '3. 针对「安全操作规范」安排一次 30 分钟集中补训并二次考试。', ].join('\n'), model_name: 'glm-4-plus', generated_at: '', }, sessions: [ { id: 's1', course_id: 'c2', month_plan_id: '', year: NOW.getFullYear(), month: NOW.getMonth() + 1, start_at: month(1, 12), end_at: month(1, 12), location: '3号厂房 · 二楼培训室', online_url: '', capacity: 0, lecturer_id: 'u-m2', status: 'scheduled' }, { id: 's2', course_id: 'c2', month_plan_id: '', year: NOW.getFullYear() - 1, month: 12, start_at: month(-2, 8), end_at: month(-2, 8), location: '技术部实训区', online_url: '', capacity: 0, lecturer_id: 'u-m2', status: 'finished' }, { id: 's3', course_id: 'c5', month_plan_id: '', year: NOW.getFullYear() - 1, month: 10, start_at: month(-1, 15), end_at: month(-1, 15), location: '一楼展厅', online_url: '', capacity: 0, lecturer_id: 'u-m3', status: 'finished' }, ], hrDashboard: { demand_progress: [ { dept_id: 'dept-a', dept_name: '冲压车间', total: 8, done: 5, percent: 62 }, { dept_id: 'dept-b', dept_name: '技术部', total: 6, done: 4, percent: 66 }, ], pending_demands: [ { id: 'd1', course_name: '叉车年度复训', check_status: 'pending' }, { id: 'd2', course_name: '品质工具(APQP)专题', check_status: 'passed' }, ], course_total: 12, course_online: 8, course_offline: 4, month_completion: { percent: 46, completed: 12, total: 26 }, month_sessions: [{ id: 's1' }, { id: 's9' }], }, } // 课程管理(课程资产主数据):预览 harness 演示数据(编号 CRS-#### 与后端一致); // 000163 课程权限:perm_dept_ids/perm_user_ids 为空时沿用 suitable_members 口径; // 000164 多课件:materials 逐条追加 const COURSE_LIBRARY_MOCK = [ { id: 'lib-1', code: 'CRS-0001', name: '新员工入职通识培训', owner_dept_id: 'dept-b', owner_dept_name: '技术部', description: '公司制度、企业文化与办公系统入门', suitable_members: '全部', perm_dept_ids: '', perm_user_ids: '', materials: [{ mid: 'm-11', name: '入职通识手册.pptx', size: 839680, file_key: 'fk-11', knowledge_id: 'kb-lib1', origin: 'upload', created_at: '' }, { mid: 'm-12', name: '员工手册速查.pdf', size: 402112, file_key: 'fk-12', knowledge_id: '', origin: 'upload', created_at: '' }], category: '企业文化与制度类', type: 'required', mode: 'online', lecturer_id: 'u-m1', hours: 2, material_name: '入职通识手册.pptx', file_name: '员工手册速查.pdf', file_size: 402112, knowledge_id: 'kb-lib1', question_bank_count: 1, verify_status: 'confirmed', publish_status: 'published', lecturer_name: '', created_at: month(-3, 1), updated_at: month(0, 2) }, { id: 'lib-2', code: 'CRS-0002', name: '冲压设备安全操作实操', owner_dept_id: 'dept-a', owner_dept_name: '冲压车间', description: '冲压机安全操作与应急处置实操训练', suitable_members: '冲压车间', perm_dept_ids: 'dept-a', perm_user_ids: '', materials: [{ mid: 'm-21', name: '安全操作规程.docx', size: 512000, file_key: 'fk-21', knowledge_id: '', origin: 'upload', created_at: '' }], category: '安全与健康类', type: 'required', mode: 'offline', lecturer_id: 'u-m2', hours: 4, material_name: '安全操作规程.docx、实操考核表.xlsx', file_name: '安全操作规程.docx', file_size: 512000, question_bank_count: 1, verify_status: 'pending', publish_status: 'draft', lecturer_name: '', created_at: month(-2, 5), updated_at: month(-1, 8) }, { id: 'lib-3', code: 'CRS-0003', name: 'TS16949 质量体系知识', owner_dept_id: '', owner_dept_name: '', description: 'IATF 16949 体系条款与内审要点', suitable_members: '品质岗', perm_dept_ids: '', perm_user_ids: '', materials: [], category: '专业技能类', type: 'elective', mode: 'online', lecturer_id: '', lecturer_external: '王顾问', hours: 3, material_name: '', file_name: '', file_size: 0, question_bank_count: 0, verify_status: 'pending', publish_status: 'draft', lecturer_name: '', created_at: month(-1, 12), updated_at: month(-1, 12) }, ] // 课程管理 · 试题管理(000153):题库与题目演示数据(编号 QB-####) const QUESTION_BANKS_MOCK = [ { id: 'b1', code: 'QB-0001', name: '新员工入职通识题库', dept_id: '', course_id: '', library_course_id: 'lib-1', knowledge_id: '', question_count: 2, created_at: month(0, 3), updated_at: month(0, 3) }, { id: 'b2', code: 'QB-0002', name: '冲压安全操作题库', dept_id: '', course_id: '', library_course_id: 'lib-2', knowledge_id: '', question_count: 1, created_at: month(0, 6), updated_at: month(0, 6) }, ] const QUESTIONS_MOCK: Record = { b1: [ { id: 'q1', bank_id: 'b1', seq_no: 1, type: 'single', stem: '公司带薪年休假的天数由什么确定?', options: ['A. 入职年限', 'B. 累计工作年限', 'C. 岗位等级', 'D. 部门规定'], answer: 'B', score: 5, difficulty: 2, knowledge_point: '考勤休假', analysis: '' }, { id: 'q2', bank_id: 'b1', seq_no: 2, type: 'multiple', stem: '入职引导包含哪些内容?', options: ['A. 企业文化', 'B. 安全规范', 'C. 办公系统', 'D. 薪酬谈判'], answer: 'ABC', score: 5, difficulty: 3, knowledge_point: '入职引导', analysis: '' }, ], b2: [ { id: 'q3', bank_id: 'b2', seq_no: 1, type: 'judge', stem: '冲压机双手启动按钮可以短接使用。', options: ['A. 对', 'B. 错'], answer: 'B', score: 5, difficulty: 1, knowledge_point: '安全操作规范', analysis: '严禁短接安全装置。' }, ], } // 规则配置(配置中心):预览 harness 回课程分类字典与职称角色字典, // 其余键缺省由前端 DEFAULT_RULE_VALUES 打底 const RULE_CONFIGS_MOCK = [ { rule_key: 'course_category_dict', rule_value: { categories: ['专业技能类', '企业文化与制度类', '通用技能类', '安全与健康类', '管理领导类', '行业与产品知识类'] }, updated_by: '', updated_at: month(0, 1), }, { rule_key: 'role_dict', rule_value: { roles: [ { key: 'hr', label: '人事', short: '人事', system: true }, { key: 'supervisor', label: '课长', short: '课长', system: true }, { key: 'lecturer', label: '讲师', short: '讲师', system: true }, { key: 'exec', label: '经理', short: '经理', system: true, inherits: ['supervisor'] }, { key: 'super_admin', label: '超级管理员', short: '超管', system: true, inherits: ['hr', 'supervisor', 'lecturer', 'exec'], }, ], }, updated_by: '', updated_at: month(0, 1), }, ] // 配置中心 · 导入模板元数据(harness 固定展示内置默认;上传/删除不落库,刷新即还原) const TEMPLATE_METAS = [ { template_key: 'demand_collection', file_name: '教育训练需求表模板.xlsx', file_size: 7369, updated_at: '', updated_by: '', source: 'default', }, { template_key: 'question_bank', file_name: '部门培训课程试题(题库导入版)模板.xlsx', file_size: 29405, updated_at: '', updated_by: '', source: 'default', }, { template_key: 'course_library', file_name: '课程管理导入模板.xlsx', file_size: 16593, updated_at: '', updated_by: '', source: 'default', }, ] // 返回 { matched, body };未匹配返回 null 由 vite 放行 export function resolveTrainingMock(method: string, url: string): { status: number; body: unknown } | null { const ok = (data: unknown) => ({ status: 200, body: { success: true, data } }) if (!url.startsWith('/api/v1/training/')) { // 知识库文档列表(课程管理「从知识库选择课件」用,预览演示数据) if (url.startsWith('/api/v1/knowledge-bases/') && url.includes('/knowledge')) { return ok([ { id: 'kbdoc-1', title: '入职通识手册', file_name: '入职通识手册.pptx' }, { id: 'kbdoc-2', title: '安全操作规程', file_name: '安全操作规程.docx' }, { id: 'kbdoc-3', title: 'IATF16949 体系要点', file_name: 'IATF16949体系要点.pdf' }, ]) } return null } // 模板二进制下载由 vite 配置里的中间件直接回文件,不经过本函数 if (url === '/api/v1/training/templates' || url.endsWith('/templates')) { if (method === 'GET') return ok(TEMPLATE_METAS) return ok(TEMPLATE_METAS[0]) } if (method === 'GET') { if (url.includes('/depts')) return ok(TRAINING_MOCK.depts) // 规则配置(配置中心):课程分类字典 + 职称角色字典 if (url.includes('/rule-configs')) return ok(RULE_CONFIGS_MOCK) // 系统默认知识库(课件/题库)摘要 if (url.includes('/knowledge-bases')) { return ok({ courseware: { id: 'kb-courseware', name: '企业培训(课件)', source: 'training_courseware' }, question_bank: { id: 'kb-question', name: '企业培训(题库)', source: 'training_question_bank' }, }) } // 课程管理 · 试题维护(000153):课程条目题库列表 / 题库题目列表,须先于 // /course-library、/question-banks 通用匹配 if (url.includes('/question-banks/') && url.includes('/questions')) { const bankId = url.split('/question-banks/')[1]?.split('/')[0] || '' return ok(QUESTIONS_MOCK[bankId] || []) } if (url.includes('/course-library/') && url.includes('/question-banks')) { const courseId = url.split('/course-library/')[1]?.split('/')[0] || '' return ok(QUESTION_BANKS_MOCK.filter((b) => !courseId || b.library_course_id === courseId)) } // 课程管理列表(月培训计划「课程名称」数据源) if (url.includes('/course-library')) return ok({ items: COURSE_LIBRARY_MOCK, total: COURSE_LIBRARY_MOCK.length }) // 学习任务:/learning-tasks/all 为管理端课程学习情况,须先于 /learning-tasks 匹配 if (url.includes('/learning-tasks/all')) return ok(TRAINING_MOCK.courseLearning) if (url.includes('/learning-tasks')) return ok(TRAINING_MOCK.myTasks) if (url.includes('/ai-analysis')) { return ok({ ...TRAINING_MOCK.aiAnalysis, generated_at: new Date().toISOString() }) } // 考试:/exam-records/my-list、/exam-records/my 须先于 /exam-records 匹配 if (url.includes('/exam-records/my-list')) return ok(TRAINING_MOCK.examRecords) if (url.includes('/exam-records/my')) return ok({ record: TRAINING_MOCK.examRecords[0], passed: true }) if (url.includes('/exam-records')) return ok(TRAINING_MOCK.examRecords) if (url.includes('/wrong-book')) return ok(TRAINING_MOCK.wrongBook) if (url.includes('/profile/me')) return ok(TRAINING_MOCK.profile) if (url.includes('/enrollments')) return ok(TRAINING_MOCK.enrollments) if (url.includes('/sign-records')) return ok(TRAINING_MOCK.signRecords) if (url.includes('/papers')) return ok(TRAINING_MOCK.papers) if (url.includes('/question-banks')) return ok({ items: [], total: 0 }) // 我的档案(/members/me)须先于成员列表(/members)匹配 if (url.includes('/members/me')) { return ok({ id: 'me', tenant_id: 1, user_id: 'u1', employee_no: 'A1024', dept_id: 'dept-b', post: '高级产品经理', roles: ['trainee'], lecturer_rate: 0, status: 'active' }) } if (url.includes('/members')) return ok({ items: TRAINING_MOCK.members, total: TRAINING_MOCK.members.length }) if (url.includes('/dashboards/hr')) return ok(TRAINING_MOCK.hrDashboard) if (url.includes('/dashboards')) return ok({}) if (url.includes('/courses')) return ok({ items: TRAINING_MOCK.courses, total: TRAINING_MOCK.courses.length }) if (url.includes('/sessions')) return ok(TRAINING_MOCK.sessions) // 年度需求收集:/demands/years 须先于 /demands 匹配(预览无历史数据,年份回当前年) if (url.includes('/demands/years')) return ok([NOW.getFullYear()]) if (url.includes('/demands')) return ok({ items: TRAINING_MOCK.demands, total: TRAINING_MOCK.demands.length }) return ok(null) } // POST/DELETE(快速建课/发布/课件登记/试题维护)统一回成功;单题保存回显入参题目 if (url.includes('/question-banks/') && url.includes('/questions')) { return ok({ id: `q-new-${Date.now()}`, seq_no: 0 }) } // 课件管理抽屉:上传/知识库挂接/移除回显对应课程条目并模拟文件字段变更 // (000164 多课件:上传/挂接追加条目,移除按 mid 或最新一条) if (url.includes('/course-library/') && url.includes('/material/remove')) { const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/`)) if (course) { const list = course.materials || [] list.pop() course.materials = list const latest = list[list.length - 1] course.file_name = latest?.name || '' course.file_size = latest?.size || 0 course.knowledge_id = latest?.knowledge_id || '' course.verify_status = 'pending' } return ok(course || { id: `c-new-${Date.now()}` }) } if (url.includes('/course-library/') && url.includes('/material')) { const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/`)) if (course) { const entry = { mid: `m-${Date.now()}`, name: '预览课件.pdf', size: 1024 * 820, file_key: 'fk-new', knowledge_id: '', origin: 'upload', created_at: new Date().toISOString() } course.materials = [...(course.materials || []), entry] course.file_name = entry.name course.file_size = entry.size course.verify_status = 'pending' } return ok(course || { id: `c-new-${Date.now()}` }) } if (url.includes('/course-library/') && url.includes('/question-banks/import')) { return ok({ id: `b-new-${Date.now()}`, code: `QB-${String(QUESTION_BANKS_MOCK.length + 1).padStart(4, '0')}`, name: '新导入题库', question_count: 5 }) } // 审核(000163:审核即发布):pending → confirmed + published(有课件时) // (预览 harness 不解析请求体,对全部 pending 条目生效) if (url.includes('/course-library/verify')) { let verified = 0 let autoPublished = 0 const unpublished: string[] = [] for (const course of COURSE_LIBRARY_MOCK) { if (course.verify_status !== 'pending') continue course.verify_status = 'confirmed' verified += 1 if (course.file_name || course.knowledge_id) { course.publish_status = 'published' autoPublished += 1 } else { unpublished.push(course.name) } } return ok({ verified, skipped: 0, auto_published: autoPublished, unpublished }) } // 下线(000163:下线后从和信课程撤回,计划存量行保留) if (url.includes('/course-library/') && url.includes('/offline')) { const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/offline`)) if (course) course.publish_status = 'offline' return ok(course || { id: `c-new-${Date.now()}` }) } if (url.includes('/course-library/') && url.includes('/publish')) { const course = COURSE_LIBRARY_MOCK.find((c) => url.includes(`/course-library/${c.id}/publish`)) if (course) course.publish_status = 'published' return ok(course || { id: `c-new-${Date.now()}` }) } return ok({ id: `c-new-${Date.now()}` }) }