更新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:
119
frontend_智能制造/fix_interview_structure.py
Normal file
119
frontend_智能制造/fix_interview_structure.py
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
# 读取mock文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 备份原文件
|
||||
backup_time = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
with open(f'src/mocks/resumeInterviewMock.js.backup_{backup_time}', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print(f"已创建备份文件: src/mocks/resumeInterviewMock.js.backup_{backup_time}")
|
||||
|
||||
def process_questions_array(questions_str):
|
||||
"""处理questions数组,将多个section合并成一个"""
|
||||
|
||||
# 提取所有的subQuestions
|
||||
all_questions = []
|
||||
|
||||
# 找到所有的subQuestions数组
|
||||
pattern = r'"subQuestions":\s*\[(.*?)\]'
|
||||
matches = re.finditer(pattern, questions_str, re.DOTALL)
|
||||
|
||||
question_counter = 1
|
||||
for match in matches:
|
||||
sub_questions_content = match.group(1)
|
||||
|
||||
# 提取每个问题和答案
|
||||
q_pattern = r'"question":\s*"([^"\\]*(?:\\.[^"\\]*)*)"[,\s]*"answer":\s*"([^"\\]*(?:\\.[^"\\]*)*)"'
|
||||
q_matches = re.finditer(q_pattern, sub_questions_content)
|
||||
|
||||
for q_match in q_matches:
|
||||
question = q_match.group(1)
|
||||
answer = q_match.group(2)
|
||||
|
||||
# 处理答案格式
|
||||
# 1. 单个字母答案(选择题)保持原样
|
||||
# 2. 其他答案处理换行为<br/>
|
||||
if len(answer.strip()) == 1 and answer.strip() in 'ABCDEFGH':
|
||||
formatted_answer = answer
|
||||
else:
|
||||
# 替换换行符
|
||||
formatted_answer = answer.replace('\\n', '<br/>')
|
||||
# 如果有选项,只保留正确答案内容
|
||||
if 'A.' in formatted_answer or 'B.' in formatted_answer:
|
||||
# 移除选项标记
|
||||
formatted_answer = re.sub(r'[A-H]\.\s*', '', formatted_answer)
|
||||
|
||||
all_questions.append({
|
||||
'id': f'q_{question_counter}',
|
||||
'question': question,
|
||||
'answer': formatted_answer
|
||||
})
|
||||
question_counter += 1
|
||||
|
||||
# 构建新的questions数组字符串
|
||||
result = '[\n {\n'
|
||||
result += ' "id": "all_questions",\n'
|
||||
result += ' "question": "面试题集",\n'
|
||||
result += ' "subQuestions": [\n'
|
||||
|
||||
for i, q in enumerate(all_questions):
|
||||
# 转义引号
|
||||
question_escaped = q['question'].replace('"', '\\"')
|
||||
answer_escaped = q['answer'].replace('"', '\\"')
|
||||
|
||||
result += ' {\n'
|
||||
result += f' "id": "{q["id"]}",\n'
|
||||
result += f' "question": "{question_escaped}",\n'
|
||||
result += f' "answer": "{answer_escaped}"\n'
|
||||
result += ' }'
|
||||
|
||||
if i < len(all_questions) - 1:
|
||||
result += ','
|
||||
result += '\n'
|
||||
|
||||
result += ' ]\n'
|
||||
result += ' }\n ]'
|
||||
|
||||
return result
|
||||
|
||||
# 处理每个岗位群的questions数组
|
||||
def process_content(content):
|
||||
# 找到所有的questions数组
|
||||
pattern = r'("questions":\s*\[)(.*?)(\]\s*\})'
|
||||
|
||||
def replacer(match):
|
||||
prefix = match.group(1)
|
||||
questions_content = match.group(2)
|
||||
suffix = match.group(3)
|
||||
|
||||
# 如果已经是合并后的格式,跳过
|
||||
if '"id": "all_questions"' in questions_content:
|
||||
return match.group(0)
|
||||
|
||||
# 处理questions内容
|
||||
new_questions = process_questions_array(questions_content)
|
||||
|
||||
return prefix + new_questions[1:-1] + suffix
|
||||
|
||||
# 替换所有的questions数组
|
||||
result = re.sub(pattern, replacer, content, flags=re.DOTALL)
|
||||
|
||||
return result
|
||||
|
||||
# 处理文件
|
||||
processed_content = process_content(content)
|
||||
|
||||
# 保存处理后的文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||||
f.write(processed_content)
|
||||
|
||||
print("✅ 面试题结构修改完成!")
|
||||
print("- 所有题目已合并到同一张卡片")
|
||||
print("- 答案换行已转换为<br/>标签")
|
||||
print("- 选择题答案已处理为只显示正确答案")
|
||||
Reference in New Issue
Block a user