fix: 修复mockData.js语法错误
- 修复正则表达式中未转义的换行符 - 添加缺失的transformCalendarCourses函数定义 - 删除重复的classInfo键 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -50,8 +50,7 @@ const transformCompanyJobs = (jobsData) => {
|
|||||||
education: job["学历要求"],
|
education: job["学历要求"],
|
||||||
positions: job["招聘人数"],
|
positions: job["招聘人数"],
|
||||||
description: job["职位描述"],
|
description: job["职位描述"],
|
||||||
requirements: job["任职要求"] ? job["任职要求"].split(/[;;。
|
requirements: job["任职要求"] ? job["任职要求"].split(/[;;。\n]/).filter(r => r.trim()) : [],
|
||||||
]/).filter(r => r.trim()) : [],
|
|
||||||
benefits: job["福利标签"] || [],
|
benefits: job["福利标签"] || [],
|
||||||
companyInfo: job["公司介绍"]
|
companyInfo: job["公司介绍"]
|
||||||
}
|
}
|
||||||
@@ -129,6 +128,103 @@ const transformAICourses = (aiData) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 转换函数:将日历课程JSON数据转换为日历事件格式
|
||||||
|
const transformCalendarCourses = (coursesData) => {
|
||||||
|
return coursesData
|
||||||
|
.filter(course => course["❌课程状态"] !== "休息" && course["日期"])
|
||||||
|
.map((course, index) => {
|
||||||
|
// 解析日期
|
||||||
|
const dateStr = course["日期"];
|
||||||
|
const [year, month, day] = dateStr.split('/').map(Number);
|
||||||
|
const courseDate = new Date(year, month - 1, day);
|
||||||
|
|
||||||
|
// 获取课程名称(优先级从高到低)
|
||||||
|
const courseName = course["复合技能阶段"] ||
|
||||||
|
course["公开课"] ||
|
||||||
|
course["垂直方向阶段(方向二:商业活动策划)"] ||
|
||||||
|
course["1V1 规划阶段"] ||
|
||||||
|
course["模拟面试实战练习阶段"] ||
|
||||||
|
"未命名课程";
|
||||||
|
|
||||||
|
// 解析上课时间
|
||||||
|
const timeStr = course["上课时间"] || "20:00-21:00";
|
||||||
|
let startTime = "20:00";
|
||||||
|
let endTime = "21:00";
|
||||||
|
|
||||||
|
// 特殊处理1V1规划课程的时间
|
||||||
|
if (course["1V1 规划阶段"]) {
|
||||||
|
startTime = "14:00";
|
||||||
|
endTime = "16:00";
|
||||||
|
} else {
|
||||||
|
// 处理时间格式,确保有效
|
||||||
|
if (timeStr && timeStr.includes('-')) {
|
||||||
|
const timeParts = timeStr.split('-').map(t => t ? t.trim() : '');
|
||||||
|
if (timeParts[0]) startTime = timeParts[0];
|
||||||
|
if (timeParts[1]) endTime = timeParts[1];
|
||||||
|
} else if (timeStr) {
|
||||||
|
// 如果没有'-',假设是开始时间
|
||||||
|
startTime = timeStr.trim();
|
||||||
|
// 自动计算结束时间(加1小时)
|
||||||
|
const [hour, minute] = startTime.split(':');
|
||||||
|
const endHour = parseInt(hour) + 1;
|
||||||
|
endTime = `${endHour.toString().padStart(2, '0')}:${minute || '00'}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建完整的时间戳
|
||||||
|
const startDateTime = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')} ${startTime}`;
|
||||||
|
const endDateTime = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')} ${endTime}`;
|
||||||
|
|
||||||
|
// 确定课程类型和颜色
|
||||||
|
let type = 'class';
|
||||||
|
let color = '#3b82f6'; // 默认蓝色
|
||||||
|
|
||||||
|
if (course["公开课"]) {
|
||||||
|
type = 'public-course';
|
||||||
|
color = '#f59e0b'; // 橙色
|
||||||
|
} else if (course["1V1 规划阶段"]) {
|
||||||
|
type = 'one-on-one';
|
||||||
|
color = '#ec4899'; // 粉色
|
||||||
|
} else if (course["模拟面试实战练习阶段"]) {
|
||||||
|
type = 'interview';
|
||||||
|
color = '#3b82f6'; // 蓝色
|
||||||
|
} else if (course["复合技能阶段"]) {
|
||||||
|
type = 'compound-skill';
|
||||||
|
color = '#667eea'; // 紫色
|
||||||
|
} else if (course["垂直方向阶段(方向二:商业活动策划)"]) {
|
||||||
|
type = 'vertical-skill';
|
||||||
|
color = '#22c55e'; // 绿色
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确定课程状态
|
||||||
|
let status = 'upcoming';
|
||||||
|
const now = new Date();
|
||||||
|
if (courseDate < now) {
|
||||||
|
status = 'completed';
|
||||||
|
} else if (courseDate.toDateString() === now.toDateString()) {
|
||||||
|
status = 'ongoing';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: index + 1,
|
||||||
|
title: courseName,
|
||||||
|
fullTitle: courseName,
|
||||||
|
teacher: course["❌导师姓名查询"] || "待定",
|
||||||
|
unit: course["❌查询单元名称"] || "",
|
||||||
|
startTime: startDateTime,
|
||||||
|
endTime: endDateTime,
|
||||||
|
type: type,
|
||||||
|
color: color,
|
||||||
|
textColor: '#1d2129',
|
||||||
|
description: `${courseName} - ${course["❌导师姓名查询"] || "待定"}老师`,
|
||||||
|
status: course["❌课程状态"] || status,
|
||||||
|
weekday: course["星期"],
|
||||||
|
location: course["上课地点"] || "线上",
|
||||||
|
originalDate: course["日期"]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 生成课程直播列表:从日历课程数据生成单元和课程结构
|
// 生成课程直播列表:从日历课程数据生成单元和课程结构
|
||||||
const generateCourseLiveListFromCalendar = (calendarEvents) => {
|
const generateCourseLiveListFromCalendar = (calendarEvents) => {
|
||||||
let globalCourseCounter = 0; // 全局课程计数器
|
let globalCourseCounter = 0; // 全局课程计数器
|
||||||
@@ -4430,12 +4526,6 @@ mockData.profileOverview = {
|
|||||||
credits: 89,
|
credits: 89,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
classInfo: {
|
|
||||||
className: "文旅班",
|
|
||||||
totalStudents: 45,
|
|
||||||
averageScore: 75.5,
|
|
||||||
myPercentile: 100,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4750,12 +4840,6 @@ mockData.profileOverview = {
|
|||||||
credits: 89,
|
credits: 89,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
classInfo: {
|
|
||||||
className: "文旅班",
|
|
||||||
totalStudents: 45,
|
|
||||||
averageScore: 75.5,
|
|
||||||
myPercentile: 100,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user