Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
77
frontend_智能制造/updateCourseLiveList.js
Normal file
77
frontend_智能制造/updateCourseLiveList.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import fs from 'fs';
|
||||
|
||||
// 读取生成的课程数据
|
||||
const courseLiveListData = JSON.parse(fs.readFileSync('courseLiveListData.json', 'utf-8'));
|
||||
|
||||
// 读取mockData.js文件
|
||||
let mockDataContent = fs.readFileSync('src/data/mockData.js', 'utf-8');
|
||||
|
||||
// 找到courseLiveList的开始和结束位置
|
||||
const startPattern = /mockData\.courseLiveList = \[/;
|
||||
const startMatch = mockDataContent.match(startPattern);
|
||||
|
||||
if (startMatch) {
|
||||
const startIndex = mockDataContent.indexOf(startMatch[0]);
|
||||
|
||||
// 找到对应的结束位置(找到配对的 ]; )
|
||||
let braceCount = 0;
|
||||
let endIndex = startIndex + startMatch[0].length;
|
||||
let inString = false;
|
||||
let stringChar = '';
|
||||
|
||||
for (let i = endIndex; i < mockDataContent.length; i++) {
|
||||
const char = mockDataContent[i];
|
||||
const prevChar = i > 0 ? mockDataContent[i - 1] : '';
|
||||
|
||||
// 处理字符串
|
||||
if (!inString && (char === '"' || char === "'") && prevChar !== '\\') {
|
||||
inString = true;
|
||||
stringChar = char;
|
||||
} else if (inString && char === stringChar && prevChar !== '\\') {
|
||||
inString = false;
|
||||
}
|
||||
|
||||
if (!inString) {
|
||||
if (char === '[') braceCount++;
|
||||
if (char === ']') {
|
||||
if (braceCount === 0) {
|
||||
// 找到了结束位置
|
||||
endIndex = i + 1;
|
||||
// 检查是否有分号
|
||||
if (mockDataContent[i + 1] === ';') {
|
||||
endIndex = i + 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
braceCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 替换courseLiveList部分
|
||||
const newCourseLiveList = `mockData.courseLiveList = ${JSON.stringify(courseLiveListData.courseLiveList, null, 2)};`;
|
||||
|
||||
mockDataContent =
|
||||
mockDataContent.substring(0, startIndex) +
|
||||
newCourseLiveList +
|
||||
mockDataContent.substring(endIndex);
|
||||
|
||||
// 写回文件
|
||||
fs.writeFileSync('src/data/mockData.js', mockDataContent);
|
||||
console.log('✅ mockData.js中的courseLiveList已更新');
|
||||
|
||||
// 验证9月3日的课程状态
|
||||
const sept3Course = courseLiveListData.courseLiveList
|
||||
.find(unit => unit.unitId === 'unit7')
|
||||
?.courses.find(c => c.date === '2025-09-03');
|
||||
|
||||
if (sept3Course) {
|
||||
console.log('\n9月3日课程状态:');
|
||||
console.log(` 课程:${sept3Course.courseName}`);
|
||||
console.log(` completed: ${sept3Course.completed}`);
|
||||
console.log(` current: ${sept3Course.current}`);
|
||||
console.log(` upcoming: ${sept3Course.upcoming}`);
|
||||
}
|
||||
} else {
|
||||
console.error('❌ 无法找到mockData.courseLiveList的位置');
|
||||
}
|
||||
Reference in New Issue
Block a user