Files
ALL-teach_sys/frontend_化工/update_mock_with_complete_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

56 lines
1.9 KiB
Python
Raw Permalink 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 re
def escape_for_js(text):
"""转义文本以适合在JavaScript字符串中使用"""
# 转义换行符
text = text.replace('\n', '\\n')
# 转义双引号
text = text.replace('"', '\\"')
return text
def main():
# 读取提取的完整数据
with open('extracted_project_data.json', 'r', encoding='utf-8') as f:
complete_data = json.load(f)
# 读取当前的mock文件
with open('src/mocks/projectLibraryMock.js', 'r', encoding='utf-8') as f:
mock_content = f.read()
# 为每个项目更新详情
for project in complete_data:
project_id = project['id']
print(f"\n处理项目 {project_id}: {project['name']}")
# 转义内容
overview = escape_for_js(project['overview'])
process = escape_for_js(project['process'])
keypoints = escape_for_js(project['keypoints'])
# 查找项目在详情数组中的位置
# 使用更精确的正则表达式来匹配项目详情
project_pattern = rf'(\{{\s*"id":\s*{project_id},\s*"name":\s*"[^"]+",\s*"positions":[^}}]+\}}\],\s*"unit":\s*"[^"]+",)\s*"overview":\s*"[^"]*",\s*"process":\s*"[^"]*",\s*"keyPoints":\s*"[^"]*"'
# 创建替换内容
replacement = rf'\1\n "overview": "{overview}",\n "process": "{process}",\n "keyPoints": "{keypoints}"'
# 执行替换
new_content, count = re.subn(project_pattern, replacement, mock_content, flags=re.DOTALL)
if count > 0:
mock_content = new_content
print(f" ✅ 已更新项目 {project_id} 的详情")
else:
print(f" ⚠️ 未找到项目 {project_id} 的匹配位置")
# 保存更新后的文件
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
f.write(mock_content)
print("\n✅ Mock文件更新完成")
if __name__ == "__main__":
main()