mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-03 18:39:23 +08:00
1. AI 分析与超时处理优化 - feat: 完善 API 超时机制,前端增加 130s 安全兜底,防止前端超时导致保存失败 2. 错题管理增强 - feat: 实现错题列表多选批量删除功能 3. 标签与学科系统扩展 - feat: 新增语文、历史、地理、政治等学科的标签框架数据支持 - chore: 清理已废弃的 custom-tags 相关代码 4. 错题详情页面的布局优化 - feat: 优化PC场景下详情页面,避免公式过长导致页面覆盖 5. AI 分析保存页面多次点击保存优化 - fix: 解决分析保存页面多次点击保存生成重复错题的问题
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
/**
|
|
* 额外学科(语文、历史、地理、政治)标签导入脚本
|
|
* 仅导入年级结构,以支持自定义标签的年级选择
|
|
*
|
|
* 使用方法: npx tsx scripts/seed-additional-subjects.ts
|
|
*/
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
import { CHINESE_CURRICULUM, CHINESE_GRADE_ORDER } from '../src/lib/tag-data/chinese';
|
|
import { HISTORY_CURRICULUM, HISTORY_GRADE_ORDER } from '../src/lib/tag-data/history';
|
|
import { GEOGRAPHY_CURRICULUM, GEOGRAPHY_GRADE_ORDER } from '../src/lib/tag-data/geography';
|
|
import { POLITICS_CURRICULUM, POLITICS_GRADE_ORDER } from '../src/lib/tag-data/politics';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function seedSubject(
|
|
subjectKey: string,
|
|
subjectName: string,
|
|
curriculum: Record<string, any[]>,
|
|
gradeOrder: Record<string, number>
|
|
) {
|
|
console.log(`\n📚 处理学科: ${subjectName} (${subjectKey})`);
|
|
|
|
// 清空现有系统标签
|
|
console.log(` 🗑️ 清空现有系统标签...`);
|
|
await prisma.knowledgeTag.deleteMany({
|
|
where: { isSystem: true, subject: subjectKey }
|
|
});
|
|
|
|
let count = 0;
|
|
for (const [gradeSemester, _] of Object.entries(curriculum)) {
|
|
// 创建年级节点
|
|
await prisma.knowledgeTag.create({
|
|
data: {
|
|
name: gradeSemester,
|
|
subject: subjectKey,
|
|
parentId: null,
|
|
isSystem: true,
|
|
order: gradeOrder[gradeSemester] || 99,
|
|
},
|
|
});
|
|
count++;
|
|
}
|
|
console.log(` ✅ ${subjectName} 年级节点创建完成: ${count} 个`);
|
|
}
|
|
|
|
async function main() {
|
|
console.log('🚀 开始导入额外学科标签结构...');
|
|
|
|
await seedSubject('chinese', '语文', CHINESE_CURRICULUM, CHINESE_GRADE_ORDER);
|
|
await seedSubject('history', '历史', HISTORY_CURRICULUM, HISTORY_GRADE_ORDER);
|
|
await seedSubject('geography', '地理', GEOGRAPHY_CURRICULUM, GEOGRAPHY_GRADE_ORDER);
|
|
await seedSubject('politics', '政治', POLITICS_CURRICULUM, POLITICS_GRADE_ORDER);
|
|
|
|
console.log('\n✨ 所有额外学科标签导入完成!');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('❌ 导入失败:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|