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:
150
frontend_财经商贸/updateLuoHaoyuProfile.js
Normal file
150
frontend_财经商贸/updateLuoHaoyuProfile.js
Normal file
@@ -0,0 +1,150 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// 读取财经商贸个人档案数据
|
||||
const financeProfileData = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '网页未导入数据/财经商贸产业/财经商贸个人档案.json'), 'utf-8')
|
||||
);
|
||||
|
||||
// 读取头像列表
|
||||
const avatarList = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '网页未导入数据/头像列表.json'), 'utf-8')
|
||||
);
|
||||
|
||||
// 找到罗浩宇的数据
|
||||
const luoHaoyu = financeProfileData.find(s => s["学员名称"] === "罗浩宇");
|
||||
|
||||
if (!luoHaoyu) {
|
||||
console.error("未找到罗浩宇的数据");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 为罗浩宇选择一个专业的头像(选择第25个)
|
||||
const luoHaoyuAvatar = avatarList[24].url;
|
||||
|
||||
console.log("罗浩宇的数据:");
|
||||
console.log("- 学号:", luoHaoyu["学号"]);
|
||||
console.log("- 学校:", luoHaoyu["学校名称"]);
|
||||
console.log("- 专业:", luoHaoyu["专业名称"]);
|
||||
console.log("- 学分:", luoHaoyu["学分"]);
|
||||
console.log("- 排名:", luoHaoyu["班级排名"]);
|
||||
console.log("- MBTI:", luoHaoyu["MBTI"]);
|
||||
console.log("- 垂直方向:", luoHaoyu["垂直方向"]);
|
||||
console.log("- 新头像:", luoHaoyuAvatar);
|
||||
|
||||
// 读取mockData.js文件
|
||||
const mockDataPath = path.join(__dirname, 'src/data/mockData.js');
|
||||
let mockDataContent = fs.readFileSync(mockDataPath, 'utf-8');
|
||||
|
||||
// 备份原文件
|
||||
const backupPath = path.join(__dirname, 'src/data', `mockData.js.backup_${new Date().toISOString().replace(/[:.]/g, '-')}`);
|
||||
fs.copyFileSync(mockDataPath, backupPath);
|
||||
console.log(`\n备份已创建: ${backupPath}`);
|
||||
|
||||
// 1. 更新user对象(侧边栏显示)
|
||||
const userObjectStr = ` user: {
|
||||
name: "罗浩宇",
|
||||
avatar: "${luoHaoyuAvatar}",
|
||||
role: "学生",
|
||||
studentId: "${luoHaoyu["学号"]}",
|
||||
school: "${luoHaoyu["学校名称"]}",
|
||||
major: "${luoHaoyu["专业名称"]}",
|
||||
credits: ${luoHaoyu["学分"]},
|
||||
classRank: ${luoHaoyu["班级排名"]},
|
||||
mbti: "${luoHaoyu["MBTI"]}",
|
||||
verticalDirection: "${luoHaoyu["垂直方向"]}",
|
||||
industry: "财经商贸"
|
||||
},`;
|
||||
|
||||
// 替换user对象
|
||||
mockDataContent = mockDataContent.replace(
|
||||
/user:\s*\{[^}]*\},/s,
|
||||
userObjectStr
|
||||
);
|
||||
|
||||
// 2. 更新profile对象(个人基本信息)
|
||||
const profileObjectStr = ` profile: {
|
||||
name: "罗浩宇",
|
||||
gender: "男",
|
||||
studentId: "${luoHaoyu["学号"]}",
|
||||
avatar: "${luoHaoyuAvatar}",
|
||||
school: "${luoHaoyu["学校名称"]}",
|
||||
major: "${luoHaoyu["专业名称"]}",
|
||||
courses: ["复合能力培养", "财经商贸方向", "电子商务", "数字营销"],
|
||||
className: "财经商贸",
|
||||
studyPhase: "复合能力培养",
|
||||
badges: {
|
||||
credits: ${luoHaoyu["学分"]},
|
||||
classRank: ${luoHaoyu["班级排名"]},
|
||||
mbti: "${luoHaoyu["MBTI"]}",
|
||||
},`;
|
||||
|
||||
// 替换profile对象的开头部分
|
||||
mockDataContent = mockDataContent.replace(
|
||||
/profile:\s*\{[^}]*badges:\s*\{[^}]*\},/s,
|
||||
profileObjectStr
|
||||
);
|
||||
|
||||
// 3. 更新profileOverview中的studentInfo
|
||||
const studentInfoPattern = /studentInfo:\s*\{[^}]*myRank:\s*\{[^}]*\},[^}]*\},/gs;
|
||||
|
||||
// 查找所有的studentInfo并替换
|
||||
const studentInfoStr = ` studentInfo: {
|
||||
name: "罗浩宇",
|
||||
realName: "罗浩宇",
|
||||
studentId: "${luoHaoyu["学号"]}",
|
||||
studentNo: "${luoHaoyu["学号"]}",
|
||||
avatar: "${luoHaoyuAvatar}",
|
||||
school: "${luoHaoyu["学校名称"]}",
|
||||
major: "${luoHaoyu["专业名称"]}",
|
||||
className: "财经商贸班",
|
||||
grade: "2023级",
|
||||
studyPhase: "复合能力培养",
|
||||
stageName: "${luoHaoyu["垂直方向"]}",
|
||||
mbti: "${luoHaoyu["MBTI"]}",
|
||||
mbtiType: "${luoHaoyu["MBTI"]}",
|
||||
enrollmentDate: "2023-09-01",
|
||||
expectedGraduation: "2026-06-30",
|
||||
credits: ${luoHaoyu["学分"]},
|
||||
gpa: 4.2,
|
||||
classRank: ${luoHaoyu["班级排名"]},
|
||||
totalStudents: 10,
|
||||
myRank: {
|
||||
rank: ${luoHaoyu["班级排名"]},
|
||||
score: ${luoHaoyu["学分"]},
|
||||
},
|
||||
},`;
|
||||
|
||||
// 替换所有的studentInfo
|
||||
mockDataContent = mockDataContent.replace(studentInfoPattern, studentInfoStr);
|
||||
|
||||
// 4. 更新排名数据中罗浩宇的头像
|
||||
// 查找罗浩宇在topStudents和rankings中的记录并更新头像
|
||||
const luoHaoyuPattern = new RegExp(
|
||||
`("name":\\s*"罗浩宇"[^}]*?"avatar":\\s*)"[^"]*"`,
|
||||
'g'
|
||||
);
|
||||
|
||||
mockDataContent = mockDataContent.replace(luoHaoyuPattern, `$1"${luoHaoyuAvatar}"`);
|
||||
|
||||
// 同时处理studentName的情况
|
||||
const luoHaoyuPattern2 = new RegExp(
|
||||
`("studentName":\\s*"罗浩宇"[^}]*?"avatar":\\s*)"[^"]*"`,
|
||||
'g'
|
||||
);
|
||||
|
||||
mockDataContent = mockDataContent.replace(luoHaoyuPattern2, `$1"${luoHaoyuAvatar}"`);
|
||||
|
||||
// 写入更新后的文件
|
||||
fs.writeFileSync(mockDataPath, mockDataContent, 'utf-8');
|
||||
|
||||
console.log('\n✅ 成功更新罗浩宇的个人信息');
|
||||
console.log('更新了以下位置:');
|
||||
console.log('- user对象(侧边栏)');
|
||||
console.log('- profile对象(个人基本信息)');
|
||||
console.log('- profileOverview.studentInfo(个人档案)');
|
||||
console.log('- 班级排名中的头像');
|
||||
Reference in New Issue
Block a user