主要内容: - 包含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>
115 lines
4.8 KiB
Python
115 lines
4.8 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import re
|
||
import json
|
||
|
||
print("修复Mock文件结构...")
|
||
|
||
# 读取文件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 先备份
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js.backup_before_structure_fix', 'w', encoding='utf-8') as f:
|
||
f.write(content)
|
||
|
||
# 找到所有岗位群
|
||
industry_pattern = r'"id":\s*"(health_\d+)"'
|
||
industries = re.findall(industry_pattern, content)
|
||
unique_industries = []
|
||
seen = set()
|
||
for ind in industries:
|
||
if ind not in seen:
|
||
unique_industries.append(ind)
|
||
seen.add(ind)
|
||
|
||
print(f"找到 {len(unique_industries)} 个岗位群")
|
||
|
||
# 对每个岗位群,确保questions在positions之后
|
||
for industry_id in unique_industries:
|
||
# 查找该岗位群的整个块
|
||
pattern = rf'(\{{\s*"id":\s*"{industry_id}"[^{{]*?"name":\s*"[^"]+",\s*"positions":\s*\[)'
|
||
|
||
match = re.search(pattern, content, re.DOTALL)
|
||
if match:
|
||
start_pos = match.start()
|
||
|
||
# 找到这个岗位群块的结束位置(下一个岗位群开始或industries数组结束)
|
||
next_industry = None
|
||
for next_id in unique_industries:
|
||
if next_id != industry_id:
|
||
next_match = re.search(rf'\{{\s*"id":\s*"{next_id}"', content[start_pos + 100:])
|
||
if next_match:
|
||
if next_industry is None or next_match.start() < next_industry:
|
||
next_industry = start_pos + 100 + next_match.start()
|
||
|
||
# 如果没有下一个岗位群,找industries数组的结束
|
||
if next_industry is None:
|
||
end_match = re.search(r'\n\];', content[start_pos:])
|
||
if end_match:
|
||
next_industry = start_pos + end_match.start()
|
||
|
||
if next_industry:
|
||
industry_block = content[start_pos:next_industry]
|
||
|
||
# 检查是否有questions被错误地放在positions内部
|
||
if '"questions":' in industry_block:
|
||
# 提取positions数组
|
||
positions_match = re.search(r'"positions":\s*\[(.*)', industry_block, re.DOTALL)
|
||
if positions_match:
|
||
positions_content = positions_match.group(1)
|
||
|
||
# 找到positions数组的正确结束位置(不包含questions)
|
||
bracket_count = 1
|
||
brace_count = 0
|
||
in_questions = False
|
||
positions_end = 0
|
||
|
||
for i, char in enumerate(positions_content):
|
||
if char == '[':
|
||
bracket_count += 1
|
||
elif char == ']':
|
||
bracket_count -= 1
|
||
if bracket_count == 0 and not in_questions:
|
||
positions_end = i
|
||
break
|
||
elif char == '{':
|
||
brace_count += 1
|
||
elif char == '}':
|
||
brace_count -= 1
|
||
|
||
# 检查是否进入questions部分
|
||
if '"questions":' in positions_content[max(0, i-20):i+20]:
|
||
in_questions = True
|
||
|
||
# 现在提取questions部分
|
||
questions_match = re.search(r'"questions":\s*\[(.*?)\]\s*\}', industry_block, re.DOTALL)
|
||
if questions_match:
|
||
questions_content = questions_match.group(0)
|
||
|
||
# 重构岗位群块
|
||
# 1. 移除positions中错误的questions
|
||
clean_positions = re.sub(r',\s*"questions":\s*\[[^\]]*?\]', '', industry_block)
|
||
|
||
# 2. 在positions数组后添加questions
|
||
# 找到positions的结束位置
|
||
pos_end_match = re.search(r'(\]\s*)(,?\s*"questions":|\}\s*(?:,|\]|$))', clean_positions)
|
||
if pos_end_match:
|
||
# 在positions后插入questions
|
||
insert_pos = pos_end_match.start() + len(pos_end_match.group(1))
|
||
new_block = clean_positions[:insert_pos] + ',\n ' + questions_content + clean_positions[insert_pos:]
|
||
|
||
# 替换原内容
|
||
content = content[:start_pos] + new_block + content[next_industry:]
|
||
print(f" ✓ 修复了 {industry_id} 的结构")
|
||
|
||
# 清理多余的逗号和括号
|
||
content = re.sub(r',\s*\]', ']', content)
|
||
content = re.sub(r',\s*\}', '}', content)
|
||
|
||
# 写回文件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(content)
|
||
|
||
print("✓ 结构修复完成!") |