主要更新: - 更新所有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>
139 lines
4.5 KiB
Python
139 lines
4.5 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_first_5_questions(content):
|
||
"""从面试题内容中提取前5个问题和答案"""
|
||
questions = []
|
||
|
||
# 提取所有问题
|
||
pattern = r'(\d+)\.\s*问题[::]?\s*(.*?)(?:\n\s*)?(?:参考回答[::]?)(.*?)(?=\d+\.\s*问题|$)'
|
||
matches = re.findall(pattern, content, re.DOTALL)
|
||
|
||
for i, match in enumerate(matches[:5], 1): # 只取前5个
|
||
q_num = match[0]
|
||
question_text = match[1].strip()
|
||
answer_text = match[2].strip()
|
||
|
||
questions.append({
|
||
"num": i,
|
||
"question": question_text,
|
||
"answer": answer_text
|
||
})
|
||
|
||
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}_simple'
|
||
|
||
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()
|
||
|
||
# 岗位映射
|
||
position_map = {
|
||
"UI设计师": "UI设计",
|
||
"包装设计师": "包装设计",
|
||
"插画师": "插画设计",
|
||
"影视灯光": "灯光",
|
||
"动画师": "动画设计",
|
||
"平面设计师": "平面设计",
|
||
"品牌视觉内容策划": "品牌设计",
|
||
"CG总监助理": "三维设计",
|
||
"特效设计师": "后期特效",
|
||
"剪辑师": "剪辑",
|
||
"调色师": "调色",
|
||
"录音师": "音频处理",
|
||
"直播专员": "直播",
|
||
"新媒体运营专员": "新媒体运营",
|
||
"文案策划": "影视节目策划",
|
||
"室内设计师": "室内设计"
|
||
}
|
||
|
||
updated_count = 0
|
||
|
||
# 对每个岗位进行更新
|
||
for item in visual_data:
|
||
position_name = item.get('岗位名称')
|
||
interview_content = item.get('面试题内容')
|
||
|
||
if not position_name or not interview_content:
|
||
continue
|
||
|
||
if position_name not in position_map:
|
||
continue
|
||
|
||
industry_name = position_map[position_name]
|
||
questions = extract_first_5_questions(interview_content)
|
||
|
||
if not questions:
|
||
continue
|
||
|
||
print(f"处理 {industry_name} ({position_name}):")
|
||
|
||
# 逐个替换前5个问题的内容
|
||
for q in questions:
|
||
q_id = f"q1_{q['num']}"
|
||
|
||
# 转义特殊字符
|
||
question_escaped = q['question'].replace('\\', '\\\\').replace('"', '\\"')
|
||
answer_escaped = q['answer'].replace('\\', '\\\\').replace('"', '\\"')
|
||
|
||
# 查找并替换该问题
|
||
pattern = rf'("id":\s*"{q_id}".*?"question":\s*)"[^"]*"(.*?"answer":\s*)"[^"]*"'
|
||
replacement = rf'\1"{question_escaped}"\2"{answer_escaped}"'
|
||
|
||
new_content = re.sub(pattern, replacement, mock_content, count=1, flags=re.DOTALL)
|
||
|
||
if new_content != mock_content:
|
||
mock_content = new_content
|
||
print(f" ✓ 更新问题 {q_id}")
|
||
else:
|
||
print(f" ✗ 未能更新问题 {q_id}")
|
||
|
||
updated_count += 1
|
||
|
||
# 保存文件
|
||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(mock_content)
|
||
|
||
print(f"\n✅ 更新完成!处理了{updated_count}个岗位")
|
||
|
||
# 验证语法
|
||
import subprocess
|
||
try:
|
||
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
|
||
capture_output=True, text=True)
|
||
if result.returncode == 0:
|
||
print("✅ 文件语法验证通过")
|
||
else:
|
||
print(f"❌ 语法错误:\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() |