feat: 实现日历课程点击跳转到直播间功能
- 添加日历课程详情弹窗的点击跳转功能 - 公共课直播间和课程直播间支持URL参数自动选中课程 - 优化岗位详情页面样式,复用简洁卡片样式 - 为岗位详情标题添加图标 - 调整不同类型课程的跳转逻辑 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
153
update_project_positions_mapping.py
Normal file
153
update_project_positions_mapping.py
Normal file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
# 读取岗位等级数据
|
||||
def load_job_levels():
|
||||
with open('网页未导入数据/文旅产业/岗位等级.json', 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# 创建岗位名称到等级的映射
|
||||
job_levels_map = {}
|
||||
for item in data:
|
||||
job_name = item['❌岗位名称']
|
||||
level = item['前端查询名称']
|
||||
job_levels_map[job_name] = level
|
||||
|
||||
return job_levels_map
|
||||
|
||||
# 读取项目案例适用岗位映射
|
||||
def load_project_positions_mapping():
|
||||
with open('网页未导入数据/文旅产业/项目案例适用岗位.json', 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# 创建项目名称到岗位列表的映射
|
||||
mapping = {}
|
||||
for item in data:
|
||||
project_name = item['案例名称']
|
||||
positions = item['岗位名称_文旅']
|
||||
mapping[project_name] = positions
|
||||
|
||||
return mapping
|
||||
|
||||
# 定义等级排序
|
||||
LEVEL_ORDER = {
|
||||
'普通岗': 1,
|
||||
'技术骨干岗': 2,
|
||||
'储备干部岗': 3
|
||||
}
|
||||
|
||||
# 生成适用岗位数组字符串
|
||||
def generate_positions_array(positions, job_levels_map):
|
||||
# 创建岗位对象列表
|
||||
position_objects = []
|
||||
for position in positions:
|
||||
if position in job_levels_map:
|
||||
level = job_levels_map[position]
|
||||
position_objects.append({
|
||||
'level': level,
|
||||
'position': position,
|
||||
'order': LEVEL_ORDER.get(level, 999)
|
||||
})
|
||||
else:
|
||||
print(f" 警告: 未找到岗位 '{position}' 的等级信息")
|
||||
|
||||
# 按等级排序
|
||||
position_objects.sort(key=lambda x: x['order'])
|
||||
|
||||
# 生成字符串
|
||||
positions_str = ', '.join([
|
||||
f"{{ level: '{p['level']}', position: '{p['position']}' }}"
|
||||
for p in position_objects
|
||||
])
|
||||
|
||||
return f"[{positions_str}]"
|
||||
|
||||
# 更新projectLibraryMock.js文件
|
||||
def update_project_library_mock(project_mapping, job_levels_map):
|
||||
file_path = 'src/mocks/projectLibraryMock.js'
|
||||
|
||||
# 备份文件
|
||||
backup_path = f'{file_path}.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}_remapped'
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
with open(backup_path, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print(f"已备份: {backup_path}")
|
||||
|
||||
# 项目名称映射(因为代码中的名称可能略有不同)
|
||||
name_variations = {
|
||||
'id: 1': '舟山某民宿180天提升入住率项目',
|
||||
'id: 2': '希尔顿欢朋酒店经营管理与服务一体化优化项目',
|
||||
'id: 3': '长安汽车新款车型线下推广活动',
|
||||
'id: 4': '春风 450MT新品上市营销活动策划项目',
|
||||
'id: 5': '敦煌文创品牌策划与IP运营',
|
||||
'id: 6': '"长安幻夜"文创IP运营与品牌建设项目',
|
||||
'id: 7': '2024年深圳国际家具展策划项目',
|
||||
'id: 8': '2024 合肥国际 3C 电子产业博览会策划项目',
|
||||
'id: 9': '盐城第九届 ICGC 动漫嘉年华漫展策划项目',
|
||||
'id: 10': '某地森林湿地自然景区多平台新媒体运营方案',
|
||||
'id: 11': '漓江畔水墨居度假酒店新媒体直播运营方案',
|
||||
'id: 12': '某自驾游平台SEO/SEM全流程优化项目',
|
||||
'id: 13': '环渤海经济圈城市足球冠军赛策划与执行项目',
|
||||
'id: 14': '某歌手2025公益演唱会策划与执行项目',
|
||||
'id: 15': '贵州黔东南非遗文化探索之旅线路设计项目',
|
||||
'id: 16': '某宠物生活馆经营改善项目',
|
||||
'id: 17': '"水墨苏乡"文化创意产品设计与量产落地项目',
|
||||
'id: 18': '谷子店开店与经营管理',
|
||||
'id: 19': '轻奢露营市集玩乐活动运营项目',
|
||||
'id: 20': '中国科学院武汉植物园生态科普与文旅运营项目'
|
||||
}
|
||||
|
||||
updated_count = 0
|
||||
|
||||
# 对每个项目进行处理
|
||||
for id_pattern, project_name in name_variations.items():
|
||||
if project_name in project_mapping:
|
||||
positions = project_mapping[project_name]
|
||||
new_positions_str = generate_positions_array(positions, job_levels_map)
|
||||
|
||||
# 查找并替换该项目的applicablePositions
|
||||
# 使用更精确的正则表达式来定位特定项目
|
||||
pattern = rf'({id_pattern}.*?applicablePositions:\s*)\[[^\]]*\]'
|
||||
|
||||
def replace_func(match):
|
||||
nonlocal updated_count
|
||||
updated_count += 1
|
||||
print(f"\n更新项目 {project_name}:")
|
||||
print(f" 新岗位: {positions}")
|
||||
return match.group(1) + new_positions_str
|
||||
|
||||
content = re.sub(pattern, replace_func, content, flags=re.DOTALL)
|
||||
|
||||
# 写回文件
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print(f"\nprojectLibraryMock.js 更新完成,共更新了 {updated_count} 个项目")
|
||||
|
||||
# 主函数
|
||||
def main():
|
||||
print("=" * 50)
|
||||
print("根据项目案例适用岗位.json重新匹配适用岗位")
|
||||
print("=" * 50)
|
||||
|
||||
# 加载数据
|
||||
job_levels_map = load_job_levels()
|
||||
print(f"已加载 {len(job_levels_map)} 个岗位等级映射")
|
||||
|
||||
project_mapping = load_project_positions_mapping()
|
||||
print(f"已加载 {len(project_mapping)} 个项目岗位映射\n")
|
||||
|
||||
# 更新文件
|
||||
update_project_library_mock(project_mapping, job_levels_map)
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("所有更新完成!")
|
||||
print("=" * 50)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user