主要更新: - 更新所有12个产业的教务系统数据和功能 - 删除所有 node_modules 文件夹(节省3.7GB) - 删除所有 .yoyo 缓存文件夹(节省1.2GB) - 删除所有 dist 构建文件(节省55MB) 项目优化: - 项目大小从 8.1GB 减少到 3.2GB(节省60%空间) - 保留完整的源代码和配置文件 - .gitignore 已配置,防止再次提交大文件 启动脚本: - start-industry.sh/bat/ps1 脚本会自动检测并安装依赖 - 首次启动时自动运行 npm install - 支持单个或批量启动产业系统 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
215 lines
5.6 KiB
JavaScript
215 lines
5.6 KiB
JavaScript
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
// 读取必要的文件
|
||
const calendarPath = path.join(__dirname, 'src/data/calendarCourses.json');
|
||
const posterMappingPath = path.join(__dirname, 'homework_poster_mapping.json');
|
||
const mockDataPath = path.join(__dirname, 'src/data/mockData.js');
|
||
|
||
const calendarData = JSON.parse(fs.readFileSync(calendarPath, 'utf-8'));
|
||
const posterMapping = JSON.parse(fs.readFileSync(posterMappingPath, 'utf-8'));
|
||
let mockDataContent = fs.readFileSync(mockDataPath, 'utf-8');
|
||
|
||
// 需要排除的单元名称
|
||
const excludedUnits = ['岗位体系认知', '产业认知课', '职业规划课'];
|
||
|
||
// 按单元组织课程
|
||
const compoundUnitMap = new Map();
|
||
const verticalUnitMap = new Map();
|
||
|
||
calendarData.forEach(day => {
|
||
const unitName = day['❌查询单元名称'] || '';
|
||
|
||
// 跳过排除的单元
|
||
if (excludedUnits.includes(unitName)) {
|
||
return;
|
||
}
|
||
|
||
// 复合技能课程
|
||
if (day['复合技能阶段'] && day['复合技能阶段'].trim()) {
|
||
const courseName = day['复合技能阶段'].trim();
|
||
|
||
// 跳过"单元小结"
|
||
if (courseName === '单元小结') {
|
||
return;
|
||
}
|
||
|
||
// 只处理有海报的课程
|
||
const imageUrl = posterMapping[courseName];
|
||
if (!imageUrl) {
|
||
return;
|
||
}
|
||
|
||
if (!compoundUnitMap.has(unitName)) {
|
||
compoundUnitMap.set(unitName, []);
|
||
}
|
||
|
||
const unit = compoundUnitMap.get(unitName);
|
||
if (!unit.some(c => c.name === courseName)) {
|
||
unit.push({
|
||
id: 0, // 稍后重新编号
|
||
name: courseName,
|
||
level: 'completed',
|
||
imageUrl: imageUrl
|
||
});
|
||
}
|
||
}
|
||
|
||
// 垂直方向课程
|
||
if (day['垂直方向阶段(方向二:商业活动策划)'] && day['垂直方向阶段(方向二:商业活动策划)'].trim()) {
|
||
const courseName = day['垂直方向阶段(方向二:商业活动策划)'].trim();
|
||
|
||
// 跳过"单元小结"
|
||
if (courseName === '单元小结') {
|
||
return;
|
||
}
|
||
|
||
// 只处理有海报的课程
|
||
const imageUrl = posterMapping[courseName];
|
||
if (!imageUrl) {
|
||
return;
|
||
}
|
||
|
||
if (!verticalUnitMap.has(unitName)) {
|
||
verticalUnitMap.set(unitName, []);
|
||
}
|
||
|
||
const unit = verticalUnitMap.get(unitName);
|
||
if (!unit.some(c => c.name === courseName)) {
|
||
unit.push({
|
||
id: 0,
|
||
name: courseName,
|
||
level: 'completed',
|
||
imageUrl: imageUrl
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
// 重新编号ID
|
||
let currentId = 1;
|
||
compoundUnitMap.forEach((courses) => {
|
||
courses.forEach(course => {
|
||
course.id = currentId++;
|
||
});
|
||
});
|
||
|
||
verticalUnitMap.forEach((courses) => {
|
||
courses.forEach(course => {
|
||
course.id = currentId++;
|
||
});
|
||
});
|
||
|
||
// 生成units结构
|
||
const compoundUnits = [];
|
||
compoundUnitMap.forEach((courses, unitName) => {
|
||
if (unitName && courses.length > 0) {
|
||
compoundUnits.push({
|
||
name: unitName,
|
||
courses: courses
|
||
});
|
||
}
|
||
});
|
||
|
||
const verticalUnits = [];
|
||
verticalUnitMap.forEach((courses, unitName) => {
|
||
if (unitName && courses.length > 0) {
|
||
// 特殊处理:展会主题与品牌定位设置isShowCase
|
||
courses.forEach(course => {
|
||
if (course.name === '展会主题与品牌定位') {
|
||
course.isShowCase = true;
|
||
}
|
||
});
|
||
|
||
verticalUnits.push({
|
||
name: unitName,
|
||
courses: courses
|
||
});
|
||
}
|
||
});
|
||
|
||
console.log('===== 生成的homework结构 =====');
|
||
console.log(`复合能力课 - 单元数: ${compoundUnits.length}`);
|
||
compoundUnits.forEach(unit => {
|
||
console.log(` - ${unit.name}: ${unit.courses.length}个课程`);
|
||
});
|
||
|
||
console.log(`\n垂直能力课 - 单元数: ${verticalUnits.length}`);
|
||
verticalUnits.forEach(unit => {
|
||
console.log(` - ${unit.name}: ${unit.courses.length}个课程`);
|
||
});
|
||
|
||
console.log('\n总课程数:',
|
||
compoundUnits.reduce((sum, u) => sum + u.courses.length, 0) +
|
||
verticalUnits.reduce((sum, u) => sum + u.courses.length, 0)
|
||
);
|
||
|
||
// 生成新的homework数组JavaScript代码
|
||
const generateCourseString = (course) => {
|
||
let str = `{ id: ${course.id}, name: "${course.name}", level: "${course.level}"`;
|
||
if (course.imageUrl) {
|
||
str += `, imageUrl: "${course.imageUrl}"`;
|
||
}
|
||
if (course.isShowCase) {
|
||
str += `, isShowCase: true`;
|
||
}
|
||
str += ' }';
|
||
return str;
|
||
};
|
||
|
||
const generateUnitsString = (units) => {
|
||
return units.map(unit => ` {
|
||
name: "${unit.name}",
|
||
courses: [
|
||
${unit.courses.map(c => ' ' + generateCourseString(c)).join(',\n')}
|
||
]
|
||
}`).join(',\n');
|
||
};
|
||
|
||
// 生成list字段 - 所有课程的扁平化列表
|
||
const generateListString = (units) => {
|
||
const allCourses = [];
|
||
units.forEach(unit => {
|
||
allCourses.push(...unit.courses);
|
||
});
|
||
return allCourses.map(c => ' ' + generateCourseString(c)).join(',\n');
|
||
};
|
||
|
||
const compoundList = generateListString(compoundUnits);
|
||
const verticalList = generateListString(verticalUnits);
|
||
|
||
const newHomeworkCode = ` homework: [
|
||
{
|
||
name: "复合能力课",
|
||
id: 1,
|
||
units: [
|
||
${generateUnitsString(compoundUnits)}
|
||
],
|
||
list: [
|
||
${compoundList}
|
||
]
|
||
},
|
||
{
|
||
name: "垂直能力课",
|
||
id: 2,
|
||
units: [
|
||
${generateUnitsString(verticalUnits)}
|
||
],
|
||
list: [
|
||
${verticalList}
|
||
]
|
||
}
|
||
],`;
|
||
|
||
// 替换原来的homework数据
|
||
const homeworkPattern = /homework:\s*\[[\s\S]*?\],\s*\/\/ 1v1定制求职策略数据/;
|
||
|
||
if (homeworkPattern.test(mockDataContent)) {
|
||
mockDataContent = mockDataContent.replace(homeworkPattern, newHomeworkCode + '\n // 1v1定制求职策略数据');
|
||
|
||
fs.writeFileSync(mockDataPath, mockDataContent, 'utf-8');
|
||
console.log('\n✅ mockData.js已成功更新!');
|
||
} else {
|
||
console.error('\n❌ 无法找到homework数据结构,更新失败!');
|
||
}
|