主要更新: - 更新所有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>
133 lines
3.9 KiB
JavaScript
133 lines
3.9 KiB
JavaScript
#!/usr/bin/env node
|
||
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
// Load visual design data
|
||
const visualDesignData = JSON.parse(
|
||
fs.readFileSync('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'utf-8')
|
||
);
|
||
|
||
// Create backup
|
||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
|
||
const backupPath = `src/mocks/resumeInterviewMock.js.backup_${timestamp}`;
|
||
const mockContent = fs.readFileSync('src/mocks/resumeInterviewMock.js', 'utf-8');
|
||
fs.writeFileSync(backupPath, mockContent);
|
||
console.log(`✓ Backup created: ${backupPath}`);
|
||
|
||
// Position mapping
|
||
const industryPositionMap = {
|
||
'UI设计': 'UI设计师',
|
||
'包装设计': '包装设计师',
|
||
'插画设计': '插画师',
|
||
'灯光': '影视灯光',
|
||
'动画设计': '动画师',
|
||
'后期特效': '特效设计师',
|
||
'剪辑': '剪辑师',
|
||
'品牌设计': '品牌视觉内容策划',
|
||
'平面设计': '平面设计师',
|
||
'三维设计': 'CG总监助理',
|
||
'摄影/摄像': '摄影师',
|
||
'室内设计': '室内设计师',
|
||
'调色': '调色师',
|
||
'新媒体运营': '新媒体运营专员',
|
||
'音频处理': '录音师',
|
||
'影视节目策划': '文案策划',
|
||
'直播': '直播专员'
|
||
};
|
||
|
||
// Extract questions from content
|
||
function extractQuestions(content, industryName) {
|
||
const questions = [];
|
||
const pattern = /(\d+)\.\s*问题[::]?\s*(.*?)(?:\n\s*)?(?:参考回答[::]?)(.*?)(?=\d+\.\s*问题|$)/gs;
|
||
let match;
|
||
let count = 0;
|
||
|
||
while ((match = pattern.exec(content)) && count < 5) {
|
||
count++;
|
||
const questionText = match[2].trim();
|
||
const answerText = match[3].trim();
|
||
|
||
questions.push({
|
||
id: `q1_${count}`,
|
||
question: questionText,
|
||
answer: answerText
|
||
});
|
||
}
|
||
|
||
if (questions.length > 0) {
|
||
return [{
|
||
id: "group_q1",
|
||
question: `# ${industryName}面试题`,
|
||
subQuestions: questions
|
||
}];
|
||
}
|
||
|
||
return [];
|
||
}
|
||
|
||
let updatedContent = mockContent;
|
||
let successCount = 0;
|
||
|
||
// Process each industry
|
||
for (const [industryName, positionName] of Object.entries(industryPositionMap)) {
|
||
console.log(`Processing ${industryName}...`);
|
||
|
||
// Find interview content
|
||
const positionData = visualDesignData.find(
|
||
item => item['岗位名称'] === positionName && item['面试题内容']
|
||
);
|
||
|
||
if (!positionData) {
|
||
console.log(` ⚠️ No interview questions found for ${positionName}`);
|
||
continue;
|
||
}
|
||
|
||
// Extract questions
|
||
const questions = extractQuestions(positionData['面试题内容'], industryName);
|
||
|
||
if (questions.length === 0) {
|
||
console.log(` ⚠️ Could not extract questions for ${positionName}`);
|
||
continue;
|
||
}
|
||
|
||
// Create the replacement string
|
||
const questionsStr = JSON.stringify(questions, null, 4)
|
||
.split('\n')
|
||
.map(line => ' ' + line)
|
||
.join('\n')
|
||
.trim();
|
||
|
||
// Find the industry section and replace questions
|
||
const industryPattern = new RegExp(
|
||
`("name":\\s*"${industryName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}"[^}]*?"questions":\\s*)\\[[\\s\\S]*?\\](?=\\s*\\})`,
|
||
'g'
|
||
);
|
||
|
||
const newContent = updatedContent.replace(industryPattern, (match, prefix) => {
|
||
successCount++;
|
||
console.log(` ✓ Updated (using ${positionName}, ${questions[0].subQuestions.length} questions)`);
|
||
return prefix + questionsStr;
|
||
});
|
||
|
||
if (newContent === updatedContent) {
|
||
console.log(` ✗ Failed to update`);
|
||
} else {
|
||
updatedContent = newContent;
|
||
}
|
||
}
|
||
|
||
// Save the updated file
|
||
fs.writeFileSync('src/mocks/resumeInterviewMock.js', updatedContent);
|
||
console.log(`\n✅ Update complete! Successfully updated ${successCount} industry groups`);
|
||
|
||
// Verify syntax
|
||
const { execSync } = require('child_process');
|
||
try {
|
||
execSync('node -c src/mocks/resumeInterviewMock.js', { encoding: 'utf-8' });
|
||
console.log('✅ Syntax validation passed');
|
||
} catch (error) {
|
||
console.error('❌ Syntax error detected, restoring backup...');
|
||
fs.writeFileSync('src/mocks/resumeInterviewMock.js', mockContent);
|
||
console.log('Backup restored');
|
||
} |