Files
online_sys/frontend_财经商贸/updateProjectLibrary.mjs
KQL a7242f0c69 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>
2025-12-12 18:16:55 +08:00

72 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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} 个项目`);
});