Files
ALL-teach_sys/frontend_视觉设计/replace_target_position_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

85 lines
3.1 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import shutil
from datetime import datetime
def main():
print("🚀 开始替换目标岗位优先级数据...")
# 创建备份
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
original_file = "src/pages/JobStrategyDetailPage/components/TargetPosition/index.jsx"
backup_path = f"{original_file}.backup_{timestamp}"
shutil.copy2(original_file, backup_path)
print(f"📦 已创建备份: {backup_path}")
# 读取视觉设计岗位数据
print("📖 读取视觉设计岗位数据...")
with open("网页未导入数据/视觉设计产业/视觉设计岗位简历.json", "r", encoding="utf-8") as f:
visual_design_data = json.load(f)
print(f"✅ 成功读取 {len(visual_design_data)} 个视觉设计岗位")
# 按批次分类岗位
batch_positions = {
"第一批次": [],
"第二批次": [],
"第三批次": []
}
for item in visual_design_data:
position_name = item.get("岗位名称", "")
batch = item.get("批次", "")
if batch in batch_positions and position_name:
batch_positions[batch].append(position_name)
print(f"✅ 处理岗位: {position_name} ({batch})")
# 读取原始文件
with open(original_file, "r", encoding="utf-8") as f:
content = f.read()
# 构建新的 initialBatchPositions 对象
new_batch_data = f''' const initialBatchPositions = {{
batch1: [
{chr(10).join([f' "{pos}",' for pos in batch_positions["第一批次"]])}
],
batch2: [
{chr(10).join([f' "{pos}",' for pos in batch_positions["第二批次"]])}
],
batch3: [
{chr(10).join([f' "{pos}",' for pos in batch_positions["第三批次"]])}
]
}};'''
# 使用正则表达式替换 initialBatchPositions 定义
import re
pattern = r'( // 定义三个批次的岗位数据\s*\n const initialBatchPositions = \{[\s\S]*?\n \};)'
if re.search(pattern, content):
new_content = re.sub(pattern, f' // 定义三个批次的岗位数据\n{new_batch_data}', content)
# 写入文件
with open(original_file, "w", encoding="utf-8") as f:
f.write(new_content)
print("📊 替换统计:")
print(f" - 第一批次岗位数: {len(batch_positions['第一批次'])}")
print(f" - 第二批次岗位数: {len(batch_positions['第二批次'])}")
print(f" - 第三批次岗位数: {len(batch_positions['第三批次'])}")
print(f" - 总岗位数: {sum(len(positions) for positions in batch_positions.values())}")
print("✅ 已更新目标岗位优先级数据")
# 显示部分替换的岗位
print("📋 各批次的岗位包括:")
for batch_name, positions in batch_positions.items():
print(f" {batch_name}: {', '.join(positions[:3])}{'...' if len(positions) > 3 else ''}")
print("🎉 处理完成!")
else:
print("❌ 未找到目标代码段,请检查文件结构")
if __name__ == "__main__":
main()