- 包含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>
115 lines
3.8 KiB
Python
115 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import json
|
|
|
|
# 读取修复后的数据
|
|
with open('fixedManufacturingDataStructure.json', 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
# 先备份当前文件
|
|
import shutil
|
|
import datetime
|
|
timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
|
|
shutil.copy('src/mocks/resumeInterviewMock.js', f'src/mocks/resumeInterviewMock.js.backup_structure_fix_{timestamp}')
|
|
|
|
# 读取原文件
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|
lines = f.readlines()
|
|
|
|
# 生成新的industries代码
|
|
industries_code = "const industries = " + json.dumps(data['industries'], ensure_ascii=False, indent=2) + ";\n"
|
|
|
|
# 生成新的resumeTemplates代码
|
|
resume_templates_code = "const resumeTemplates = " + json.dumps(data['resumeTemplates'], ensure_ascii=False, indent=2) + ";\n"
|
|
|
|
# 找到industries的起始和结束位置
|
|
industries_start = -1
|
|
industries_end = -1
|
|
for i, line in enumerate(lines):
|
|
if line.startswith('const industries = '):
|
|
industries_start = i
|
|
# 找到对应的结束位置
|
|
bracket_count = 0
|
|
square_bracket_count = 0
|
|
in_array = False
|
|
|
|
for j in range(i, len(lines)):
|
|
for char in lines[j]:
|
|
if char == '[':
|
|
square_bracket_count += 1
|
|
in_array = True
|
|
elif char == ']':
|
|
square_bracket_count -= 1
|
|
elif char == '{' and in_array:
|
|
bracket_count += 1
|
|
elif char == '}' and in_array:
|
|
bracket_count -= 1
|
|
|
|
# 当所有括号都匹配完成时
|
|
if in_array and square_bracket_count == 0 and bracket_count == 0:
|
|
if '];' in lines[j]:
|
|
industries_end = j + 1
|
|
break
|
|
break
|
|
|
|
# 找到resumeTemplates的起始和结束位置
|
|
templates_start = -1
|
|
templates_end = -1
|
|
for i, line in enumerate(lines):
|
|
if line.startswith('const resumeTemplates = '):
|
|
templates_start = i
|
|
# 找到对应的结束位置
|
|
bracket_count = 0
|
|
for j in range(i, len(lines)):
|
|
bracket_count += lines[j].count('{') - lines[j].count('}')
|
|
if bracket_count == 0 and '};' in lines[j]:
|
|
templates_end = j + 1
|
|
break
|
|
break
|
|
|
|
print(f"Industries: 行 {industries_start+1} 到 {industries_end}")
|
|
print(f"ResumeTemplates: 行 {templates_start+1} 到 {templates_end}")
|
|
|
|
if industries_start == -1 or templates_start == -1:
|
|
print("错误:找不到目标代码块")
|
|
exit(1)
|
|
|
|
# 构建新文件
|
|
new_lines = []
|
|
|
|
# 添加industries之前的内容
|
|
new_lines.extend(lines[:industries_start])
|
|
|
|
# 添加新的industries
|
|
new_lines.append(industries_code)
|
|
|
|
# 添加industries和resumeTemplates之间的内容
|
|
new_lines.extend(lines[industries_end:templates_start])
|
|
|
|
# 添加新的resumeTemplates
|
|
new_lines.append(resume_templates_code)
|
|
|
|
# 添加resumeTemplates之后的内容
|
|
new_lines.extend(lines[templates_end:])
|
|
|
|
# 写入新文件
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|
f.writelines(new_lines)
|
|
|
|
print(f"文件已成功更新!")
|
|
print(f"- 岗位群数量: {len(data['industries'])}")
|
|
print(f"- 岗位总数: {data['totalPositions']}")
|
|
print(f"- 简历模板组数: {len(data['resumeTemplates'])}")
|
|
print(f"- 简历模板总数: {sum(len(templates) for templates in data['resumeTemplates'].values())}")
|
|
|
|
# 验证更新结果
|
|
print("\n验证数据结构:")
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
if '["3D打印工艺"]' in content or '"3D打印工艺":[' in content:
|
|
print("✅ 简历模板按行业分组结构已修复")
|
|
else:
|
|
print("❌ 简历模板结构可能有问题")
|
|
|
|
print("✅ 数据结构修复完成!") |