Files
ALL-teach_sys/frontend_大健康/fix_modified_syntax.py
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含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>
2025-09-24 14:14:14 +08:00

124 lines
4.7 KiB
Python
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.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import re
def fix_syntax():
"""修复resumeInterviewMock.js中的语法问题"""
# 读取文件
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
content = f.read()
# 找到resumeTemplates的部分
templates_match = re.search(r'const resumeTemplates = (\{[\s\S]*?\});', content)
if not templates_match:
print("错误无法找到resumeTemplates")
return False
# 提取JSON字符串
templates_json_str = templates_match.group(1)
# 尝试解析并修复JSON
try:
# 先尝试直接解析
templates_data = json.loads(templates_json_str)
except json.JSONDecodeError:
# 如果失败,尝试修复多行字符串问题
print("检测到JSON解析错误尝试修复...")
# 使用备份文件重新生成
with open('src/mocks/resumeInterviewMock.js.backup_modified_20250919_103451', 'r', encoding='utf-8') as f:
backup_content = f.read()
# 从备份中提取templates
backup_match = re.search(r'const resumeTemplates = (\{[\s\S]*?\});', backup_content)
if backup_match:
try:
templates_data = json.loads(backup_match.group(1))
# 加载修改版简历
import os
modified_folder = '网页未导入数据/大健康产业/大健康修改版简历'
modified_resumes = {}
for filename in os.listdir(modified_folder):
if filename.endswith('.md'):
position_name = filename.replace('.md', '')
filepath = os.path.join(modified_folder, filename)
with open(filepath, 'r', encoding='utf-8') as f:
content_text = f.read()
# 移除第一行的标题(如果有的话)
lines = content_text.split('\n')
if lines[0].startswith('# '):
content_text = '\n'.join(lines[1:]).strip()
modified_resumes[position_name] = content_text
# 更新modified字段
for group_name, templates in templates_data.items():
for template in templates:
position_name = template['position']
# 检查是否有对应的修改版简历
matching_key = None
for key in modified_resumes.keys():
if key == position_name or key.replace('助理', '') == position_name or position_name.startswith(key):
matching_key = key
break
if matching_key:
# 更新modified字段
template['content']['modified'] = modified_resumes[matching_key]
print(f"✅ 更新: {position_name}")
except Exception as e:
print(f"解析备份文件失败: {e}")
return False
# 重新构建文件
# 读取原始文件的其他部分
with open('src/mocks/resumeInterviewMock.js.backup_final', 'r', encoding='utf-8') as f:
original_content = f.read()
# 找到industries的位置
industries_start = original_content.find('const industries = ')
industries_end = original_content.find('];', industries_start) + 2
# 找到resumeTemplates的位置
templates_start = original_content.find('const resumeTemplates = ')
templates_end = original_content.find('};', templates_start) + 2
# 构建新文件
new_content = original_content[:templates_start]
new_content += f'const resumeTemplates = {json.dumps(templates_data, ensure_ascii=False, indent=2)};'
new_content += original_content[templates_end:]
# 保存文件
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write(new_content)
print("✅ 文件修复完成")
# 验证语法
import subprocess
result = subprocess.run(
['node', '-c', 'src/mocks/resumeInterviewMock.js'],
capture_output=True,
text=True
)
if result.returncode == 0:
print("✅ 语法检查通过")
return True
else:
print(f"❌ 仍有语法错误:{result.stderr[:200]}")
return False
def main():
print("修复语法错误...")
fix_syntax()
if __name__ == "__main__":
main()