Files
ALL-teach_sys/frontend_交通物流/fixInterviewStatusFunction.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

142 lines
4.9 KiB
JavaScript
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.

import fs from 'fs';
// 读取当前的 mockData.js 文件
let mockDataContent = fs.readFileSync('src/data/mockData.js', 'utf-8');
// 定义新的 transformInterviewStatus 函数
const newTransformInterviewStatusFunction = `// 转换面试状态数据
const transformInterviewStatus = (statusData, jobsData) => {
if (!Array.isArray(statusData)) {
console.warn('statusData is not an array:', statusData);
return [];
}
return statusData
.map((status, index) => {
if (!status || typeof status !== 'object') {
console.warn('Invalid status item:', status);
return null;
}
// 从岗位数据中查找匹配的岗位详情
const matchedJob = jobsData.find(job =>
job["内推岗位名称"] === status["岗位名称"]
);
// 解析日期
let formattedDate;
let interviewDate;
// 处理不同的日期格式
const dateString = status["投递时间"] || "2024-01-01";
if (dateString && dateString.includes('-')) {
// 标准格式YYYY-MM-DD
formattedDate = dateString;
interviewDate = new Date(dateString);
} else if (dateString && dateString.includes('/')) {
// 格式YYYY/M/D
const dateParts = dateString.split('/');
if (dateParts.length === 3) {
formattedDate = \`\${dateParts[0]}-\${dateParts[1].padStart(2, '0')}-\${dateParts[2].padStart(2, '0')}\`;
interviewDate = new Date(parseInt(dateParts[0]), parseInt(dateParts[1]) - 1, parseInt(dateParts[2]));
} else {
formattedDate = dateString;
interviewDate = new Date();
}
} else {
formattedDate = dateString;
interviewDate = new Date();
}
// 根据面试状态确定状态码和文本
let statusCode = 'PENDING';
let statusText = status["面试状态"] || "已投递";
if (statusText === "已通过" || statusText === "收到Offer") {
statusCode = 'OFFER';
} else if (statusText === "未通过" || statusText === "面试未通过") {
statusCode = 'FAILED';
} else if (statusText === "面试中") {
statusCode = 'INTERVIEW';
} else if (statusText === "笔试中") {
statusCode = 'TEST';
}
return {
id: index + 1,
position: status["岗位名称"] || "未知岗位",
interviewTime: formattedDate,
interviewDate: interviewDate,
status: statusCode,
statusText: statusText,
progress: status["面试进度"] || 25,
nextStep: status["下一步"] || "等待回复",
job: matchedJob ? {
salary: matchedJob["薪资"],
tags: matchedJob["职位标签"] || [],
location: matchedJob["工作地点"],
education: matchedJob["学历要求"],
companyInfo: matchedJob["公司介绍"],
jobCategory: matchedJob["岗位相关标签"] || "专业相关岗位",
remainingPositions: matchedJob["招聘人数"] ? parseInt(matchedJob["招聘人数"]) : 5,
description: matchedJob["职位描述"],
requirements: matchedJob["任职要求"]
} : null
};
})
.filter(item => item !== null)
.sort((a, b) => b.interviewDate - a.interviewDate);
};`;
// 查找并替换整个 transformInterviewStatus 函数
const functionStartPattern = /\/\/ 转换面试状态数据\s*const transformInterviewStatus = \(statusData, jobsData\) => \{/;
const functionEndPattern = /\};\s*(?=\/\/|const|export|$)/;
// 找到函数开始位置
const startMatch = mockDataContent.match(functionStartPattern);
if (startMatch) {
const startIndex = startMatch.index;
// 从开始位置查找函数结束位置
let braceCount = 0;
let foundStart = false;
let endIndex = startIndex;
for (let i = startIndex; i < mockDataContent.length; i++) {
const char = mockDataContent[i];
if (char === '{') {
braceCount++;
foundStart = true;
} else if (char === '}') {
braceCount--;
if (foundStart && braceCount === 0) {
endIndex = i + 1;
// 查找分号
if (mockDataContent[i + 1] === ';') {
endIndex = i + 2;
}
break;
}
}
}
// 替换函数
const beforeFunction = mockDataContent.substring(0, startIndex);
const afterFunction = mockDataContent.substring(endIndex);
mockDataContent = beforeFunction + newTransformInterviewStatusFunction + afterFunction;
// 备份原文件
const backupFileName = \`src/data/mockData.js.backup_interview_fix_\${new Date().toISOString().replace(/[:.]/g, '-')}\`;
fs.copyFileSync('src/data/mockData.js', backupFileName);
console.log(\`原文件已备份到: \${backupFileName}\`);
// 保存修复后的文件
fs.writeFileSync('src/data/mockData.js', mockDataContent, 'utf-8');
console.log('transformInterviewStatus 函数已修复');
} else {
console.log('未找到 transformInterviewStatus 函数');
}
console.log('修复完成!');