主要内容: - 包含12个产业的完整教务系统前端代码 - 智能启动脚本 (start-industry.sh) - 可视化产业导航页面 (index.html) - 项目文档 (README.md) 优化内容: - 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB - 添加.gitignore文件避免上传不必要的文件 - 自动依赖管理和智能启动系统 产业列表: 1. 文旅产业 (5150) 2. 智能制造 (5151) 3. 智能开发 (5152) 4. 财经商贸 (5153) 5. 视觉设计 (5154) 6. 交通物流 (5155) 7. 大健康 (5156) 8. 土木水利 (5157) 9. 食品产业 (5158) 10. 化工产业 (5159) 11. 能源产业 (5160) 12. 环保产业 (5161) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
118 lines
3.5 KiB
JavaScript
118 lines
3.5 KiB
JavaScript
const fs = require('fs');
|
||
|
||
// 读取projectLibraryMock.js文件
|
||
const mockFilePath = './src/mocks/projectLibraryMock.js';
|
||
let mockFileContent = fs.readFileSync(mockFilePath, 'utf-8');
|
||
|
||
// 找到getMockProjectDetail函数的开始
|
||
const functionStart = mockFileContent.indexOf('export const getMockProjectDetail = (id) => {');
|
||
if (functionStart === -1) {
|
||
console.error('❌ 未找到getMockProjectDetail函数');
|
||
process.exit(1);
|
||
}
|
||
|
||
// 找到函数的结束位置
|
||
let braceCount = 0;
|
||
let functionEnd = -1;
|
||
let inString = false;
|
||
let stringChar = '';
|
||
|
||
for (let i = functionStart; i < mockFileContent.length; i++) {
|
||
const char = mockFileContent[i];
|
||
const prevChar = i > 0 ? mockFileContent[i - 1] : '';
|
||
|
||
// 处理字符串
|
||
if (!inString && (char === '"' || char === "'" || char === '`')) {
|
||
inString = true;
|
||
stringChar = char;
|
||
} else if (inString && char === stringChar && prevChar !== '\\') {
|
||
inString = false;
|
||
}
|
||
|
||
// 计算大括号
|
||
if (!inString) {
|
||
if (char === '{') braceCount++;
|
||
if (char === '}') {
|
||
braceCount--;
|
||
if (braceCount === 0) {
|
||
functionEnd = i + 1;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (functionEnd === -1) {
|
||
console.error('❌ 未找到getMockProjectDetail函数的结束位置');
|
||
process.exit(1);
|
||
}
|
||
|
||
// 提取当前函数
|
||
const currentFunction = mockFileContent.substring(functionStart, functionEnd);
|
||
|
||
// 检查当前函数是否已经返回正确格式
|
||
if (currentFunction.includes('success:') || currentFunction.includes('success :')) {
|
||
console.log('✅ getMockProjectDetail函数可能已经返回正确格式,检查具体实现...');
|
||
}
|
||
|
||
// 查找getMockProjectsList中的projects数组
|
||
const projectsListStart = mockFileContent.indexOf('export const getMockProjectsList');
|
||
const projectsStart = mockFileContent.indexOf('const projects = [', projectsListStart);
|
||
const projectsEnd = mockFileContent.indexOf('];', projectsStart) + 2;
|
||
|
||
if (projectsStart === -1 || projectsEnd === -1) {
|
||
console.error('❌ 未找到项目数据');
|
||
process.exit(1);
|
||
}
|
||
|
||
// 提取projects数组内容
|
||
const projectsContent = mockFileContent.substring(projectsStart + 'const projects = '.length, projectsEnd - 1);
|
||
|
||
// 构建新的getMockProjectDetail函数
|
||
const newFunction = `export const getMockProjectDetail = (id) => {
|
||
// 使用与getMockProjectsList相同的数据
|
||
const projects = ${projectsContent};
|
||
|
||
const project = projects.find(p => p.id === parseInt(id));
|
||
|
||
if (!project) {
|
||
return {
|
||
success: false,
|
||
code: 404,
|
||
message: "项目不存在",
|
||
data: null
|
||
};
|
||
}
|
||
|
||
// 构造返回数据,确保包含success字段
|
||
return {
|
||
success: true,
|
||
code: 0,
|
||
message: "success",
|
||
data: {
|
||
id: project.id,
|
||
title: project.name,
|
||
category: "智能开发",
|
||
description: project.overview || "暂无项目概述",
|
||
overview: project.overview || "暂无项目概述",
|
||
applicablePositions: project.positions || [],
|
||
correspondingUnits: project.unit ? [project.unit] : [],
|
||
process: project.process || "",
|
||
keyPoints: project.keyPoints || "",
|
||
attachments: []
|
||
}
|
||
};
|
||
}`;
|
||
|
||
// 替换函数
|
||
mockFileContent =
|
||
mockFileContent.substring(0, functionStart) +
|
||
newFunction +
|
||
mockFileContent.substring(functionEnd);
|
||
|
||
// 写入文件
|
||
fs.writeFileSync(mockFilePath, mockFileContent, 'utf-8');
|
||
|
||
console.log('✅ getMockProjectDetail函数已修复!');
|
||
console.log('函数现在返回包含success字段的正确格式');
|
||
console.log('项目详情弹窗应该能正常打开了'); |