Files
teach_sys_Demo/regenerateDashboardTasks.js
KQL efd4dd57ad fix: 修复多个页面显示和数据问题
- 修复定制求职策略页面图片超出容器问题
- 修复企业内推岗位页面面试数据结构和显示
- 删除日历页面的当日事项侧边栏
- 修复主页Dashboard当日事项数据显示
  - 修正9月份任务数据的teacherName字段
  - 修复日期筛选的时区问题
  - 删除任务列表中的课程名称显示
  - 将英文"course"改为中文"课程"
- 添加9月份完整的任务数据到allTasks数组

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 13:01:24 +08:00

86 lines
2.5 KiB
JavaScript
Raw 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
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}`);