- 包含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>
173 lines
5.3 KiB
JavaScript
173 lines
5.3 KiB
JavaScript
import fs from 'fs';
|
|
|
|
// Read finance commerce projects data
|
|
const financeProjects = JSON.parse(
|
|
fs.readFileSync('网页未导入数据/财经商贸产业/财经商贸项目案例.json', 'utf8')
|
|
);
|
|
|
|
// Transform finance projects to match the exact structure of manufacturing projects
|
|
const transformedProjects = financeProjects.map((project, index) => ({
|
|
id: index + 1,
|
|
name: project['案例名称'],
|
|
description: project['所属垂直方向'],
|
|
positions: project['对应个人简历名称'].split(',').map(p => p.trim()),
|
|
unit: project['对应单元名称(垂直能力课)'] || project['对应单元名称(复合能力课)'],
|
|
direction: project['所属垂直方向'],
|
|
category: getCategoryFromDirection(project['所属垂直方向'])
|
|
}));
|
|
|
|
// Helper function to map direction to category
|
|
function getCategoryFromDirection(direction) {
|
|
const categoryMap = {
|
|
'国际贸易': '国际贸易',
|
|
'供应链管理': '供应链管理',
|
|
'电子商务': '电子商务'
|
|
};
|
|
return categoryMap[direction] || direction;
|
|
}
|
|
|
|
// Helper function to parse markdown content
|
|
function parseMarkdownContent(content) {
|
|
if (!content) return { overview: '', process: '', keyPoints: '' };
|
|
|
|
const lines = content.split('\n');
|
|
let overview = '';
|
|
let process = '';
|
|
let keyPoints = '';
|
|
let currentSection = '';
|
|
|
|
lines.forEach(line => {
|
|
if (line.includes('项目概述')) {
|
|
currentSection = 'overview';
|
|
} else if (line.includes('项目整体流程') || line.includes('整体流程介绍')) {
|
|
currentSection = 'process';
|
|
} else if (line.includes('关键技术点')) {
|
|
currentSection = 'keyPoints';
|
|
} else if (currentSection) {
|
|
switch(currentSection) {
|
|
case 'overview':
|
|
overview += line + '\n';
|
|
break;
|
|
case 'process':
|
|
process += line + '\n';
|
|
break;
|
|
case 'keyPoints':
|
|
keyPoints += line + '\n';
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
return {
|
|
overview: overview.trim(),
|
|
process: process.trim(),
|
|
keyPoints: keyPoints.trim()
|
|
};
|
|
}
|
|
|
|
// Generate detailed project data with positions structure
|
|
const detailedProjects = transformedProjects.map((project, index) => {
|
|
const originalProject = financeProjects[index];
|
|
const parsedContent = parseMarkdownContent(originalProject['项目案例内容']);
|
|
|
|
// Transform positions to include level
|
|
const positionsWithLevel = project.positions.map(pos => {
|
|
// Determine level based on position name
|
|
let level = '普通岗';
|
|
if (pos.includes('经理') || pos.includes('总监') || pos.includes('主管')) {
|
|
level = '储备干部岗';
|
|
} else if (pos.includes('工程师') || pos.includes('专员') || pos.includes('顾问')) {
|
|
level = '技术骨干岗';
|
|
}
|
|
|
|
return {
|
|
level: level,
|
|
position: pos
|
|
};
|
|
});
|
|
|
|
return {
|
|
id: project.id,
|
|
name: project.name,
|
|
positions: positionsWithLevel,
|
|
unit: project.unit,
|
|
overview: parsedContent.overview || originalProject['项目案例内容'].substring(0, 300),
|
|
process: parsedContent.process || '',
|
|
keyPoints: parsedContent.keyPoints || ''
|
|
};
|
|
});
|
|
|
|
// Generate the complete mock file content with proper detail function
|
|
const mockFileContent = `// 项目库Mock数据
|
|
export const getMockProjectsList = (params = {}) => {
|
|
const { search = "", page = 1, pageSize = 10 } = params;
|
|
|
|
// 完整项目列表数据
|
|
const projects = ${JSON.stringify(transformedProjects, null, 4)};
|
|
|
|
// 搜索过滤
|
|
let filteredProjects = projects;
|
|
if (search) {
|
|
filteredProjects = projects.filter(project =>
|
|
project.name.includes(search) ||
|
|
project.description.includes(search) ||
|
|
project.positions.some(pos => pos.includes(search)) ||
|
|
project.category.includes(search)
|
|
);
|
|
}
|
|
|
|
// 分页
|
|
const start = (page - 1) * pageSize;
|
|
const end = start + pageSize;
|
|
const paginatedProjects = filteredProjects.slice(start, end);
|
|
|
|
return {
|
|
success: true,
|
|
data: paginatedProjects,
|
|
total: filteredProjects.length,
|
|
page,
|
|
pageSize
|
|
};
|
|
};
|
|
|
|
// 项目详情Mock数据 - 财经商贸
|
|
export const getMockProjectDetail = (id) => {
|
|
// 直接根据ID返回对应项目的详情
|
|
const projects = ${JSON.stringify(detailedProjects, null, 4)};
|
|
|
|
const project = projects.find(p => p.id === parseInt(id));
|
|
|
|
if (!project) {
|
|
return {
|
|
success: false,
|
|
message: '项目不存在'
|
|
};
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
data: {
|
|
id: project.id,
|
|
title: project.name,
|
|
category: ${JSON.stringify(transformedProjects, null, 4)}.find(p => p.id === project.id)?.category || '',
|
|
applicablePositions: project.positions,
|
|
unit: project.unit,
|
|
overview: project.overview,
|
|
process: project.process,
|
|
keyPoints: project.keyPoints,
|
|
images: []
|
|
}
|
|
};
|
|
};
|
|
`;
|
|
|
|
// Backup existing file
|
|
const timestamp = Date.now();
|
|
const backupPath = `src/mocks/projectLibraryMock.js.backup_${timestamp}`;
|
|
fs.copyFileSync('src/mocks/projectLibraryMock.js', backupPath);
|
|
console.log(`✅ Created backup at: ${backupPath}`);
|
|
|
|
// Write the new mock file
|
|
fs.writeFileSync('src/mocks/projectLibraryMock.js', mockFileContent);
|
|
console.log('✅ Successfully fixed projectLibraryMock.js with correct data structure');
|
|
console.log('✅ Project details now return correct format with positions, overview, process, and keyPoints'); |