主要更新内容: - 优化UI组件(视频播放器、HR访问模态框、岗位信息展示等) - 更新数据文件(简历、岗位、项目案例等) - 添加新的图片资源(面试状态图标等) - 新增AgentPage等页面组件 - 清理旧的备份文件,提升代码库整洁度 - 优化岗位等级和面试状态的数据结构 🤖 Generated with [Claude Code](https://claude.com/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数据结构,更新失败!');
|
||
}
|