Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
104
frontend_财经商贸/updateProjectUnitsMapping.mjs
Normal file
104
frontend_财经商贸/updateProjectUnitsMapping.mjs
Normal file
@@ -0,0 +1,104 @@
|
||||
import fs from 'fs';
|
||||
|
||||
// 读取财经商贸项目案例数据
|
||||
const caseData = JSON.parse(fs.readFileSync('网页未导入数据/财经商贸产业/财经商贸项目案例.json', 'utf8'));
|
||||
|
||||
// 读取现有的映射文件
|
||||
let mappingContent = fs.readFileSync('src/data/projectUnitsMapping.js', 'utf8');
|
||||
|
||||
// 构建财经商贸项目单元映射
|
||||
const financeMapping = {};
|
||||
|
||||
caseData.slice(0, 20).forEach(item => {
|
||||
const projectName = item['案例名称'];
|
||||
const verticalUnit = item['对应单元名称(垂直能力课)'];
|
||||
const compoundUnit = item['对应单元名称(复合能力课)'];
|
||||
|
||||
financeMapping[projectName] = {
|
||||
compoundUnits: compoundUnit ? [compoundUnit] : [],
|
||||
verticalUnits: verticalUnit ? [verticalUnit] : []
|
||||
};
|
||||
});
|
||||
|
||||
// 生成新的映射对象字符串
|
||||
const newMappingStr = JSON.stringify(financeMapping, null, 2)
|
||||
.replace(/"([^"]+)":/g, ' "$1":')
|
||||
.replace(/"/g, '"');
|
||||
|
||||
// 查找现有的智能制造映射部分
|
||||
const existingMappingStart = mappingContent.indexOf('export const projectUnitsMapping = {');
|
||||
const existingMappingEnd = mappingContent.indexOf('};', existingMappingStart) + 2;
|
||||
|
||||
// 构建新的完整映射文件内容
|
||||
const newContent = `// 项目案例对应单元映射数据 - 财经商贸
|
||||
// 基于 网页未导入数据/财经商贸产业/财经商贸项目案例.json
|
||||
|
||||
export const projectUnitsMapping = ${newMappingStr};
|
||||
|
||||
// 获取项目的复合能力课程
|
||||
export const getCompoundUnits = (projectTitle) => {
|
||||
if (!projectTitle) return [];
|
||||
|
||||
// 直接匹配
|
||||
if (projectUnitsMapping[projectTitle]) {
|
||||
return projectUnitsMapping[projectTitle].compoundUnits || [];
|
||||
}
|
||||
|
||||
// 模糊匹配(包含关系)
|
||||
const keys = Object.keys(projectUnitsMapping);
|
||||
for (const key of keys) {
|
||||
if (projectTitle.includes(key) || key.includes(projectTitle)) {
|
||||
return projectUnitsMapping[key].compoundUnits || [];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
// 获取项目的垂直能力课程
|
||||
export const getVerticalUnits = (projectTitle) => {
|
||||
if (!projectTitle) return [];
|
||||
|
||||
// 直接匹配
|
||||
if (projectUnitsMapping[projectTitle]) {
|
||||
return projectUnitsMapping[projectTitle].verticalUnits || [];
|
||||
}
|
||||
|
||||
// 模糊匹配(包含关系)
|
||||
const keys = Object.keys(projectUnitsMapping);
|
||||
for (const key of keys) {
|
||||
if (projectTitle.includes(key) || key.includes(projectTitle)) {
|
||||
return projectUnitsMapping[key].verticalUnits || [];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
// 获取项目的所有对应单元
|
||||
export const getProjectUnits = (projectTitle) => {
|
||||
const compoundUnits = getCompoundUnits(projectTitle);
|
||||
const verticalUnits = getVerticalUnits(projectTitle);
|
||||
return [...compoundUnits, ...verticalUnits];
|
||||
};`;
|
||||
|
||||
// 写入文件
|
||||
fs.writeFileSync('src/data/projectUnitsMapping.js', newContent, 'utf8');
|
||||
|
||||
console.log('项目单元映射已更新为财经商贸数据!');
|
||||
console.log(`共添加了 ${Object.keys(financeMapping).length} 个项目的单元映射`);
|
||||
|
||||
// 显示单元统计
|
||||
const allVerticalUnits = new Set();
|
||||
const allCompoundUnits = new Set();
|
||||
|
||||
Object.values(financeMapping).forEach(mapping => {
|
||||
mapping.verticalUnits.forEach(unit => allVerticalUnits.add(unit));
|
||||
mapping.compoundUnits.forEach(unit => allCompoundUnits.add(unit));
|
||||
});
|
||||
|
||||
console.log(`\n垂直能力课: ${allVerticalUnits.size} 种`);
|
||||
[...allVerticalUnits].forEach(unit => console.log(` - ${unit}`));
|
||||
|
||||
console.log(`\n复合能力课: ${allCompoundUnits.size} 种`);
|
||||
[...allCompoundUnits].forEach(unit => console.log(` - ${unit}`));
|
||||
Reference in New Issue
Block a user