Files
ALL-teach_sys/frontend_食品/generateCompleteQuestions.js
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含12个产业的完整教务系统前端代码
- 智能启动脚本 (start-industry.sh)
- 可视化产业导航页面 (index.html)
- 项目文档 (README.md)

优化内容:
- 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB
- 添加.gitignore文件避免上传不必要的文件
- 自动依赖管理和智能启动系统

产业列表:
1. 文旅产业 (5150)
2. 智能制造 (5151)
3. 智能开发 (5152)
4. 财经商贸 (5153)
5. 视觉设计 (5154)
6. 交通物流 (5155)
7. 大健康 (5156)
8. 土木水利 (5157)
9. 食品产业 (5158)
10. 化工产业 (5159)
11. 能源产业 (5160)
12. 环保产业 (5161)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 14:14:14 +08:00

100 lines
2.9 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// 读取面试题数据
const interviewQuestionsData = JSON.parse(
fs.readFileSync(path.join(__dirname, 'src/data/interviewQuestions.json'), 'utf-8')
);
// 解析面试题内容 - 获取所有题目
function parseAllInterviewQuestions(content) {
if (!content) return [];
const questions = [];
const lines = content.split('\n').filter(line => line.trim());
let currentQuestion = null;
let currentAnswer = '';
let collectingAnswer = false;
let questionIndex = 0;
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
// 跳过标题行
if (line.startsWith('#')) {
continue;
}
// 匹配问题(数字开头)
if (/^\d+\./.test(line)) {
// 保存上一个问题
if (currentQuestion && currentAnswer) {
questions.push({
id: `q${questionIndex + 1}`,
question: currentQuestion,
answer: currentAnswer.trim()
});
questionIndex++;
}
// 开始新问题
currentQuestion = line.replace(/^\d+\.\s*/, '').trim();
currentAnswer = '';
collectingAnswer = false;
}
// 匹配答案标记
else if (line.includes('答案:') || line.includes('示例回答:') || line.includes('参考答案:')) {
collectingAnswer = true;
// 提取答案内容(可能在同一行)
const answerMatch = line.match(/(?:答案:|示例回答:|参考答案:)(.*)/);
if (answerMatch && answerMatch[1]) {
currentAnswer = answerMatch[1].trim();
}
}
// 收集答案内容
else if (collectingAnswer && line) {
if (currentAnswer) {
currentAnswer += ' ';
}
currentAnswer += line;
}
}
// 保存最后一个问题
if (currentQuestion && currentAnswer) {
questions.push({
id: `q${questionIndex + 1}`,
question: currentQuestion,
answer: currentAnswer.trim()
});
}
return questions;
}
// 生成每个岗位群的完整面试题
interviewQuestionsData.forEach(item => {
const groupName = item['岗位群名称'];
const questions = parseAllInterviewQuestions(item['面试题内容']);
if (questions.length > 0) {
console.log(`\n// ========== ${groupName} ==========`);
console.log(`// 共${questions.length}道题`);
console.log(`const ${groupName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '')}Questions = [`);
questions.forEach((q, index) => {
console.log(` {`);
console.log(` id: "${q.id}",`);
console.log(` question: "${q.question.replace(/"/g, '\\"')}",`);
console.log(` answer: \`${q.answer.replace(/`/g, '\\`')}\``);
console.log(` }${index < questions.length - 1 ? ',' : ''}`);
});
console.log(`];`);
}
});