Files
online_sys/frontend_智能开发/fix_final_syntax.py
KQL a7242f0c69 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>
2025-12-12 18:16:55 +08:00

65 lines
2.3 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
import re
# 读取文件
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
content = f.read()
print("原始文件长度:", len(content.split('\n')), "")
# 创建备份
with open('src/mocks/resumeInterviewMock.js.backup_final', 'w', encoding='utf-8') as f:
f.write(content)
print("已创建备份: resumeInterviewMock.js.backup_final")
# 查找问题的root cause
lines = content.split('\n')
# 检查第6516-6520行的具体问题
print("\n检查问题行6510-6525:")
for i in range(6509, min(6525, len(lines))):
print(f"{i+1}: {lines[i]}")
# 解决方案确保第6518行的分号前面有正确的逗号
# 问题是"旅游"数组结束后resumeTemplates对象也结束但是JavaScript期望有逗号或更多内容
# 检查最后一个行业的结构
travel_end_pattern = r'(\s*\]\s*)\n(\s*\/\/ 添加空对象以便语法正确\s*\n\s*"_end": \[\]\s*\n\s*\};)'
match = re.search(travel_end_pattern, content)
if match:
print("找到了旅游数组结束的地方")
# 移除临时的_end键直接结束对象
content = re.sub(travel_end_pattern, r'\1\n};', content)
print("修复了临时的_end键")
else:
print("没有找到_end键尝试其他修复方法")
# 另一个可能的问题检查studentInfo结构的结束
# 确保所有的大括号正确嵌套
content = re.sub(r'(\s*personal_summary: "[^"]*")\n(\s*\}\s*\n\s*\}\s*\n\s*\}\s*\n\s*\],)',
r'\1\n }\2', content)
# 写回文件
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write(content)
print("修复完成,正在验证语法...")
import subprocess
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
capture_output=True, text=True)
if result.returncode == 0:
print("✅ 语法验证通过!")
else:
print(f"❌ 仍有语法错误:{result.stderr}")
# 如果还有错误,显示具体错误行
import re
match = re.search(r':(\d+)', result.stderr)
if match:
line_num = int(match.group(1))
print(f"\n错误行 {line_num} 附近:")
for i in range(max(0, line_num-3), min(len(lines), line_num+3)):
prefix = ">>> " if i == line_num-1 else " "
print(f"{prefix}{i+1}: {lines[i][:100]}")