96 lines
3.1 KiB
JavaScript
96 lines
3.1 KiB
JavaScript
|
|
const fs = require('fs');
|
|||
|
|
|
|||
|
|
// 读取智能开发项目案例数据
|
|||
|
|
const projectData = JSON.parse(
|
|||
|
|
fs.readFileSync('./网页未导入数据/智能开发产业/智能开发项目案例.json', 'utf-8')
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
console.log(`找到 ${projectData.length} 个智能开发项目案例`);
|
|||
|
|
|
|||
|
|
// 转换为项目库页面需要的格式
|
|||
|
|
const projects = projectData.map((item, index) => {
|
|||
|
|
// 解析对应岗位
|
|||
|
|
const positions = item['对应个人简历名称']
|
|||
|
|
? item['对应个人简历名称'].split(',').map(p => p.trim())
|
|||
|
|
: [];
|
|||
|
|
|
|||
|
|
// 确定单元名称(优先使用垂直能力课,其次复合能力课)
|
|||
|
|
const unit = item['对应单元名称(垂直能力课)'] || item['对应单元名称(复合能力课)'] || '';
|
|||
|
|
|
|||
|
|
// 确定项目类别和方向
|
|||
|
|
const direction = item['所属垂直方向'] || '智能开发';
|
|||
|
|
const directionMap = {
|
|||
|
|
'AI智能应用开发': 'AI应用开发',
|
|||
|
|
'网络安全': '网络安全',
|
|||
|
|
'AI大前端开发': '前端开发',
|
|||
|
|
'AIOps智能运维': '智能运维'
|
|||
|
|
};
|
|||
|
|
const category = directionMap[direction] || direction;
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
id: index + 1,
|
|||
|
|
name: item['案例名称'],
|
|||
|
|
description: direction,
|
|||
|
|
positions: positions,
|
|||
|
|
unit: unit,
|
|||
|
|
direction: direction,
|
|||
|
|
category: category,
|
|||
|
|
// 保留项目详情内容
|
|||
|
|
projectDetail: item['项目案例内容'] || ''
|
|||
|
|
};
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 读取现有的projectLibraryMock.js文件
|
|||
|
|
const mockFilePath = './src/mocks/projectLibraryMock.js';
|
|||
|
|
let mockFileContent = fs.readFileSync(mockFilePath, 'utf-8');
|
|||
|
|
|
|||
|
|
// 只替换projects数组部分
|
|||
|
|
const projectsStr = JSON.stringify(projects, null, 4);
|
|||
|
|
|
|||
|
|
// 找到projects数组的开始和结束位置
|
|||
|
|
const projectsStartPattern = /const projects = \[/;
|
|||
|
|
const projectsEndPattern = /\];\s*\/\/ 搜索过滤/;
|
|||
|
|
|
|||
|
|
const startMatch = mockFileContent.match(projectsStartPattern);
|
|||
|
|
const endMatch = mockFileContent.match(projectsEndPattern);
|
|||
|
|
|
|||
|
|
if (startMatch && endMatch) {
|
|||
|
|
const startIndex = startMatch.index;
|
|||
|
|
const endIndex = mockFileContent.indexOf('];', startIndex) + 2;
|
|||
|
|
|
|||
|
|
// 构建新的projects部分
|
|||
|
|
const newProjectsSection = `const projects = ${projectsStr};`;
|
|||
|
|
|
|||
|
|
// 替换内容
|
|||
|
|
mockFileContent =
|
|||
|
|
mockFileContent.substring(0, startIndex) +
|
|||
|
|
newProjectsSection +
|
|||
|
|
mockFileContent.substring(endIndex);
|
|||
|
|
|
|||
|
|
// 写入文件
|
|||
|
|
fs.writeFileSync(mockFilePath, mockFileContent, 'utf-8');
|
|||
|
|
|
|||
|
|
console.log('✅ 班级项目库数据更新成功!');
|
|||
|
|
console.log(`- 共更新 ${projects.length} 个项目`);
|
|||
|
|
|
|||
|
|
// 统计信息
|
|||
|
|
const categoryCount = {};
|
|||
|
|
projects.forEach(p => {
|
|||
|
|
categoryCount[p.category] = (categoryCount[p.category] || 0) + 1;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log('\n项目类别统计:');
|
|||
|
|
Object.entries(categoryCount).forEach(([cat, count]) => {
|
|||
|
|
console.log(` ${cat}: ${count}个`);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log('\n前5个项目示例:');
|
|||
|
|
projects.slice(0, 5).forEach((p, i) => {
|
|||
|
|
console.log(` ${i+1}. ${p.name}`);
|
|||
|
|
console.log(` 单元: ${p.unit}`);
|
|||
|
|
console.log(` 方向: ${p.direction}`);
|
|||
|
|
console.log(` 岗位: ${p.positions.slice(0, 3).join(', ')}`);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
console.error('❌ 未找到projects数组位置,请检查文件格式');
|
|||
|
|
}
|