88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
|
|
const fs = require('fs');
|
|||
|
|
|
|||
|
|
// 读取智能开发项目案例数据
|
|||
|
|
const smartDevProjects = JSON.parse(
|
|||
|
|
fs.readFileSync('网页未导入数据/智能开发产业/智能开发项目案例.json', 'utf-8')
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// 构建新的映射数据
|
|||
|
|
let mappingContent = `// 项目案例对应单元映射数据
|
|||
|
|
// 基于智能开发产业项目案例
|
|||
|
|
|
|||
|
|
export const projectUnitsMapping = {
|
|||
|
|
`;
|
|||
|
|
|
|||
|
|
smartDevProjects.forEach((project, index) => {
|
|||
|
|
const projectName = project['项目名称'];
|
|||
|
|
|
|||
|
|
// 获取复合能力课和垂直能力课
|
|||
|
|
const compoundUnits = project['对应单元']?.['复合能力课'] || [];
|
|||
|
|
const verticalUnits = project['对应单元']?.['垂直能力课'] || [];
|
|||
|
|
|
|||
|
|
mappingContent += ` "${projectName}": {
|
|||
|
|
"compoundUnits": [
|
|||
|
|
${compoundUnits.map(unit => ` "${unit}"`).join(',\n')}
|
|||
|
|
],
|
|||
|
|
"verticalUnits": [
|
|||
|
|
${verticalUnits.map(unit => ` "${unit}"`).join(',\n')}
|
|||
|
|
]
|
|||
|
|
}`;
|
|||
|
|
|
|||
|
|
if (index < smartDevProjects.length - 1) {
|
|||
|
|
mappingContent += ',\n';
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
mappingContent += `
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 获取项目的复合能力课程
|
|||
|
|
export const getCompoundUnits = (projectTitle) => {
|
|||
|
|
if (!projectTitle) return [];
|
|||
|
|
|
|||
|
|
// 直接匹配
|
|||
|
|
if (projectUnitsMapping[projectTitle]) {
|
|||
|
|
return projectUnitsMapping[projectTitle].compoundUnits || [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 尝试去除后缀后匹配(如"详情")
|
|||
|
|
const cleanTitle = projectTitle.replace(/详情$/, '');
|
|||
|
|
if (projectUnitsMapping[cleanTitle]) {
|
|||
|
|
return projectUnitsMapping[cleanTitle].compoundUnits || [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return [];
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 获取项目的垂直能力课程
|
|||
|
|
export const getVerticalUnits = (projectTitle) => {
|
|||
|
|
if (!projectTitle) return [];
|
|||
|
|
|
|||
|
|
// 直接匹配
|
|||
|
|
if (projectUnitsMapping[projectTitle]) {
|
|||
|
|
return projectUnitsMapping[projectTitle].verticalUnits || [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 尝试去除后缀后匹配(如"详情")
|
|||
|
|
const cleanTitle = projectTitle.replace(/详情$/, '');
|
|||
|
|
if (projectUnitsMapping[cleanTitle]) {
|
|||
|
|
return projectUnitsMapping[cleanTitle].verticalUnits || [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return [];
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 获取项目的所有对应单元
|
|||
|
|
export const getProjectUnits = (projectTitle) => {
|
|||
|
|
const compoundUnits = getCompoundUnits(projectTitle);
|
|||
|
|
const verticalUnits = getVerticalUnits(projectTitle);
|
|||
|
|
return [...compoundUnits, ...verticalUnits];
|
|||
|
|
};
|
|||
|
|
`;
|
|||
|
|
|
|||
|
|
// 写入文件
|
|||
|
|
fs.writeFileSync('src/data/projectUnitsMapping.js', mappingContent);
|
|||
|
|
|
|||
|
|
console.log('✅ projectUnitsMapping.js 已更新为智能开发项目数据!');
|
|||
|
|
console.log(`- 包含 ${smartDevProjects.length} 个项目的单元映射`);
|
|||
|
|
console.log('- 保留了原有的函数结构');
|