Files
ALL-teach_sys/frontend_视觉设计/generate_questions_js.py
KQL 38350dca36 更新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>
2025-10-17 14:36:25 +08:00

78 lines
2.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import re
def load_visual_design_data():
"""加载视觉设计岗位简历数据"""
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
return json.load(f)
def extract_questions_from_content(content):
"""从面试题内容中提取问题和答案"""
questions = []
# 找到所有问题和答案对
pattern = r'(\d+)\.\s*问题[:]?\s*(.*?)(?:\n\s*)?(?:参考回答[:]?)(.*?)(?=\d+\.\s*问题|$)'
matches = re.findall(pattern, content, re.DOTALL)
for match in matches[:5]: # 限制为前5个问题
q_num = match[0]
question_text = match[1].strip()
answer_text = match[2].strip()
questions.append({
"id": f"q{q_num}",
"question": question_text,
"answer": answer_text
})
return questions
def generate_js_code():
"""生成可以直接使用的JS代码"""
visual_data = load_visual_design_data()
# 生成一个映射对象
questions_map = {}
for item in visual_data:
position_name = item.get('岗位名称', '')
interview_content = item.get('面试题内容', '')
if position_name and interview_content:
questions = extract_questions_from_content(interview_content)
if questions:
questions_map[position_name] = questions
# 生成JS代码
js_code = "// 视觉设计产业岗位面试题数据\nconst visualDesignQuestions = {\n"
for position_name, questions in questions_map.items():
js_code += f' "{position_name}": [\n'
for q in questions:
# 对特殊字符进行转义
question_escaped = q['question'].replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')
answer_escaped = q['answer'].replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')
js_code += f''' {{
id: "{q['id']}",
question: "{question_escaped}",
answer: "{answer_escaped}"
}},\n'''
js_code = js_code.rstrip(',\n') + '\n ],\n'
js_code = js_code.rstrip(',\n') + '\n};\n\nexport default visualDesignQuestions;'
# 保存到文件
with open('visualDesignQuestions.js', 'w', encoding='utf-8') as f:
f.write(js_code)
print("已生成visualDesignQuestions.js文件")
print(f"包含{len(questions_map)}个岗位的面试题数据")
if __name__ == '__main__':
generate_js_code()