242 lines
7.6 KiB
JavaScript
242 lines
7.6 KiB
JavaScript
|
|
import fs from 'fs';
|
|||
|
|
import path from 'path';
|
|||
|
|
|
|||
|
|
// 读取当前的resumeInterviewMock.js文件
|
|||
|
|
const mockFilePath = './src/mocks/resumeInterviewMock.js';
|
|||
|
|
const mockContent = fs.readFileSync(mockFilePath, 'utf-8');
|
|||
|
|
|
|||
|
|
// 读取修改版简历文件夹
|
|||
|
|
const modifiedResumesPath = './网页未导入数据/环保产业/环保修改版简历';
|
|||
|
|
const modifiedResumeFiles = fs.readdirSync(modifiedResumesPath).filter(f => f.endsWith('.md'));
|
|||
|
|
|
|||
|
|
console.log('找到修改版简历文件:', modifiedResumeFiles.length, '个');
|
|||
|
|
|
|||
|
|
// 创建岗位名称到修改版简历内容的映射
|
|||
|
|
const modifiedResumesMap = {};
|
|||
|
|
|
|||
|
|
modifiedResumeFiles.forEach(file => {
|
|||
|
|
// 从文件名提取岗位名称(去掉.md扩展名)
|
|||
|
|
const positionName = file.replace('.md', '');
|
|||
|
|
const filePath = path.join(modifiedResumesPath, file);
|
|||
|
|
let content = fs.readFileSync(filePath, 'utf-8');
|
|||
|
|
|
|||
|
|
// 去掉第一行标题(如果有的话)
|
|||
|
|
const lines = content.split('\n');
|
|||
|
|
if (lines[0].startsWith('# ')) {
|
|||
|
|
lines.shift(); // 移除第一行
|
|||
|
|
}
|
|||
|
|
content = lines.join('\n').trim();
|
|||
|
|
|
|||
|
|
// 清理Markdown加粗语法 **文本** -> 文本
|
|||
|
|
content = content.replace(/\*\*(.*?)\*\*/g, '$1');
|
|||
|
|
|
|||
|
|
modifiedResumesMap[positionName] = content;
|
|||
|
|
console.log('读取修改版简历:', positionName);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 创建有修改版的岗位列表
|
|||
|
|
const modifiedPositionsList = Object.keys(modifiedResumesMap);
|
|||
|
|
|
|||
|
|
// 更新页面中的hasRealModifiedVersion函数
|
|||
|
|
const updatePageFile = () => {
|
|||
|
|
const pageFilePath = './src/pages/ResumeInterviewPage/index.jsx';
|
|||
|
|
let pageContent = fs.readFileSync(pageFilePath, 'utf-8');
|
|||
|
|
|
|||
|
|
// 找到并替换modifiedPositions数组
|
|||
|
|
const modifiedPositionsStr = modifiedPositionsList.map(p => ` "${p}"`).join(',\n');
|
|||
|
|
|
|||
|
|
const pattern = /const modifiedPositions = \[([\s\S]*?)\];/;
|
|||
|
|
const replacement = `const modifiedPositions = [
|
|||
|
|
// 环保产业岗位
|
|||
|
|
${modifiedPositionsStr}
|
|||
|
|
];`;
|
|||
|
|
|
|||
|
|
pageContent = pageContent.replace(pattern, replacement);
|
|||
|
|
|
|||
|
|
fs.writeFileSync(pageFilePath, pageContent);
|
|||
|
|
console.log('已更新页面的modifiedPositions列表');
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 读取环保岗位简历.json来更新resumeTemplates
|
|||
|
|
const updateResumeTemplates = () => {
|
|||
|
|
const envDataPath = './网页未导入数据/环保产业/环保岗位简历.json';
|
|||
|
|
const envData = JSON.parse(fs.readFileSync(envDataPath, 'utf-8'));
|
|||
|
|
|
|||
|
|
// 按岗位群分组
|
|||
|
|
const groupedData = {};
|
|||
|
|
|
|||
|
|
envData.forEach(item => {
|
|||
|
|
const groupName = item['简历岗位群'];
|
|||
|
|
if (!groupedData[groupName]) {
|
|||
|
|
groupedData[groupName] = [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 构建简历数据
|
|||
|
|
const resume = {
|
|||
|
|
position: item['岗位名称'],
|
|||
|
|
level: item['岗位等级标签'],
|
|||
|
|
avatar: item['简历头像url'],
|
|||
|
|
content: {
|
|||
|
|
original: item['简历内容']
|
|||
|
|
},
|
|||
|
|
studentInfo: {
|
|||
|
|
project_experience: {
|
|||
|
|
project_name: item['对应项目案例名称'],
|
|||
|
|
position: item['岗位名称'] + '助理',
|
|||
|
|
time_period: "XXXXXX",
|
|||
|
|
company: "XXXXXX",
|
|||
|
|
description: "参与项目实施"
|
|||
|
|
},
|
|||
|
|
core_skills: [],
|
|||
|
|
compound_skills: [],
|
|||
|
|
personal_summary: ""
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 检查是否有修改版
|
|||
|
|
if (modifiedResumesMap[item['岗位名称']]) {
|
|||
|
|
resume.content.modified = modifiedResumesMap[item['岗位名称']];
|
|||
|
|
console.log('添加修改版内容:', item['岗位名称']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 提取技能和总结
|
|||
|
|
const resumeContent = item['简历内容'];
|
|||
|
|
const coreSkillsMatch = resumeContent.match(/### (一)垂直能力\n\n([\s\S]*?)### (二)/);
|
|||
|
|
if (coreSkillsMatch) {
|
|||
|
|
const skills = coreSkillsMatch[1].split('\n')
|
|||
|
|
.filter(line => line.match(/^\d+\./))
|
|||
|
|
.map(line => line.replace(/^\d+\.\s*/, '').trim());
|
|||
|
|
resume.studentInfo.core_skills = skills.slice(0, 9);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const compoundSkillsMatch = resumeContent.match(/### (二)复合能力\n\n([\s\S]*?)#/);
|
|||
|
|
if (compoundSkillsMatch) {
|
|||
|
|
const skills = compoundSkillsMatch[1].split('\n')
|
|||
|
|
.filter(line => line.match(/^\d+\./))
|
|||
|
|
.map(line => line.replace(/^\d+\.\s*/, '').trim());
|
|||
|
|
resume.studentInfo.compound_skills = skills.slice(0, 9);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const summaryMatch = resumeContent.match(/# 三、个人评价\n\n([\s\S]*?)$/);
|
|||
|
|
if (summaryMatch) {
|
|||
|
|
resume.studentInfo.personal_summary = summaryMatch[1].trim();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
groupedData[groupName].push(resume);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 生成industries数据
|
|||
|
|
const industries = [];
|
|||
|
|
const resumeTemplates = {};
|
|||
|
|
let industryId = 1;
|
|||
|
|
|
|||
|
|
Object.keys(groupedData).forEach(groupName => {
|
|||
|
|
const industryData = {
|
|||
|
|
id: `env_${industryId}`,
|
|||
|
|
name: groupName,
|
|||
|
|
positions: [],
|
|||
|
|
questions: [
|
|||
|
|
{
|
|||
|
|
id: `group_q${industryId}`,
|
|||
|
|
question: `# 一、${groupName}专业问题`,
|
|||
|
|
subQuestions: [
|
|||
|
|
{
|
|||
|
|
id: `q${industryId}_1`,
|
|||
|
|
question: `请谈谈您对${groupName}领域的理解和认识?`,
|
|||
|
|
answer: `我对${groupName}有深入的理解,包括相关法规、技术标准和实施流程...`
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: `q${industryId}_2`,
|
|||
|
|
question: `在${groupName}项目中,您如何保证项目质量?`,
|
|||
|
|
answer: `我会通过建立完善的质量管理体系,严格执行相关标准...`
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 为每个岗位创建positions数据
|
|||
|
|
groupedData[groupName].forEach((resume, idx) => {
|
|||
|
|
const position = {
|
|||
|
|
id: `env_${industryId}_${idx + 1}`,
|
|||
|
|
title: resume.position,
|
|||
|
|
level: resume.level,
|
|||
|
|
avatar: resume.avatar,
|
|||
|
|
department: groupName,
|
|||
|
|
type: "全职",
|
|||
|
|
experience: "1-3年",
|
|||
|
|
education: "大专",
|
|||
|
|
salary: "5-15K",
|
|||
|
|
location: "苏州",
|
|||
|
|
updateTime: "2024-01-20",
|
|||
|
|
description: `负责${resume.position}相关工作`,
|
|||
|
|
requirements: resume.studentInfo.core_skills.slice(0, 4)
|
|||
|
|
};
|
|||
|
|
industryData.positions.push(position);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 不限制岗位数量,显示所有岗位
|
|||
|
|
|
|||
|
|
industries.push(industryData);
|
|||
|
|
resumeTemplates[groupName] = groupedData[groupName];
|
|||
|
|
industryId++;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 生成最终的JS文件内容
|
|||
|
|
const jsContent = `// 简历与面试题Mock数据
|
|||
|
|
|
|||
|
|
// 岗位群列表
|
|||
|
|
const industries = ${JSON.stringify(industries, null, 2)};
|
|||
|
|
|
|||
|
|
// 学生个人简历(通用)
|
|||
|
|
const myResume = {
|
|||
|
|
"name": "张三",
|
|||
|
|
"gender": "男",
|
|||
|
|
"age": "22",
|
|||
|
|
"education": "大专",
|
|||
|
|
"major": "环境工程技术",
|
|||
|
|
"school": "苏州职业技术学院",
|
|||
|
|
"phone": "138****5678",
|
|||
|
|
"email": "zhangsan@example.com",
|
|||
|
|
"address": "江苏省苏州市",
|
|||
|
|
"skills": [
|
|||
|
|
"环境监测与评价",
|
|||
|
|
"节能技术应用",
|
|||
|
|
"环保设备运维",
|
|||
|
|
"数据分析处理"
|
|||
|
|
],
|
|||
|
|
"certificates": [
|
|||
|
|
"环境影响评价工程师(初级)",
|
|||
|
|
"ISO 14001内审员"
|
|||
|
|
],
|
|||
|
|
"internship": "在多家环保企业实习,参与环评项目、节能改造等工作",
|
|||
|
|
"selfIntroduction": "我是一名环境工程技术专业的应届毕业生,对环保事业充满热情..."
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 简历模板数据
|
|||
|
|
const resumeTemplates = ${JSON.stringify(resumeTemplates, null, 2)};
|
|||
|
|
|
|||
|
|
// Mock数据整合
|
|||
|
|
const resumeInterviewMockData = {
|
|||
|
|
industries,
|
|||
|
|
myResume,
|
|||
|
|
resumeTemplates
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 导出函数
|
|||
|
|
export const getMockPageData = () => {
|
|||
|
|
return resumeInterviewMockData;
|
|||
|
|
};
|
|||
|
|
`;
|
|||
|
|
|
|||
|
|
// 写入文件
|
|||
|
|
fs.writeFileSync('./src/mocks/resumeInterviewMock.js', jsContent);
|
|||
|
|
console.log('resumeInterviewMock.js更新完成!');
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 执行更新
|
|||
|
|
updatePageFile();
|
|||
|
|
updateResumeTemplates();
|
|||
|
|
|
|||
|
|
console.log('\n修改版简历数据替换完成!');
|
|||
|
|
console.log('共处理了', modifiedResumeFiles.length, '个修改版简历');
|