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:
88
frontend_财经商贸/updateLivePageData.js
Normal file
88
frontend_财经商贸/updateLivePageData.js
Normal file
@@ -0,0 +1,88 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// 1. 更新单元背景数据
|
||||
// 读取财经商贸单元背景数据
|
||||
const financeUnitData = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '网页未导入数据/财经商贸产业/财经商贸单元背景.json'), 'utf-8')
|
||||
);
|
||||
|
||||
// 转换格式,移除不需要的字段
|
||||
const cleanedUnitData = financeUnitData.map(item => ({
|
||||
"单元名称": item["单元名称"],
|
||||
"单元海报_url": item["单元海报_url"]
|
||||
}));
|
||||
|
||||
// 备份原文件
|
||||
const unitBackupPath = path.join(__dirname, '网页未导入数据/智能制造产业', `智能制造单元背景.json.backup_${new Date().toISOString().replace(/[:.]/g, '-')}`);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, '网页未导入数据/智能制造产业/智能制造单元背景.json'),
|
||||
unitBackupPath
|
||||
);
|
||||
console.log(`单元背景备份已创建: ${unitBackupPath}`);
|
||||
|
||||
// 写入新的单元背景数据
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '网页未导入数据/智能制造产业/智能制造单元背景.json'),
|
||||
JSON.stringify(cleanedUnitData, null, 2),
|
||||
'utf-8'
|
||||
);
|
||||
console.log(`成功更新单元背景数据,共 ${cleanedUnitData.length} 个单元`);
|
||||
|
||||
// 2. 更新导师信息数据
|
||||
// 读取导师信息(通用)数据
|
||||
const allTeachersData = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '网页未导入数据/导师信息(通用).json'), 'utf-8')
|
||||
);
|
||||
|
||||
// 筛选财经商贸产业的导师
|
||||
const financeTeachers = allTeachersData.filter(teacher => teacher["就业管家"] === "财经商贸");
|
||||
|
||||
// 创建财经商贸导师数据对象
|
||||
const financeTeachersObject = {};
|
||||
financeTeachers.forEach(teacher => {
|
||||
const teacherName = teacher["查询导师名称"];
|
||||
financeTeachersObject[teacherName] = {
|
||||
name: teacherName,
|
||||
introduction: teacher["导师介绍"],
|
||||
specialties: teacher["导师特长"],
|
||||
avatar: teacher["❌导师头像url链接"],
|
||||
type: teacher["导师类型"] === "任课老师" ? "复合课导师" : teacher["导师类型"],
|
||||
verticalDirection: teacher["所属垂直方向"],
|
||||
courses: []
|
||||
};
|
||||
});
|
||||
|
||||
// 读取mockData.js文件内容
|
||||
let mockDataContent = fs.readFileSync(path.join(__dirname, 'src/data/mockData.js'), 'utf-8');
|
||||
|
||||
// 找到teacherData的位置并替换
|
||||
// 先备份原文件
|
||||
const mockDataBackupPath = path.join(__dirname, 'src/data', `mockData.js.backup_${new Date().toISOString().replace(/[:.]/g, '-')}`);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, 'src/data/mockData.js'),
|
||||
mockDataBackupPath
|
||||
);
|
||||
console.log(`mockData.js备份已创建: ${mockDataBackupPath}`);
|
||||
|
||||
// 生成新的导师数据字符串
|
||||
const teacherDataString = `updateTeacherCourses(${JSON.stringify(financeTeachersObject, null, 4).replace(/\n/g, '\n ')}, allCalendarEvents)`;
|
||||
|
||||
// 使用正则表达式替换teacherData部分
|
||||
mockDataContent = mockDataContent.replace(
|
||||
/teacherData: updateTeacherCourses\({[\s\S]*?}\), allCalendarEvents\)/,
|
||||
`teacherData: ${teacherDataString}`
|
||||
);
|
||||
|
||||
// 写入更新后的mockData.js
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, 'src/data/mockData.js'),
|
||||
mockDataContent,
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
console.log(`成功更新导师数据,共 ${financeTeachers.length} 位财经商贸导师`);
|
||||
Reference in New Issue
Block a user