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:
122
frontend_智能开发/fix_project_details.py
Normal file
122
frontend_智能开发/fix_project_details.py
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
# 读取智能制造项目案例数据
|
||||
with open('网页未导入数据/智能制造产业/智能制造项目案例.json', 'r', encoding='utf-8') as f:
|
||||
raw_data = json.load(f)
|
||||
|
||||
# 读取现有的mock文件
|
||||
with open('src/mocks/projectLibraryMock.js', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 生成新的getMockProjectDetail函数
|
||||
new_function = '''// 项目详情Mock数据 - 智能制造
|
||||
export const getMockProjectDetail = (id) => {
|
||||
// 直接根据ID返回对应项目的详情
|
||||
const projects = '''
|
||||
|
||||
# 生成项目详情数据
|
||||
projects_data = []
|
||||
for idx, item in enumerate(raw_data):
|
||||
project_id = idx + 1
|
||||
|
||||
# 提取岗位信息
|
||||
positions = []
|
||||
if item.get('对应个人简历名称'):
|
||||
pos_list = [p.strip() for p in item['对应个人简历名称'].split(',')]
|
||||
for pos in pos_list:
|
||||
if '助理' in pos or '技术员' in pos:
|
||||
level = '普通岗'
|
||||
elif '工程师' in pos or '主管' in pos:
|
||||
level = '技术骨干岗'
|
||||
elif '经理' in pos or '总监' in pos:
|
||||
level = '储备干部岗'
|
||||
else:
|
||||
level = '普通岗'
|
||||
positions.append({'level': level, 'position': pos})
|
||||
|
||||
# 提取项目内容
|
||||
content_text = item.get('项目案例内容', '')
|
||||
overview = ''
|
||||
process = ''
|
||||
keyPoints = ''
|
||||
|
||||
if content_text:
|
||||
# 提取概述(第一个非标题的段落)
|
||||
lines = content_text.split('\n')
|
||||
for line in lines:
|
||||
if line.strip() and not line.startswith('#'):
|
||||
overview = line.strip()
|
||||
break
|
||||
|
||||
# 提取流程部分
|
||||
process_match = re.search(r'# 二、.*?\n(.*?)(?=# 三、|$)', content_text, re.DOTALL)
|
||||
if process_match:
|
||||
process = process_match.group(1).strip()
|
||||
|
||||
# 提取关键技术点
|
||||
keypoints_match = re.search(r'# 三、.*?\n(.*?)$', content_text, re.DOTALL)
|
||||
if keypoints_match:
|
||||
keyPoints = keypoints_match.group(1).strip()
|
||||
|
||||
project = {
|
||||
'id': project_id,
|
||||
'name': item['案例名称'],
|
||||
'positions': positions,
|
||||
'unit': item.get('对应单元名称(垂直能力课)') or item.get('对应单元名称(复合能力课)'),
|
||||
'overview': overview,
|
||||
'process': process,
|
||||
'keyPoints': keyPoints
|
||||
}
|
||||
projects_data.append(project)
|
||||
|
||||
# 生成JavaScript数组
|
||||
new_function += json.dumps(projects_data, ensure_ascii=False, indent=2)
|
||||
|
||||
new_function += ''';
|
||||
|
||||
const project = projects.find(p => p.id === parseInt(id));
|
||||
|
||||
if (project) {
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
id: project.id,
|
||||
title: project.name,
|
||||
overview: project.overview || '暂无项目概述',
|
||||
applicablePositions: project.positions || [],
|
||||
units: [project.unit],
|
||||
process: project.process || '项目流程详情暂未录入',
|
||||
keyPoints: project.keyPoints || '关键技术点暂未录入',
|
||||
// 附件板块保留,但显示暂无附件
|
||||
attachments: []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: "项目不存在"
|
||||
};
|
||||
};'''
|
||||
|
||||
# 替换getMockProjectDetail函数
|
||||
pattern = r'// 项目详情Mock数据.*?export const getMockProjectDetail = \(id\) => \{.*?\n\};'
|
||||
match = re.search(pattern, content, re.DOTALL)
|
||||
|
||||
if match:
|
||||
new_content = content[:match.start()] + new_function + content[match.end():]
|
||||
|
||||
# 写回文件
|
||||
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
|
||||
f.write(new_content)
|
||||
|
||||
print(f"✅ 成功更新项目详情数据!")
|
||||
print(f"- 更新了 {len(projects_data)} 个项目的详情")
|
||||
print(f"- 修复了适用岗位数据")
|
||||
print(f"- 保留了附件板块")
|
||||
else:
|
||||
print("❌ 未找到getMockProjectDetail函数")
|
||||
Reference in New Issue
Block a user