112 lines
4.2 KiB
JavaScript
112 lines
4.2 KiB
JavaScript
|
|
import fs from 'fs';
|
|||
|
|
import path from 'path';
|
|||
|
|
|
|||
|
|
// 修改版简历的岗位列表
|
|||
|
|
const modifiedPositions = [
|
|||
|
|
"AGV运维专员",
|
|||
|
|
"WMS技术顾问",
|
|||
|
|
"物流运营",
|
|||
|
|
"物流安全员",
|
|||
|
|
"物流工程师",
|
|||
|
|
"智能仓储规划师",
|
|||
|
|
"无人仓拣选工程师",
|
|||
|
|
"机器人运维工程师",
|
|||
|
|
"智能仓储运维工程师",
|
|||
|
|
"智慧物流解决方案工程师"
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
console.log('开始更新修改版简历数据...\n');
|
|||
|
|
|
|||
|
|
// 1. 首先更新 ResumeInterviewPage 的 hasRealModifiedVersion 函数
|
|||
|
|
const pageFilePath = 'src/pages/ResumeInterviewPage/index.jsx';
|
|||
|
|
let pageContent = fs.readFileSync(pageFilePath, 'utf-8');
|
|||
|
|
|
|||
|
|
// 替换 modifiedPositions 数组
|
|||
|
|
const newModifiedPositions = ` const modifiedPositions = [
|
|||
|
|
// 交通物流产业岗位
|
|||
|
|
"AGV运维专员",
|
|||
|
|
"WMS技术顾问",
|
|||
|
|
"物流运营",
|
|||
|
|
"物流安全员",
|
|||
|
|
"物流工程师",
|
|||
|
|
"智能仓储规划师",
|
|||
|
|
"无人仓拣选工程师",
|
|||
|
|
"机器人运维工程师",
|
|||
|
|
"智能仓储运维工程师",
|
|||
|
|
"智慧物流解决方案工程师"
|
|||
|
|
];`;
|
|||
|
|
|
|||
|
|
pageContent = pageContent.replace(
|
|||
|
|
/const modifiedPositions = \[[\s\S]*?\];/,
|
|||
|
|
newModifiedPositions
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
fs.writeFileSync(pageFilePath, pageContent, 'utf-8');
|
|||
|
|
console.log('✓ 已更新 ResumeInterviewPage 的修改版岗位列表\n');
|
|||
|
|
|
|||
|
|
// 2. 读取所有修改版简历内容
|
|||
|
|
const modifiedResumesDir = '网页未导入数据/交通物流产业/交通物流修改版简历';
|
|||
|
|
const modifiedResumes = {};
|
|||
|
|
|
|||
|
|
for (const position of modifiedPositions) {
|
|||
|
|
const filePath = path.join(modifiedResumesDir, `${position}.md`);
|
|||
|
|
if (fs.existsSync(filePath)) {
|
|||
|
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|||
|
|
modifiedResumes[position] = content;
|
|||
|
|
console.log(`✓ 读取修改版简历: ${position}`);
|
|||
|
|
} else {
|
|||
|
|
console.log(`✗ 未找到修改版简历文件: ${position}.md`);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 3. 读取当前的 mock 数据
|
|||
|
|
const mockFilePath = 'src/mocks/resumeInterviewMock.js';
|
|||
|
|
let mockContent = fs.readFileSync(mockFilePath, 'utf-8');
|
|||
|
|
|
|||
|
|
// 4. 解析并更新 resumeTemplates 中对应岗位的 modified 字段
|
|||
|
|
// 由于文件是 JavaScript,我们需要通过字符串替换来更新
|
|||
|
|
console.log('\n开始更新 resumeTemplates 的 modified 字段...');
|
|||
|
|
|
|||
|
|
// 读取交通物流原始数据来建立映射
|
|||
|
|
const originalData = JSON.parse(fs.readFileSync('网页未导入数据/交通物流产业/交通物流岗位简历.json', 'utf-8'));
|
|||
|
|
|
|||
|
|
// 为每个修改版岗位更新数据
|
|||
|
|
for (const [position, modifiedContent] of Object.entries(modifiedResumes)) {
|
|||
|
|
// 找到原始数据
|
|||
|
|
const originalItem = originalData.find(item => item.岗位名称 === position);
|
|||
|
|
|
|||
|
|
if (originalItem) {
|
|||
|
|
// 在 mockContent 中查找并替换该岗位的 content.modified
|
|||
|
|
// 使用更精确的正则表达式来匹配特定岗位的 content 部分
|
|||
|
|
const positionPattern = new RegExp(
|
|||
|
|
`("position":\\s*"${position}"[\\s\\S]*?"content":\\s*\\{[\\s\\S]*?"modified":\\s*)"[^"]*"`,
|
|||
|
|
'g'
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// 转义修改版内容中的特殊字符
|
|||
|
|
const escapedContent = JSON.stringify(modifiedContent).slice(1, -1);
|
|||
|
|
|
|||
|
|
// 替换 modified 字段
|
|||
|
|
const replacement = `$1"${escapedContent}"`;
|
|||
|
|
|
|||
|
|
if (mockContent.match(positionPattern)) {
|
|||
|
|
mockContent = mockContent.replace(positionPattern, replacement);
|
|||
|
|
console.log(`✓ 更新岗位 "${position}" 的修改版简历`);
|
|||
|
|
} else {
|
|||
|
|
console.log(`✗ 未找到岗位 "${position}" 在 resumeTemplates 中`);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 5. 保存更新后的 mock 文件
|
|||
|
|
// 先备份
|
|||
|
|
const backupFileName = `src/mocks/resumeInterviewMock.js.backup_modified_${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|||
|
|
fs.copyFileSync(mockFilePath, backupFileName);
|
|||
|
|
console.log(`\n原文件已备份到: ${backupFileName}`);
|
|||
|
|
|
|||
|
|
fs.writeFileSync(mockFilePath, mockContent, 'utf-8');
|
|||
|
|
console.log('✓ resumeInterviewMock.js 已更新\n');
|
|||
|
|
|
|||
|
|
console.log('修改版简历数据更新完成!');
|
|||
|
|
console.log(`- 更新了 ${modifiedPositions.length} 个岗位的修改版状态`);
|
|||
|
|
console.log(`- 成功读取并更新了 ${Object.keys(modifiedResumes).length} 个修改版简历内容`);
|