更新12个教务系统并优化项目大小
主要更新: - 更新所有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>
This commit is contained in:
@@ -1,226 +1,139 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
# 读取视觉设计岗位简历.json文件
|
||||
json_file = '网页未导入数据/视觉设计产业/视觉设计岗位简历.json'
|
||||
mock_file = 'src/mocks/resumeInterviewMock.js'
|
||||
def load_visual_design_data():
|
||||
"""加载视觉设计岗位简历数据"""
|
||||
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
|
||||
print("正在读取完整的面试题数据...")
|
||||
with open(json_file, 'r', encoding='utf-8') as f:
|
||||
positions_data = json.load(f)
|
||||
def extract_first_5_questions(content):
|
||||
"""从面试题内容中提取前5个问题和答案"""
|
||||
questions = []
|
||||
|
||||
# 创建岗位名称到面试题的映射
|
||||
interview_questions_map = {}
|
||||
for position in positions_data:
|
||||
position_name = position.get("岗位名称", "")
|
||||
interview_content = position.get("面试题内容", "")
|
||||
if position_name and interview_content:
|
||||
# 解析markdown格式的面试题
|
||||
questions = []
|
||||
lines = interview_content.split('\n')
|
||||
current_section = ""
|
||||
current_question = None
|
||||
# 提取所有问题
|
||||
pattern = r'(\d+)\.\s*问题[::]?\s*(.*?)(?:\n\s*)?(?:参考回答[::]?)(.*?)(?=\d+\.\s*问题|$)'
|
||||
matches = re.findall(pattern, content, re.DOTALL)
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line.startswith('# '):
|
||||
# 新的大分类
|
||||
current_section = line[2:].strip()
|
||||
elif line and line[0].isdigit() and '. 问题' in line:
|
||||
# 保存上一个问题
|
||||
if current_question:
|
||||
questions.append(current_question)
|
||||
for i, match in enumerate(matches[:5], 1): # 只取前5个
|
||||
q_num = match[0]
|
||||
question_text = match[1].strip()
|
||||
answer_text = match[2].strip()
|
||||
|
||||
# 提取问题文本
|
||||
parts = line.split('问题:', 1)
|
||||
if len(parts) > 1:
|
||||
question_text = parts[1].strip()
|
||||
else:
|
||||
parts = line.split('问题:', 1)
|
||||
if len(parts) > 1:
|
||||
question_text = parts[1].strip()
|
||||
else:
|
||||
question_text = line
|
||||
questions.append({
|
||||
"num": i,
|
||||
"question": question_text,
|
||||
"answer": answer_text
|
||||
})
|
||||
|
||||
current_question = {
|
||||
"question": question_text,
|
||||
"answer": "",
|
||||
"section": current_section
|
||||
}
|
||||
elif line.startswith('答案:') or line.startswith('答案:'):
|
||||
if current_question:
|
||||
answer = line.replace('答案:', '').replace('答案:', '').strip()
|
||||
current_question["answer"] = answer
|
||||
elif current_question and line and not line.startswith('#') and not (line[0].isdigit() and '. 问题' in line):
|
||||
# 继续添加到答案中(多行答案)
|
||||
if current_question["answer"] and not line.startswith('---'):
|
||||
current_question["answer"] += " " + line
|
||||
return questions
|
||||
|
||||
# 添加最后一个问题
|
||||
if current_question:
|
||||
questions.append(current_question)
|
||||
def main():
|
||||
print("=== 简单更新面试题内容 ===\n")
|
||||
|
||||
interview_questions_map[position_name] = questions
|
||||
if questions:
|
||||
print(f"解析 {position_name} 的面试题,共 {len(questions)} 个问题")
|
||||
# 创建备份
|
||||
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
backup_name = f'src/mocks/resumeInterviewMock.js.backup_{timestamp}_simple'
|
||||
|
||||
print(f"\n总共找到 {len(interview_questions_map)} 个岗位的面试题")
|
||||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||||
mock_content = f.read()
|
||||
|
||||
# 读取resumeInterviewMock.js文件
|
||||
print("\n正在读取 resumeInterviewMock.js...")
|
||||
with open(mock_file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
with open(backup_name, 'w', encoding='utf-8') as f:
|
||||
f.write(mock_content)
|
||||
print(f"✓ 已创建备份: {backup_name}\n")
|
||||
|
||||
# 创建备份
|
||||
backup_file = f"{mock_file}.backup_simple_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
with open(backup_file, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print(f"已创建备份文件: {backup_file}")
|
||||
# 加载视觉设计数据
|
||||
visual_data = load_visual_design_data()
|
||||
|
||||
# 为每个产业创建面试题数据
|
||||
def create_industry_questions(position_name, questions):
|
||||
"""为特定岗位创建面试题数组"""
|
||||
# 按section分组
|
||||
sections = {}
|
||||
for q in questions:
|
||||
section = q.get('section', '通用问题')
|
||||
if section not in sections:
|
||||
sections[section] = []
|
||||
sections[section].append(q)
|
||||
# 岗位映射
|
||||
position_map = {
|
||||
"UI设计师": "UI设计",
|
||||
"包装设计师": "包装设计",
|
||||
"插画师": "插画设计",
|
||||
"影视灯光": "灯光",
|
||||
"动画师": "动画设计",
|
||||
"平面设计师": "平面设计",
|
||||
"品牌视觉内容策划": "品牌设计",
|
||||
"CG总监助理": "三维设计",
|
||||
"特效设计师": "后期特效",
|
||||
"剪辑师": "剪辑",
|
||||
"调色师": "调色",
|
||||
"录音师": "音频处理",
|
||||
"直播专员": "直播",
|
||||
"新媒体运营专员": "新媒体运营",
|
||||
"文案策划": "影视节目策划",
|
||||
"室内设计师": "室内设计"
|
||||
}
|
||||
|
||||
# 创建questions数组
|
||||
result = []
|
||||
updated_count = 0
|
||||
|
||||
for section_name, section_questions in sections.items():
|
||||
if section_questions:
|
||||
# 创建分组
|
||||
group = {
|
||||
"id": f"group_q{len(result)+1}",
|
||||
"question": f"# {section_name}" if section_name else "# 面试题",
|
||||
"subQuestions": []
|
||||
}
|
||||
# 对每个岗位进行更新
|
||||
for item in visual_data:
|
||||
position_name = item.get('岗位名称')
|
||||
interview_content = item.get('面试题内容')
|
||||
|
||||
for idx, q in enumerate(section_questions):
|
||||
sub_q = {
|
||||
"id": f"q{len(result)+1}_{idx+1}",
|
||||
"question": q["question"],
|
||||
"answer": q["answer"] if q["answer"] else "请根据实际情况回答。"
|
||||
}
|
||||
group["subQuestions"].append(sub_q)
|
||||
if not position_name or not interview_content:
|
||||
continue
|
||||
|
||||
if group["subQuestions"]: # 只添加有内容的分组
|
||||
result.append(group)
|
||||
if position_name not in position_map:
|
||||
continue
|
||||
|
||||
return result
|
||||
industry_name = position_map[position_name]
|
||||
questions = extract_first_5_questions(interview_content)
|
||||
|
||||
# 定义产业和岗位的映射关系
|
||||
industry_positions_map = {
|
||||
"UI设计": ["UI设计师"],
|
||||
"包装设计": ["包装设计师"],
|
||||
"插画设计": ["插画师"],
|
||||
"灯光": ["影视灯光"],
|
||||
"动画设计": ["动画师", "角色原画师", "分镜设计师"],
|
||||
"后期特效": ["特效设计师", "3D特效师", "特效合成师", "CG总监助理"],
|
||||
"剪辑": ["剪辑师", "影视剪辑", "短视频剪辑师"],
|
||||
"品牌设计": ["品牌视觉内容策划", "LOGO设计师", "品牌视觉传播策划管培生"],
|
||||
"平面设计": ["平面设计师", "AIGC设计师", "AI绘画师"],
|
||||
"三维设计": ["3D建模师", "渲染合成师", "材质灯光师", "游戏场景地编", "游戏场景生态设计师助理", "潮玩设计师"],
|
||||
"摄影/摄像": ["摄影师", "影视摄像", "摄影美术指导助理"],
|
||||
"室内设计": ["室内设计师", "美术总监助理"],
|
||||
"调色": ["调色师"],
|
||||
"新媒体运营": ["新媒体运营专员", "自媒体运营专员"],
|
||||
"音频处理": ["音效设计师", "音频编辑师", "混音师", "录音师"],
|
||||
"影视节目策划": ["导演", "文案策划"],
|
||||
"直播": ["社群运营", "直播助理", "直播运营", "直播专员"]
|
||||
}
|
||||
if not questions:
|
||||
continue
|
||||
|
||||
# 手动为每个产业更新questions
|
||||
print("\n开始更新面试题数据...")
|
||||
update_count = 0
|
||||
print(f"处理 {industry_name} ({position_name}):")
|
||||
|
||||
# 读取文件行
|
||||
lines = content.split('\n')
|
||||
new_lines = []
|
||||
i = 0
|
||||
# 逐个替换前5个问题的内容
|
||||
for q in questions:
|
||||
q_id = f"q1_{q['num']}"
|
||||
|
||||
while i < len(lines):
|
||||
line = lines[i]
|
||||
new_lines.append(line)
|
||||
# 转义特殊字符
|
||||
question_escaped = q['question'].replace('\\', '\\\\').replace('"', '\\"')
|
||||
answer_escaped = q['answer'].replace('\\', '\\\\').replace('"', '\\"')
|
||||
|
||||
# 检查是否是产业名称行
|
||||
for industry_name, position_names in industry_positions_map.items():
|
||||
if f'"name": "{industry_name}"' in line:
|
||||
# 找到产业,查找其questions字段
|
||||
j = i + 1
|
||||
while j < len(lines) and '"questions":' not in lines[j]:
|
||||
new_lines.append(lines[j])
|
||||
j += 1
|
||||
# 查找并替换该问题
|
||||
pattern = rf'("id":\s*"{q_id}".*?"question":\s*)"[^"]*"(.*?"answer":\s*)"[^"]*"'
|
||||
replacement = rf'\1"{question_escaped}"\2"{answer_escaped}"'
|
||||
|
||||
if j < len(lines) and '"questions":' in lines[j]:
|
||||
# 找到questions行
|
||||
new_lines.append(lines[j]) # 添加 "questions": [
|
||||
new_content = re.sub(pattern, replacement, mock_content, count=1, flags=re.DOTALL)
|
||||
|
||||
# 跳过旧的questions内容直到找到对应的结束 ]
|
||||
bracket_count = 1
|
||||
j += 1
|
||||
while j < len(lines) and bracket_count > 0:
|
||||
if '[' in lines[j]:
|
||||
bracket_count += lines[j].count('[') - lines[j].count(']')
|
||||
elif ']' in lines[j]:
|
||||
bracket_count -= lines[j].count(']')
|
||||
j += 1
|
||||
if new_content != mock_content:
|
||||
mock_content = new_content
|
||||
print(f" ✓ 更新问题 {q_id}")
|
||||
else:
|
||||
print(f" ✗ 未能更新问题 {q_id}")
|
||||
|
||||
# 现在j指向 ] 的下一行
|
||||
# 插入新的面试题数据
|
||||
for position_name in position_names:
|
||||
if position_name in interview_questions_map:
|
||||
questions = interview_questions_map[position_name]
|
||||
if questions:
|
||||
questions_data = create_industry_questions(position_name, questions)
|
||||
# 生成JSON字符串(带缩进)
|
||||
questions_str = json.dumps(questions_data, ensure_ascii=False, indent=6)[1:-1] # 去掉外层的[]
|
||||
# 添加正确缩进
|
||||
indented_questions = '\n'.join([' ' + line for line in questions_str.split('\n')])
|
||||
new_lines.append(indented_questions)
|
||||
new_lines.append(' ]')
|
||||
update_count += 1
|
||||
print(f"✓ 已更新 {industry_name} 产业的面试题({len(questions)} 个问题)")
|
||||
# 更新i到j的位置,跳过旧的questions内容
|
||||
i = j - 1
|
||||
break
|
||||
else:
|
||||
# 如果没有找到对应的面试题,保持原样
|
||||
continue
|
||||
break
|
||||
i += 1
|
||||
updated_count += 1
|
||||
|
||||
# 如果没有更新任何产业,使用原内容
|
||||
if update_count == 0:
|
||||
print("未能更新任何产业,保持原文件不变")
|
||||
else:
|
||||
# 写回文件
|
||||
print(f"\n正在写入更新后的内容...")
|
||||
new_content = '\n'.join(new_lines)
|
||||
with open(mock_file, 'w', encoding='utf-8') as f:
|
||||
f.write(new_content)
|
||||
# 保存文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||||
f.write(mock_content)
|
||||
|
||||
print(f"\n更新完成!")
|
||||
print(f"成功更新: {update_count} 个产业的面试题")
|
||||
print(f"\n✅ 更新完成!处理了{updated_count}个岗位")
|
||||
|
||||
# 验证语法
|
||||
print("\n验证文件语法...")
|
||||
result = os.popen(f'node -c {mock_file} 2>&1').read()
|
||||
if result:
|
||||
print(f"❌ 语法错误: {result}")
|
||||
# 恢复备份
|
||||
print("正在恢复备份...")
|
||||
with open(backup_file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
with open(mock_file, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print("已恢复备份文件")
|
||||
else:
|
||||
print("✓ 语法验证通过")
|
||||
print("\n面试题更新成功!现在每个产业都有完整的面试题数据。")
|
||||
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()
|
||||
Reference in New Issue
Block a user