Files
ALL-teach_sys/frontend_能源/update_energy_hr_data.py
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含12个产业的完整教务系统前端代码
- 智能启动脚本 (start-industry.sh)
- 可视化产业导航页面 (index.html)
- 项目文档 (README.md)

优化内容:
- 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB
- 添加.gitignore文件避免上传不必要的文件
- 自动依赖管理和智能启动系统

产业列表:
1. 文旅产业 (5150)
2. 智能制造 (5151)
3. 智能开发 (5152)
4. 财经商贸 (5153)
5. 视觉设计 (5154)
6. 交通物流 (5155)
7. 大健康 (5156)
8. 土木水利 (5157)
9. 食品产业 (5158)
10. 化工产业 (5159)
11. 能源产业 (5160)
12. 环保产业 (5161)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 14:14:14 +08:00

97 lines
3.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import shutil
from datetime import datetime
def update_energy_hr_data():
"""更新侧边栏和HR访问量弹窗的能源产业HR数据"""
# 读取能源产业HR数据
with open('网页未导入数据/企业HR头像.json', 'r', encoding='utf-8') as f:
all_hrs = json.load(f)
# 筛选能源产业的HR
energy_hrs = [hr for hr in all_hrs if hr['所属产业'] == '能源']
print(f"找到 {len(energy_hrs)} 个能源产业HR")
# 备份Sidebar组件
sidebar_file = 'src/components/Sidebar/index.jsx'
sidebar_backup = f"src/components/Sidebar/index.jsx.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
shutil.copy(sidebar_file, sidebar_backup)
print(f"已备份侧边栏组件到: {sidebar_backup}")
# 备份HRVisitModal组件
modal_file = 'src/components/HRVisitModal/index.jsx'
modal_backup = f"src/components/HRVisitModal/index.jsx.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
shutil.copy(modal_file, modal_backup)
print(f"已备份HR访问弹窗组件到: {modal_backup}")
# 更新Sidebar组件中的HR数据显示前3个
with open(sidebar_file, 'r', encoding='utf-8') as f:
sidebar_content = f.read()
# 找到HR数据部分并替换
sidebar_hr_data = []
for i, hr in enumerate(energy_hrs[:3]):
sidebar_hr_data.append(f'''{{
id: {i + 1},
avatar: "{hr['url']}",
name: "{hr['企业HR名称']}",
company: "{hr['企业HR所属公司']}"
}}''')
sidebar_hrs_str = ','.join(sidebar_hr_data)
# 替换侧边栏中的HR数据
# 找到hrAvatars定义的位置
import re
hr_avatars_pattern = r'const hrAvatars = \[(.*?)\];'
hr_avatars_match = re.search(hr_avatars_pattern, sidebar_content, re.DOTALL)
if hr_avatars_match:
new_hr_avatars = f'const hrAvatars = [{sidebar_hrs_str}];'
sidebar_content = sidebar_content[:hr_avatars_match.start()] + new_hr_avatars + sidebar_content[hr_avatars_match.end():]
with open(sidebar_file, 'w', encoding='utf-8') as f:
f.write(sidebar_content)
print("已更新侧边栏HR数据")
# 更新HRVisitModal组件中的HR数据显示全部14个
with open(modal_file, 'r', encoding='utf-8') as f:
modal_content = f.read()
# 构建HR数据数组
modal_hr_data = []
for i, hr in enumerate(energy_hrs):
modal_hr_data.append(f''' {{
id: {i + 1},
avatar: "{hr['url']}",
name: "{hr['企业HR名称']}",
company: "{hr['企业HR所属公司']}",
position: "HR",
visitCount: {25 - i}
}}''')
modal_hrs_str = ',\n'.join(modal_hr_data)
# 替换弹窗中的HR数据
hr_data_pattern = r'const hrData = \[(.*?)\];'
hr_data_match = re.search(hr_data_pattern, modal_content, re.DOTALL)
if hr_data_match:
new_hr_data = f'const hrData = [\n{modal_hrs_str}\n ];'
modal_content = modal_content[:hr_data_match.start()] + new_hr_data + modal_content[hr_data_match.end():]
with open(modal_file, 'w', encoding='utf-8') as f:
f.write(modal_content)
print("已更新HR访问弹窗数据")
# 显示更新结果
print("\n能源产业HR列表:")
for i, hr in enumerate(energy_hrs, 1):
print(f"{i}. {hr['企业HR名称']} - {hr['企业HR所属公司']}")
if __name__ == "__main__":
update_energy_hr_data()