131 lines
4.5 KiB
Python
131 lines
4.5 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
|
|||
|
|
import json
|
|||
|
|
import re
|
|||
|
|
|
|||
|
|
print("开始完整修复resumeInterviewMock.js...")
|
|||
|
|
|
|||
|
|
# 读取文件
|
|||
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|||
|
|
content = f.read()
|
|||
|
|
|
|||
|
|
# 备份
|
|||
|
|
with open('src/mocks/resumeInterviewMock.js.backup_complete_fix', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(content)
|
|||
|
|
print("✅ 已创建备份: resumeInterviewMock.js.backup_complete_fix")
|
|||
|
|
|
|||
|
|
# 分析文件结构
|
|||
|
|
lines = content.split('\n')
|
|||
|
|
|
|||
|
|
# 找到关键位置
|
|||
|
|
industries_start = None
|
|||
|
|
resumeTemplates_start = None
|
|||
|
|
myResume_start = None
|
|||
|
|
|
|||
|
|
for i, line in enumerate(lines):
|
|||
|
|
if 'const industries = [' in line:
|
|||
|
|
industries_start = i
|
|||
|
|
print(f"找到industries开始位置: 第{i+1}行")
|
|||
|
|
elif 'const resumeTemplates = {' in line:
|
|||
|
|
resumeTemplates_start = i
|
|||
|
|
print(f"找到resumeTemplates开始位置: 第{i+1}行")
|
|||
|
|
elif 'const myResume = {' in line:
|
|||
|
|
myResume_start = i
|
|||
|
|
print(f"找到myResume开始位置: 第{i+1}行")
|
|||
|
|
|
|||
|
|
# 检查第6479-6481行的结构问题
|
|||
|
|
print("\n检查关键位置的结构...")
|
|||
|
|
if len(lines) > 6480:
|
|||
|
|
# 在第6479行,模板字符串应该正确结束
|
|||
|
|
if '我是一名即将毕业的大专生' in lines[6478]:
|
|||
|
|
print("找到问题位置:文旅项目投资拓展管培生的数据结构")
|
|||
|
|
|
|||
|
|
# 确保content对象正确结束
|
|||
|
|
# original字段的模板字符串在第6479行结束
|
|||
|
|
# 然后应该关闭content对象
|
|||
|
|
|
|||
|
|
# 查找studentInfo的位置
|
|||
|
|
studentInfo_line = None
|
|||
|
|
for i in range(6478, min(6485, len(lines))):
|
|||
|
|
if 'studentInfo:' in lines[i]:
|
|||
|
|
studentInfo_line = i
|
|||
|
|
print(f"找到studentInfo在第{i+1}行")
|
|||
|
|
break
|
|||
|
|
|
|||
|
|
if studentInfo_line:
|
|||
|
|
# studentInfo应该在content对象外部,与content同级
|
|||
|
|
# 修复:确保content对象在original后正确关闭
|
|||
|
|
lines[6479] = lines[6479].rstrip('`,')
|
|||
|
|
if not lines[6479].endswith('`'):
|
|||
|
|
lines[6479] += '`'
|
|||
|
|
lines[6480] = ' },' # 关闭content对象
|
|||
|
|
|
|||
|
|
# 确保studentInfo正确缩进
|
|||
|
|
if studentInfo_line > 6480:
|
|||
|
|
lines[studentInfo_line] = ' studentInfo: {'
|
|||
|
|
|
|||
|
|
# 重新组合内容
|
|||
|
|
content = '\n'.join(lines)
|
|||
|
|
|
|||
|
|
# 写回文件
|
|||
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(content)
|
|||
|
|
|
|||
|
|
print("\n修复完成,验证语法...")
|
|||
|
|
|
|||
|
|
# 验证
|
|||
|
|
import subprocess
|
|||
|
|
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
|
|||
|
|
capture_output=True, text=True)
|
|||
|
|
|
|||
|
|
if result.returncode == 0:
|
|||
|
|
print("✅ 语法验证通过!")
|
|||
|
|
|
|||
|
|
# 测试数据加载
|
|||
|
|
print("\n测试数据加载...")
|
|||
|
|
test_code = """
|
|||
|
|
const { resumeInterviewMockData } = require('./src/mocks/resumeInterviewMock.js');
|
|||
|
|
console.log('Industries数量:', resumeInterviewMockData.industries.length);
|
|||
|
|
console.log('ResumeTemplates键数量:', Object.keys(resumeInterviewMockData.resumeTemplates).length);
|
|||
|
|
|
|||
|
|
// 检查问题岗位
|
|||
|
|
const problemPositions = [
|
|||
|
|
'民宿管家', '民宿客房管家', '民宿运营专员', '露营地运营专员',
|
|||
|
|
'新媒体运营专员', '文创产品设计师', '文创产品策划师', '文创产品设计师助理',
|
|||
|
|
'品牌策划运营专员', '品牌公关', '品牌推广专员', 'ip运营',
|
|||
|
|
'ip运营总监助理', '品牌公关管培生'
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
let foundCount = 0;
|
|||
|
|
for (const industry in resumeInterviewMockData.resumeTemplates) {
|
|||
|
|
const positions = resumeInterviewMockData.resumeTemplates[industry];
|
|||
|
|
for (const pos of positions) {
|
|||
|
|
if (problemPositions.includes(pos.position)) {
|
|||
|
|
foundCount++;
|
|||
|
|
console.log(`✓ 找到: ${pos.position}`);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
console.log(`\\n总计找到 ${foundCount}/${problemPositions.length} 个问题岗位`);
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
with open('test_positions.js', 'w') as f:
|
|||
|
|
f.write(test_code)
|
|||
|
|
|
|||
|
|
result2 = subprocess.run(['node', 'test_positions.js'], capture_output=True, text=True)
|
|||
|
|
if result2.returncode == 0:
|
|||
|
|
print(result2.stdout)
|
|||
|
|
else:
|
|||
|
|
print(f"数据加载测试失败: {result2.stderr}")
|
|||
|
|
else:
|
|||
|
|
print(f"❌ 仍有语法错误:\n{result.stderr}")
|
|||
|
|
|
|||
|
|
# 显示错误位置
|
|||
|
|
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][:80]}")
|