223 lines
7.1 KiB
Python
223 lines
7.1 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
import json
|
|||
|
|
|
|||
|
|
# 读取视觉设计岗位简历数据,建立岗位等级映射
|
|||
|
|
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
|
|||
|
|
positions_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 建立岗位名称与等级的映射
|
|||
|
|
position_levels = {}
|
|||
|
|
for item in positions_data:
|
|||
|
|
position_name = item.get('岗位名称', '')
|
|||
|
|
level = item.get('岗位等级标签', '')
|
|||
|
|
if position_name and level:
|
|||
|
|
position_levels[position_name] = level
|
|||
|
|
|
|||
|
|
# 读取视觉设计项目案例数据
|
|||
|
|
with open('网页未导入数据/视觉设计产业/视觉设计项目案例.json', 'r', encoding='utf-8') as f:
|
|||
|
|
visual_design_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 生成项目列表数据
|
|||
|
|
projects_js = []
|
|||
|
|
for idx, item in enumerate(visual_design_data, 1):
|
|||
|
|
project = {
|
|||
|
|
'id': idx,
|
|||
|
|
'name': item['案例名称'],
|
|||
|
|
'description': item.get('所属垂直方向', ''),
|
|||
|
|
'positions': [pos.strip() for pos in item.get('对应个人简历名称', '').split(',') if pos.strip()],
|
|||
|
|
'unit': item.get('对应单元名称(复合能力课)', ''),
|
|||
|
|
'direction': item.get('所属垂直方向', ''),
|
|||
|
|
'category': item.get('对应单元名称(垂直能力课)', '')
|
|||
|
|
}
|
|||
|
|
projects_js.append(project)
|
|||
|
|
|
|||
|
|
# 生成项目详情数据
|
|||
|
|
project_details = {}
|
|||
|
|
for idx, item in enumerate(visual_design_data, 1):
|
|||
|
|
content = item.get('项目案例内容', '')
|
|||
|
|
|
|||
|
|
# 直接保存原始Markdown内容的部分
|
|||
|
|
# 分割内容,查找各个部分
|
|||
|
|
lines = content.split('\n') if content else []
|
|||
|
|
|
|||
|
|
overview = ""
|
|||
|
|
process = ""
|
|||
|
|
keyPoints = ""
|
|||
|
|
|
|||
|
|
current_section = ""
|
|||
|
|
current_content = []
|
|||
|
|
|
|||
|
|
for line in lines:
|
|||
|
|
if '# 一、项目概述' in line:
|
|||
|
|
# 保存之前的部分
|
|||
|
|
if current_section == "process":
|
|||
|
|
process = '\n'.join(current_content)
|
|||
|
|
elif current_section == "keyPoints":
|
|||
|
|
keyPoints = '\n'.join(current_content)
|
|||
|
|
# 开始新部分
|
|||
|
|
current_section = "overview"
|
|||
|
|
current_content = []
|
|||
|
|
elif '# 二、项目整体流程介绍' in line:
|
|||
|
|
# 保存概述
|
|||
|
|
if current_section == "overview":
|
|||
|
|
overview = '\n'.join(current_content)
|
|||
|
|
current_section = "process"
|
|||
|
|
current_content = []
|
|||
|
|
elif '# 三、项目案例关键技术点' in line:
|
|||
|
|
# 保存流程
|
|||
|
|
if current_section == "process":
|
|||
|
|
process = '\n'.join(current_content)
|
|||
|
|
current_section = "keyPoints"
|
|||
|
|
current_content = []
|
|||
|
|
elif current_section:
|
|||
|
|
current_content.append(line)
|
|||
|
|
|
|||
|
|
# 保存最后一部分
|
|||
|
|
if current_section == "overview":
|
|||
|
|
overview = '\n'.join(current_content)
|
|||
|
|
elif current_section == "process":
|
|||
|
|
process = '\n'.join(current_content)
|
|||
|
|
elif current_section == "keyPoints":
|
|||
|
|
keyPoints = '\n'.join(current_content)
|
|||
|
|
|
|||
|
|
# 清理多余的空行
|
|||
|
|
overview = overview.strip()
|
|||
|
|
process = process.strip()
|
|||
|
|
keyPoints = keyPoints.strip()
|
|||
|
|
|
|||
|
|
# 处理适用岗位
|
|||
|
|
positions = item.get('对应个人简历名称', '').split(',')
|
|||
|
|
applicable_positions = []
|
|||
|
|
for pos in positions:
|
|||
|
|
pos = pos.strip()
|
|||
|
|
if pos:
|
|||
|
|
level = position_levels.get(pos, '技术骨干岗')
|
|||
|
|
applicable_positions.append({
|
|||
|
|
'position': pos,
|
|||
|
|
'level': level
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
# 处理对应单元
|
|||
|
|
corresponding_units = {
|
|||
|
|
'compound': [item.get('对应单元名称(复合能力课)', '')] if item.get('对应单元名称(复合能力课)') else [],
|
|||
|
|
'vertical': [item.get('对应单元名称(垂直能力课)', '')] if item.get('对应单元名称(垂直能力课)') else []
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 处理附件
|
|||
|
|
attachments = []
|
|||
|
|
if item.get('附件'):
|
|||
|
|
files = item['附件'].split(',')
|
|||
|
|
for file in files[:5]:
|
|||
|
|
file = file.strip()
|
|||
|
|
if file:
|
|||
|
|
ext = file.split('.')[-1].lower()
|
|||
|
|
file_type = 'document'
|
|||
|
|
if ext in ['jpg', 'jpeg', 'png', 'gif']:
|
|||
|
|
file_type = 'image'
|
|||
|
|
elif ext in ['mp4', 'avi', 'mov']:
|
|||
|
|
file_type = 'video'
|
|||
|
|
elif ext == 'pdf':
|
|||
|
|
file_type = 'pdf'
|
|||
|
|
elif ext in ['doc', 'docx']:
|
|||
|
|
file_type = 'word'
|
|||
|
|
elif ext in ['psd', 'aep']:
|
|||
|
|
file_type = 'design'
|
|||
|
|
elif ext in ['zip', 'rar', '7z']:
|
|||
|
|
file_type = 'archive'
|
|||
|
|
elif ext in ['mp3', 'wav']:
|
|||
|
|
file_type = 'audio'
|
|||
|
|
|
|||
|
|
attachments.append({
|
|||
|
|
'name': file,
|
|||
|
|
'type': file_type,
|
|||
|
|
'size': '2.3MB'
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
project_details[idx] = {
|
|||
|
|
'title': item['案例名称'],
|
|||
|
|
'category': item.get('所属垂直方向', ''),
|
|||
|
|
'overview': overview if overview else '暂无项目概述',
|
|||
|
|
'applicablePositions': applicable_positions,
|
|||
|
|
'correspondingUnits': corresponding_units,
|
|||
|
|
'process': process if process else '暂无流程介绍',
|
|||
|
|
'keyPoints': keyPoints if keyPoints else '暂无关键技术点',
|
|||
|
|
'attachments': attachments
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 生成JavaScript代码
|
|||
|
|
js_code = '''// 项目库Mock数据
|
|||
|
|
export const getMockProjectsList = (params = {}) => {
|
|||
|
|
const { search = "", page = 1, pageSize = 10 } = params;
|
|||
|
|
|
|||
|
|
// 完整项目列表数据
|
|||
|
|
const projects = '''
|
|||
|
|
|
|||
|
|
# 添加项目列表数组 - 使用ensure_ascii=False保留中文
|
|||
|
|
js_code += json.dumps(projects_js, ensure_ascii=False, indent=2)
|
|||
|
|
|
|||
|
|
js_code += ''';
|
|||
|
|
|
|||
|
|
// 根据搜索条件过滤
|
|||
|
|
let filteredProjects = projects;
|
|||
|
|
if (search) {
|
|||
|
|
filteredProjects = projects.filter(p =>
|
|||
|
|
p.name.toLowerCase().includes(search.toLowerCase()) ||
|
|||
|
|
p.description.toLowerCase().includes(search.toLowerCase())
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 分页
|
|||
|
|
const startIndex = (page - 1) * pageSize;
|
|||
|
|
const endIndex = startIndex + pageSize;
|
|||
|
|
const paginatedProjects = filteredProjects.slice(startIndex, endIndex);
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
success: true,
|
|||
|
|
data: paginatedProjects,
|
|||
|
|
total: filteredProjects.length,
|
|||
|
|
page,
|
|||
|
|
pageSize
|
|||
|
|
};
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 获取项目详情
|
|||
|
|
export const getMockProjectDetail = (id) => {
|
|||
|
|
// 项目详情数据
|
|||
|
|
const projectDetails = '''
|
|||
|
|
|
|||
|
|
# 添加项目详情对象 - 使用ensure_ascii=False保留中文和换行符
|
|||
|
|
js_code += json.dumps(project_details, ensure_ascii=False, indent=2)
|
|||
|
|
|
|||
|
|
js_code += ''';
|
|||
|
|
|
|||
|
|
const detail = projectDetails[id];
|
|||
|
|
|
|||
|
|
if (detail) {
|
|||
|
|
return {
|
|||
|
|
success: true,
|
|||
|
|
data: detail
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 如果没有找到详情,返回默认数据
|
|||
|
|
return {
|
|||
|
|
success: true,
|
|||
|
|
data: {
|
|||
|
|
title: "项目详情",
|
|||
|
|
category: "视觉设计",
|
|||
|
|
overview: "暂无详细信息",
|
|||
|
|
applicablePositions: [],
|
|||
|
|
correspondingUnits: { compound: [], vertical: [] },
|
|||
|
|
process: "暂无流程介绍",
|
|||
|
|
keyPoints: "暂无关键技术点",
|
|||
|
|
attachments: []
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
};
|
|||
|
|
'''
|
|||
|
|
|
|||
|
|
# 写入文件
|
|||
|
|
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(js_code)
|
|||
|
|
|
|||
|
|
print("Mock文件已更新,Markdown内容已正确处理!")
|