完整的教务系统前端项目 - 包含所有修复和9月份数据
This commit is contained in:
86
regenerateDashboardTasks.js
Normal file
86
regenerateDashboardTasks.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import fs from 'fs';
|
||||
|
||||
// 读取更新后的mockData
|
||||
const mockDataContent = fs.readFileSync('src/data/mockData.js', 'utf-8');
|
||||
|
||||
// 提取courseLiveList数据
|
||||
const courseLiveListMatch = mockDataContent.match(/mockData\.courseLiveList = (\[[\s\S]*?\]);/);
|
||||
if (!courseLiveListMatch) {
|
||||
console.error('无法找到courseLiveList数据');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const courseLiveList = eval('(' + courseLiveListMatch[1] + ')');
|
||||
|
||||
// 重新生成任务数据
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
|
||||
|
||||
console.log('今天的日期:', todayStr);
|
||||
|
||||
// 查找今天的课程(9月3日)
|
||||
const todaysCourses = [];
|
||||
courseLiveList.forEach(unit => {
|
||||
unit.courses.forEach(course => {
|
||||
if (course.date === todayStr) {
|
||||
todaysCourses.push({
|
||||
...course,
|
||||
unitName: unit.unitName,
|
||||
unitId: unit.unitId
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
console.log('找到今天的课程:', todaysCourses.length, '门');
|
||||
todaysCourses.forEach(course => {
|
||||
console.log(` - ${course.courseName} (${course.teacherName})`);
|
||||
});
|
||||
|
||||
// 生成allTasks
|
||||
const allTasks = [];
|
||||
let taskId = 1;
|
||||
|
||||
courseLiveList.forEach(unit => {
|
||||
unit.courses.forEach(course => {
|
||||
const courseDate = new Date(course.date);
|
||||
const status = course.completed ? 'COMPLETED' :
|
||||
course.current ? 'IN_PROGRESS' :
|
||||
courseDate > today ? 'PENDING' : 'COMPLETED';
|
||||
|
||||
allTasks.push({
|
||||
id: taskId++,
|
||||
title: `完成${course.courseName}课程学习`,
|
||||
courseName: course.courseName,
|
||||
date: course.date,
|
||||
deadline: `${course.date} 21:00`,
|
||||
priority: course.current ? 'high' : course.upcoming ? 'medium' : 'low',
|
||||
status: status,
|
||||
teacher: course.teacherName,
|
||||
unit: unit.unitName,
|
||||
type: 'course'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 过滤今天的任务
|
||||
const todayTasks = allTasks.filter(task => task.date === todayStr);
|
||||
|
||||
console.log('\n生成的今日任务:', todayTasks.length, '个');
|
||||
todayTasks.forEach(task => {
|
||||
console.log(` - ${task.title}`);
|
||||
console.log(` 状态: ${task.status}, 优先级: ${task.priority}`);
|
||||
});
|
||||
|
||||
// 输出结果到文件
|
||||
const result = {
|
||||
todayTasks,
|
||||
allTasks: allTasks.slice(0, 50), // 限制数量
|
||||
todayStr
|
||||
};
|
||||
|
||||
fs.writeFileSync('dashboardTasksData.json', JSON.stringify(result, null, 2));
|
||||
console.log('\n✅ Dashboard任务数据已生成到 dashboardTasksData.json');
|
||||
console.log(`📝 今日任务: ${todayTasks.length} 个`);
|
||||
console.log(`📋 总任务: ${allTasks.length} 个`);
|
||||
Reference in New Issue
Block a user