主要更新: - 更新所有12个产业的教务系统数据和功能 - 删除所有 node_modules 文件夹(节省3.7GB) - 删除所有 .yoyo 缓存文件夹(节省1.2GB) - 删除所有 dist 构建文件(节省55MB) 项目优化: - 项目大小从 8.1GB 减少到 3.2GB(节省60%空间) - 保留完整的源代码和配置文件 - .gitignore 已配置,防止再次提交大文件 启动脚本: - start-industry.sh/bat/ps1 脚本会自动检测并安装依赖 - 首次启动时自动运行 npm install - 支持单个或批量启动产业系统 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
171 lines
6.2 KiB
Python
171 lines
6.2 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import json
|
||
import re
|
||
from datetime import datetime
|
||
|
||
def load_visual_design_data():
|
||
"""加载视觉设计岗位简历数据"""
|
||
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
|
||
return json.load(f)
|
||
|
||
def extract_questions_with_structure(content, industry_name):
|
||
"""从面试题内容中提取问题和答案(保持subQuestions结构)"""
|
||
questions = []
|
||
|
||
# 提取所有问题
|
||
pattern = r'(\d+)\.\s*问题[::]?\s*(.*?)(?:\n\s*)?(?:参考回答[::]?)(.*?)(?=\d+\.\s*问题|$)'
|
||
matches = re.findall(pattern, content, re.DOTALL)
|
||
|
||
# 创建子问题数组
|
||
sub_questions = []
|
||
for i, match in enumerate(matches[:10], 1): # 限制为前10个问题
|
||
q_num = match[0]
|
||
question_text = match[1].strip()
|
||
answer_text = match[2].strip()
|
||
|
||
sub_questions.append({
|
||
"id": f"q1_{i}",
|
||
"question": question_text,
|
||
"answer": answer_text
|
||
})
|
||
|
||
# 如果找到了问题,创建带有subQuestions的结构
|
||
if sub_questions:
|
||
questions.append({
|
||
"id": "group_q1",
|
||
"question": f"# {industry_name}面试题",
|
||
"subQuestions": sub_questions
|
||
})
|
||
|
||
return questions
|
||
|
||
def main():
|
||
print("=== 精确替换面试题数据 ===\n")
|
||
|
||
# 创建备份
|
||
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||
backup_name = f'src/mocks/resumeInterviewMock.js.backup_{timestamp}_accurate'
|
||
|
||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
mock_content = f.read()
|
||
|
||
with open(backup_name, 'w', encoding='utf-8') as f:
|
||
f.write(mock_content)
|
||
print(f"✓ 已创建备份: {backup_name}\n")
|
||
|
||
# 加载视觉设计数据
|
||
visual_data = load_visual_design_data()
|
||
|
||
# 创建岗位群到岗位名称的精确映射
|
||
# 基于实际数据分析结果
|
||
industry_position_map = {
|
||
'UI设计': 'UI设计师',
|
||
'包装设计': '包装设计师', # 有多个,选择包装设计师
|
||
'插画设计': '插画师', # 有多个,选择插画师
|
||
'灯光': '影视灯光', # 有多个,选择影视灯光
|
||
'动画设计': '动画师', # 有多个,选择动画师
|
||
'后期特效': '特效设计师', # 有多个,选择特效设计师
|
||
'剪辑': '剪辑师', # 有多个,选择剪辑师
|
||
'品牌设计': '品牌视觉内容策划', # 有多个,选择品牌视觉内容策划
|
||
'平面设计': '平面设计师',
|
||
'三维设计': 'CG总监助理', # 有多个,选择CG总监助理
|
||
'摄影/摄像': '摄影师', # 有多个,选择摄影师
|
||
'室内设计': '室内设计师',
|
||
'调色': '调色师',
|
||
'新媒体运营': '新媒体运营专员',
|
||
'音频处理': '录音师',
|
||
'影视节目策划': '文案策划',
|
||
'直播': '直播专员' # 有多个,选择直播专员
|
||
}
|
||
|
||
updated_count = 0
|
||
failed_list = []
|
||
|
||
for industry_name, position_name in industry_position_map.items():
|
||
print(f"处理 {industry_name}...")
|
||
|
||
# 查找对应的面试题内容
|
||
interview_content = None
|
||
for item in visual_data:
|
||
if item.get('岗位名称') == position_name and item.get('面试题内容'):
|
||
interview_content = item.get('面试题内容')
|
||
break
|
||
|
||
if not interview_content:
|
||
print(f" ⚠️ 未找到 {position_name} 的面试题内容")
|
||
failed_list.append(industry_name)
|
||
continue
|
||
|
||
# 提取问题
|
||
questions = extract_questions_with_structure(interview_content, industry_name)
|
||
|
||
if not questions:
|
||
print(f" ⚠️ 未能从 {position_name} 提取面试题")
|
||
failed_list.append(industry_name)
|
||
continue
|
||
|
||
# 构建新的questions数组JSON
|
||
questions_json = json.dumps(questions, ensure_ascii=False, indent=2)
|
||
|
||
# 调整缩进
|
||
lines = questions_json.split('\n')
|
||
adjusted_lines = []
|
||
for line in lines:
|
||
if line.strip():
|
||
adjusted_lines.append(' ' + line)
|
||
else:
|
||
adjusted_lines.append('')
|
||
questions_json = '\n'.join(adjusted_lines)
|
||
|
||
# 查找并替换
|
||
# 使用更精确的模式:找到industry name后,找到其questions数组并替换
|
||
pattern = rf'("name":\s*"{re.escape(industry_name)}"[^{{]*?"questions":\s*)\[[^\[]*?(?:\[[^\]]*?\][^\[]*?)*?\]'
|
||
|
||
def replace_func(match):
|
||
prefix = match.group(1)
|
||
return prefix + questions_json.strip()
|
||
|
||
new_mock_content = re.sub(pattern, replace_func, mock_content, count=1, flags=re.DOTALL)
|
||
|
||
if new_mock_content != mock_content:
|
||
mock_content = new_mock_content
|
||
updated_count += 1
|
||
sub_count = len(questions[0].get('subQuestions', [])) if questions else 0
|
||
print(f" ✓ 成功更新 (使用岗位: {position_name}, 共{sub_count}个问题)")
|
||
else:
|
||
print(f" ✗ 未能更新")
|
||
failed_list.append(industry_name)
|
||
|
||
# 保存文件
|
||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(mock_content)
|
||
|
||
print(f"\n✅ 更新完成!")
|
||
print(f" 成功更新: {updated_count}个岗位群")
|
||
if failed_list:
|
||
print(f" 失败: {len(failed_list)}个")
|
||
for name in failed_list:
|
||
print(f" - {name}")
|
||
|
||
# 验证语法
|
||
import subprocess
|
||
try:
|
||
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
|
||
capture_output=True, text=True)
|
||
if result.returncode == 0:
|
||
print("\n✅ 文件语法验证通过")
|
||
else:
|
||
print(f"\n❌ 语法错误:\n{result.stderr}")
|
||
print("\n恢复备份...")
|
||
with open(backup_name, 'r', encoding='utf-8') as f:
|
||
backup_content = f.read()
|
||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(backup_content)
|
||
print("已恢复备份")
|
||
except Exception as e:
|
||
print(f"⚠️ 无法验证语法: {str(e)}")
|
||
|
||
if __name__ == '__main__':
|
||
main() |