- 包含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>
124 lines
4.7 KiB
Python
124 lines
4.7 KiB
Python
#!/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() |