72 lines
2.7 KiB
JavaScript
72 lines
2.7 KiB
JavaScript
|
|
import fs from 'fs';
|
|||
|
|
|
|||
|
|
// 读取财经商贸项目案例数据(只读取项目名称和分类)
|
|||
|
|
const caseData = JSON.parse(fs.readFileSync('网页未导入数据/财经商贸产业/财经商贸项目案例.json', 'utf8'));
|
|||
|
|
|
|||
|
|
// 创建项目数据映射
|
|||
|
|
const projectsData = caseData.slice(0, 20).map((item, index) => {
|
|||
|
|
// 根据所属垂直方向确定category
|
|||
|
|
let category = '国际贸易'; // 默认
|
|||
|
|
if (item['所属垂直方向'] === '国际贸易') {
|
|||
|
|
category = '国际贸易';
|
|||
|
|
} else if (item['所属垂直方向'] === '供应链管理') {
|
|||
|
|
category = '供应链管理';
|
|||
|
|
} else if (item['所属垂直方向'] === '电子商务') {
|
|||
|
|
category = '电子商务';
|
|||
|
|
} else if (item['所属垂直方向'] === '金融服务') {
|
|||
|
|
category = '金融服务';
|
|||
|
|
} else if (item['所属垂直方向'] === '企业管理基础') {
|
|||
|
|
category = '供应链管理';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取岗位列表
|
|||
|
|
const positions = item['对应个人简历名称'] ? item['对应个人简历名称'].split(',') : [];
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
id: index + 1,
|
|||
|
|
name: item['案例名称'],
|
|||
|
|
description: item['所属垂直方向'] || category,
|
|||
|
|
positions: positions,
|
|||
|
|
unit: item['对应单元名称(垂直能力课)'] || item['对应单元名称(复合能力课)'] || '',
|
|||
|
|
direction: item['所属垂直方向'] || category,
|
|||
|
|
category: category,
|
|||
|
|
content: item['项目案例内容'] || ''
|
|||
|
|
};
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 读取当前的项目库Mock数据
|
|||
|
|
const mockFilePath = 'src/mocks/projectLibraryMock.js';
|
|||
|
|
let mockContent = fs.readFileSync(mockFilePath, 'utf8');
|
|||
|
|
|
|||
|
|
// 构建新的projects数组字符串
|
|||
|
|
const projectsStr = JSON.stringify(projectsData, null, 2)
|
|||
|
|
.replace(/"id":/g, ' "id":')
|
|||
|
|
.replace(/"name":/g, ' "name":')
|
|||
|
|
.replace(/"description":/g, ' "description":')
|
|||
|
|
.replace(/"positions":/g, ' "positions":')
|
|||
|
|
.replace(/"unit":/g, ' "unit":')
|
|||
|
|
.replace(/"direction":/g, ' "direction":')
|
|||
|
|
.replace(/"category":/g, ' "category":')
|
|||
|
|
.replace(/"content":/g, ' "content":');
|
|||
|
|
|
|||
|
|
// 替换文件中的projects数组
|
|||
|
|
mockContent = mockContent.replace(
|
|||
|
|
/const projects = \[[^\]]*\];/s,
|
|||
|
|
`const projects = ${projectsStr};`
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// 写回文件
|
|||
|
|
fs.writeFileSync(mockFilePath, mockContent, 'utf8');
|
|||
|
|
|
|||
|
|
console.log('项目库已更新完成!');
|
|||
|
|
console.log(`共更新了 ${projectsData.length} 个项目`);
|
|||
|
|
|
|||
|
|
// 显示分类统计
|
|||
|
|
const categoryStats = {};
|
|||
|
|
projectsData.forEach(p => {
|
|||
|
|
categoryStats[p.category] = (categoryStats[p.category] || 0) + 1;
|
|||
|
|
});
|
|||
|
|
console.log('\n分类统计:');
|
|||
|
|
Object.entries(categoryStats).forEach(([cat, count]) => {
|
|||
|
|
console.log(` ${cat}: ${count} 个项目`);
|
|||
|
|
});
|