主要内容: - 包含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>
78 lines
3.0 KiB
Python
78 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import json
|
|
import re
|
|
|
|
def extract_sections(content):
|
|
"""从项目内容中提取各个部分"""
|
|
# 提取项目概述
|
|
overview_match = re.search(r'# 一、项目概述\s*\n\n(.*?)(?=\n# 二、|\n\n# 二、|$)', content, re.DOTALL)
|
|
overview = overview_match.group(1).strip() if overview_match else ""
|
|
|
|
# 提取项目整体流程介绍
|
|
process_match = re.search(r'# 二、项目整体流程介绍\s*\n\n(.*?)(?=\n# 三、|\n\n# 三、|$)', content, re.DOTALL)
|
|
process = process_match.group(1).strip() if process_match else ""
|
|
|
|
# 提取项目案例关键技术点
|
|
keypoints_match = re.search(r'# 三、项目案例关键技术点\s*\n\n(.*?)$', content, re.DOTALL)
|
|
keypoints = keypoints_match.group(1).strip() if keypoints_match else ""
|
|
|
|
# 转义换行符
|
|
overview = overview.replace('\n', '\\n')
|
|
process = process.replace('\n', '\\n')
|
|
keypoints = keypoints.replace('\n', '\\n')
|
|
|
|
return overview, process, keypoints
|
|
|
|
def main():
|
|
# 读取原始数据
|
|
with open('网页未导入数据/化工产业/化工项目案例.json', 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
# 读取当前的mock文件
|
|
with open('src/mocks/projectLibraryMock.js', 'r', encoding='utf-8') as f:
|
|
mock_content = f.read()
|
|
|
|
# 处理每个项目
|
|
for i, project in enumerate(data):
|
|
project_id = i + 1
|
|
content = project['项目案例内容']
|
|
overview, process, keypoints = extract_sections(content)
|
|
|
|
# 如果内容为空,跳过
|
|
if not overview and not process and not keypoints:
|
|
print(f"项目 {project_id} ({project['案例名称']}) 内容为空,跳过")
|
|
continue
|
|
|
|
print(f"处理项目 {project_id}: {project['案例名称']}")
|
|
print(f" 概述长度: {len(overview)}")
|
|
print(f" 流程长度: {len(process)}")
|
|
print(f" 技术点长度: {len(keypoints)}")
|
|
|
|
# 查找并替换项目的overview
|
|
if overview:
|
|
# 使用更精确的模式匹配
|
|
pattern = rf'("id": {project_id},.*?"overview": )"[^"]*"'
|
|
replacement = rf'\1"{overview}"'
|
|
mock_content = re.sub(pattern, replacement, mock_content, flags=re.DOTALL)
|
|
|
|
# 查找并替换项目的process
|
|
if process:
|
|
pattern = rf'("id": {project_id},.*?"process": )"[^"]*"'
|
|
replacement = rf'\1"{process}"'
|
|
mock_content = re.sub(pattern, replacement, mock_content, flags=re.DOTALL)
|
|
|
|
# 查找并替换项目的keyPoints
|
|
if keypoints:
|
|
pattern = rf'("id": {project_id},.*?"keyPoints": )"[^"]*"'
|
|
replacement = rf'\1"{keypoints}"'
|
|
mock_content = re.sub(pattern, replacement, mock_content, flags=re.DOTALL)
|
|
|
|
# 保存更新后的文件
|
|
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
|
|
f.write(mock_content)
|
|
|
|
print("\n✅ 所有项目详情已更新完成!")
|
|
|
|
if __name__ == "__main__":
|
|
main() |