- 包含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>
106 lines
4.3 KiB
Python
106 lines
4.3 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import json
|
||
|
||
print("替换HR访问量数据为大健康产业...")
|
||
|
||
# 读取企业HR头像数据
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/企业HR头像.json', 'r', encoding='utf-8') as f:
|
||
all_hr_data = json.load(f)
|
||
|
||
# 筛选大健康产业的HR数据
|
||
health_hr_data = [hr for hr in all_hr_data if hr['所属产业'] == '大健康']
|
||
|
||
print(f"找到 {len(health_hr_data)} 位大健康产业的HR")
|
||
|
||
# 为侧边栏准备前3个HR头像URL
|
||
sidebar_hr_avatars = health_hr_data[:3] if len(health_hr_data) >= 3 else health_hr_data
|
||
|
||
# 为弹窗准备完整的HR数据(最多显示14位,与原数据保持一致)
|
||
modal_hr_data = []
|
||
visit_messages = [
|
||
'访问了您的个人档案',
|
||
'访问了您的线下面试模拟',
|
||
'访问了您的项目库',
|
||
'访问了您的线下模拟面试',
|
||
'访问了您的简历',
|
||
'访问了您的岗位匹配度报告'
|
||
]
|
||
|
||
for i, hr in enumerate(health_hr_data[:14]): # 限制为14位,与原始数据保持一致
|
||
modal_hr_data.append({
|
||
'id': i + 1,
|
||
'name': f"{hr['企业HR名称']}{'先生' if hr['性别'] == '男' else '女士'}",
|
||
'company': hr['企业HR所属公司'],
|
||
'avatar': hr['url'],
|
||
'visitMessage': visit_messages[i % len(visit_messages)]
|
||
})
|
||
|
||
# 备份并更新Sidebar组件
|
||
print("\n更新Sidebar组件中的HR头像...")
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/components/Sidebar/index.jsx', 'r', encoding='utf-8') as f:
|
||
sidebar_content = f.read()
|
||
|
||
# 备份
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/components/Sidebar/index.jsx.backup_before_hr_replace', 'w', encoding='utf-8') as f:
|
||
f.write(sidebar_content)
|
||
|
||
# 替换侧边栏中的HR头像URL
|
||
if len(sidebar_hr_avatars) >= 3:
|
||
# 替换第一个头像
|
||
sidebar_content = sidebar_content.replace(
|
||
'src="https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/company_hr_avatar/recuWFTWaK5tTz.jpeg"',
|
||
f'src="{sidebar_hr_avatars[0]["url"]}"'
|
||
)
|
||
# 替换第二个头像
|
||
sidebar_content = sidebar_content.replace(
|
||
'src="https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/company_hr_avatar/recuWFTWaKV4qG.jpeg"',
|
||
f'src="{sidebar_hr_avatars[1]["url"]}"'
|
||
)
|
||
# 替换第三个头像
|
||
sidebar_content = sidebar_content.replace(
|
||
'src="https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/company_hr_avatar/recuWFTWaKooWn.jpeg"',
|
||
f'src="{sidebar_hr_avatars[2]["url"]}"'
|
||
)
|
||
|
||
# 更新HR数量显示
|
||
sidebar_content = sidebar_content.replace(
|
||
'<span className="hr-count-text">等10位HR</span>',
|
||
f'<span className="hr-count-text">等{len(health_hr_data)}位HR</span>'
|
||
)
|
||
|
||
# 写回Sidebar组件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/components/Sidebar/index.jsx', 'w', encoding='utf-8') as f:
|
||
f.write(sidebar_content)
|
||
|
||
print("✓ Sidebar组件已更新")
|
||
|
||
# 备份并更新HRVisitModal组件
|
||
print("\n更新HRVisitModal组件中的HR数据...")
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/components/HRVisitModal/index.jsx', 'r', encoding='utf-8') as f:
|
||
modal_content = f.read()
|
||
|
||
# 备份
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/components/HRVisitModal/index.jsx.backup_before_hr_replace', 'w', encoding='utf-8') as f:
|
||
f.write(modal_content)
|
||
|
||
# 生成新的hrData数组
|
||
hr_data_str = json.dumps(modal_hr_data, ensure_ascii=False, indent=4)
|
||
hr_data_str = hr_data_str.replace('"id"', 'id').replace('"name"', 'name').replace('"company"', 'company').replace('"avatar"', 'avatar').replace('"visitMessage"', 'visitMessage')
|
||
|
||
# 替换hrData数组
|
||
import re
|
||
pattern = r'const hrData = \[[\s\S]*?\];'
|
||
replacement = f'const hrData = {hr_data_str};'
|
||
modal_content = re.sub(pattern, replacement, modal_content)
|
||
|
||
# 写回HRVisitModal组件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/components/HRVisitModal/index.jsx', 'w', encoding='utf-8') as f:
|
||
f.write(modal_content)
|
||
|
||
print("✓ HRVisitModal组件已更新")
|
||
print(f"\n替换完成!")
|
||
print(f"- 侧边栏显示前3位大健康HR头像")
|
||
print(f"- HR访问量显示:等{len(health_hr_data)}位HR")
|
||
print(f"- 弹窗中包含{len(modal_hr_data)}位大健康产业HR的详细信息") |