- 包含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>
78 lines
2.9 KiB
Python
78 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import json
|
|
import re
|
|
|
|
print("添加缺失的导师信息到mockData.js...")
|
|
|
|
# 读取通用导师信息
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/导师信息(通用).json', 'r', encoding='utf-8') as f:
|
|
teachers_data = json.load(f)
|
|
|
|
# 需要添加的导师列表(企业高管公开课和营销能力课的导师)
|
|
needed_teachers = ["刘杰", "郭建辉", "赵志强", "周伏波", "李毅峰", "范雪娇"]
|
|
|
|
# 提取需要的导师信息
|
|
teachers_to_add = {}
|
|
for teacher in teachers_data:
|
|
name = teacher.get("查询导师名称", "")
|
|
if name in needed_teachers:
|
|
# 处理导师特长,去掉 "# " 前缀
|
|
specialties = [s.replace("# ", "") for s in teacher.get("导师特长", [])]
|
|
|
|
teachers_to_add[name] = {
|
|
"name": name,
|
|
"introduction": teacher.get("导师介绍", ""),
|
|
"specialties": specialties,
|
|
"avatar": teacher.get("❌导师头像url链接", ""),
|
|
"type": "公共课导师",
|
|
"verticalDirection": teacher.get("所属垂直方向", ""),
|
|
"courses": []
|
|
}
|
|
|
|
# 读取当前的 mockData.js
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/data/mockData.js', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# 备份原文件
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/data/mockData.js.backup_before_adding_teachers', 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
# 找到插入位置 - 在魏立慧后面,}, allCalendarEvents) 之前
|
|
pattern = r'("魏立慧": \{[^}]+courses: \[\]\s*\})(.*?)(\}, allCalendarEvents\))'
|
|
match = re.search(pattern, content, re.DOTALL)
|
|
|
|
if match:
|
|
# 准备新的导师数据字符串
|
|
new_teachers_str = ""
|
|
added_count = 0
|
|
for name, data in teachers_to_add.items():
|
|
# 转义引号以避免JS语法错误
|
|
introduction = data['introduction'].replace('"', '\\"').replace('\n', '\\n')
|
|
|
|
teacher_str = f''',
|
|
"{name}": {{
|
|
name: "{data['name']}",
|
|
introduction: "{introduction}",
|
|
specialties: {json.dumps(data['specialties'], ensure_ascii=False)},
|
|
avatar: "{data['avatar']}",
|
|
type: "{data['type']}",
|
|
verticalDirection: "{data['verticalDirection']}",
|
|
courses: []
|
|
}}'''
|
|
new_teachers_str += teacher_str
|
|
print(f"✓ 添加导师: {name}")
|
|
added_count += 1
|
|
|
|
# 插入新导师
|
|
new_content = content[:match.end(1)] + new_teachers_str + match.group(3) + content[match.end():]
|
|
|
|
# 写入更新后的文件
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/data/mockData.js', 'w', encoding='utf-8') as f:
|
|
f.write(new_content)
|
|
|
|
print(f"\n✓ 成功添加 {added_count} 个导师到 mockData.js")
|
|
print(" - 原文件已备份为 mockData.js.backup_before_adding_teachers")
|
|
else:
|
|
print("❌ 无法找到插入位置") |