更新12个教务系统并优化项目大小
主要更新: - 更新所有12个产业的教务系统数据和功能 - 删除所有 node_modules 文件夹(节省3.7GB) - 删除所有 .yoyo 缓存文件夹(节省1.2GB) - 删除所有 dist 构建文件(节省55MB) 项目优化: - 项目大小从 8.1GB 减少到 3.2GB(节省60%空间) - 保留完整的源代码和配置文件 - .gitignore 已配置,防止再次提交大文件 启动脚本: - start-industry.sh/bat/ps1 脚本会自动检测并安装依赖 - 首次启动时自动运行 npm install - 支持单个或批量启动产业系统 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
53
frontend_化工/fix_expert_data.py
Normal file
53
frontend_化工/fix_expert_data.py
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
# 读取原始文件
|
||||
with open('src/data/expertSupportData.js', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 提取JSON部分(去掉JavaScript变量声明和结尾)
|
||||
json_start = content.index('{')
|
||||
json_end = content.rfind('}') + 1
|
||||
json_content = content[json_start:json_end]
|
||||
|
||||
# 解析JSON
|
||||
data = json.loads(json_content)
|
||||
|
||||
# 递归处理所有字符串值
|
||||
def clean_text(obj):
|
||||
if isinstance(obj, str):
|
||||
# 处理转义的双引号 \" -> "
|
||||
obj = obj.replace('\\"', '"')
|
||||
# 处理转义的换行符 \\n -> \n (保留真正的换行)
|
||||
obj = obj.replace('\\n', '\n')
|
||||
return obj
|
||||
elif isinstance(obj, dict):
|
||||
return {k: clean_text(v) for k, v in obj.items()}
|
||||
elif isinstance(obj, list):
|
||||
return [clean_text(item) for item in obj]
|
||||
else:
|
||||
return obj
|
||||
|
||||
# 清理数据
|
||||
cleaned_data = clean_text(data)
|
||||
|
||||
# 生成新的JavaScript文件内容
|
||||
output = """// 从化工问答内容.json转换的专家支持中心数据
|
||||
const expertSupportData = """ + json.dumps(cleaned_data, ensure_ascii=False, indent=2) + """;
|
||||
|
||||
export default expertSupportData;
|
||||
"""
|
||||
|
||||
# 写入新文件
|
||||
with open('src/data/expertSupportData_cleaned.js', 'w', encoding='utf-8') as f:
|
||||
f.write(output)
|
||||
|
||||
print("数据清理完成!已生成 expertSupportData_cleaned.js")
|
||||
print("\n示例内容修复:")
|
||||
print("原始: 废水处理厂为什么要建\\\"调节池\\\"?")
|
||||
print("修复后: 废水处理厂为什么要建\"调节池\"?")
|
||||
print("\n原始: PLC:响应速度快...\\nDCS:更擅长连续过程控制...")
|
||||
print("修复后: PLC:响应速度快...\nDCS:更擅长连续过程控制...")
|
||||
Reference in New Issue
Block a user