更新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:
104
frontend_智能制造/final_fix_interview.py
Normal file
104
frontend_智能制造/final_fix_interview.py
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
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_final_{backup_time}', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print(f"已创建备份文件: src/mocks/resumeInterviewMock.js.backup_final_{backup_time}")
|
||||
|
||||
def merge_questions(match):
|
||||
"""合并questions数组中的所有题目到一个对象"""
|
||||
full_match = match.group(0)
|
||||
questions_content = match.group(1)
|
||||
|
||||
# 提取所有的subQuestions
|
||||
all_sub_questions = []
|
||||
|
||||
# 查找所有的subQuestions数组
|
||||
sub_pattern = r'"subQuestions":\s*\[(.*?)\](?=\s*\})'
|
||||
sub_matches = re.finditer(sub_pattern, questions_content, re.DOTALL)
|
||||
|
||||
question_counter = 1
|
||||
for sub_match in sub_matches:
|
||||
sub_content = sub_match.group(1)
|
||||
|
||||
# 提取每个问题和答案
|
||||
q_pattern = r'"id":\s*"[^"]+",\s*"question":\s*"([^"\\]*(?:\\.[^"\\]*)*)",\s*"answer":\s*"([^"\\]*(?:\\.[^"\\]*)*)"'
|
||||
q_matches = re.finditer(q_pattern, sub_content)
|
||||
|
||||
for q_match in q_matches:
|
||||
question = q_match.group(1)
|
||||
answer = q_match.group(2)
|
||||
|
||||
# 处理答案格式
|
||||
if len(answer.strip()) == 1 and answer.strip() in 'ABCDEFGH':
|
||||
# 选择题单字母答案
|
||||
formatted_answer = answer
|
||||
else:
|
||||
# 处理换行
|
||||
formatted_answer = answer.replace('\\n', '<br/>')
|
||||
# 移除选项标记(如 A. B. C.)
|
||||
formatted_answer = re.sub(r'\\s*[A-H]\\.\\s*', '', formatted_answer)
|
||||
|
||||
all_sub_questions.append({
|
||||
'id': f'q_{question_counter}',
|
||||
'question': question,
|
||||
'answer': formatted_answer
|
||||
})
|
||||
question_counter += 1
|
||||
|
||||
# 构建新的questions数组
|
||||
result = '"questions": [\n {\n'
|
||||
result += ' "id": "all_questions",\n'
|
||||
result += ' "question": "面试题集",\n'
|
||||
result += ' "subQuestions": [\n'
|
||||
|
||||
for i, q in enumerate(all_sub_questions):
|
||||
# 确保引号被正确转义
|
||||
question_str = q['question'].replace('\\', '\\\\').replace('"', '\\"')
|
||||
answer_str = q['answer'].replace('\\', '\\\\').replace('"', '\\"')
|
||||
|
||||
result += ' {\n'
|
||||
result += f' "id": "{q["id"]}",\n'
|
||||
result += f' "question": "{question_str}",\n'
|
||||
result += f' "answer": "{answer_str}"\n'
|
||||
result += ' }'
|
||||
|
||||
if i < len(all_sub_questions) - 1:
|
||||
result += ','
|
||||
result += '\n'
|
||||
|
||||
result += ' ]\n'
|
||||
result += ' }\n ]'
|
||||
|
||||
return result
|
||||
|
||||
# 处理所有的questions数组
|
||||
pattern = r'"questions":\s*\[(.*?)\]\s*(?=\})'
|
||||
new_content = re.sub(pattern, merge_questions, content, flags=re.DOTALL)
|
||||
|
||||
# 保存处理后的文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||||
f.write(new_content)
|
||||
|
||||
print("✅ 面试题结构修改完成!")
|
||||
print("- 所有题目已合并到同一张卡片")
|
||||
print("- 答案换行已转换为<br/>标签")
|
||||
print("- 选择题答案已处理为只显示正确答案")
|
||||
|
||||
# 验证语法
|
||||
import subprocess
|
||||
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
|
||||
capture_output=True, text=True)
|
||||
if result.returncode == 0:
|
||||
print("✅ 语法检查通过!")
|
||||
else:
|
||||
print("❌ 语法错误:")
|
||||
print(result.stderr)
|
||||
Reference in New Issue
Block a user