Files
ALL-teach_sys/frontend_食品/fix_mockdata_syntax.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

87 lines
3.4 KiB
Python
Raw 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 re
def fix_mockdata_syntax():
"""修复mockData.js的语法错误"""
file_path = 'src/data/mockData.js'
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
print("开始修复语法错误...")
# 找到第一个profileOverview定义的结束位置
# 查找模式第一个profileOverview后面跟着的};
first_profile_end = re.search(r'mockData\.profileOverview = \{[\s\S]*?\};', content)
if first_profile_end:
print(f"找到第一个profileOverview定义结束位置: {first_profile_end.end()}")
# 检查第一个profileOverview后面是否紧跟第二个profileOverview
after_first = content[first_profile_end.end():]
second_profile_start = re.search(r'// 添加Profile个人档案页面数据\s*mockData\.profileOverview', after_first)
if second_profile_start:
print("发现重复的profileOverview定义")
# 删除第一个profileOverview定义
content_before_first = content[:first_profile_end.start()]
content_after_first = content[first_profile_end.end():]
# 重新组合内容去掉第一个profileOverview
fixed_content = content_before_first + content_after_first
print("已删除重复的profileOverview定义")
else:
print("未发现重复定义,检查其他语法问题...")
fixed_content = content
else:
print("未找到profileOverview定义")
fixed_content = content
# 修复可能的多余逗号和括号问题
# 查找并修复 },\n },\n }; 这样的模式
fixed_content = re.sub(r'},\s*},\s*};', '};\n\n', fixed_content)
# 查找并修复 },\n },\n };\n 这样的模式
fixed_content = re.sub(r'},\s*}\s*};\s*\n\s*// 添加Profile', '};\n\n// 添加Profile', fixed_content)
# 保存修复后的文件
with open(file_path, 'w', encoding='utf-8') as f:
f.write(fixed_content)
print("语法错误修复完成!")
# 验证修复结果
try:
import subprocess
result = subprocess.run(['node', '-c', file_path], capture_output=True, text=True)
if result.returncode == 0:
print("✅ JavaScript语法检查通过!")
else:
print(f"❌ JavaScript语法仍有错误: {result.stderr}")
# 尝试更精确的修复
print("尝试更精确的修复...")
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 找到问题行附近的内容
lines = content.split('\n')
for i, line in enumerate(lines):
if i >= 1200 and i <= 1210:
print(f"{i+1}行: {line}")
except Exception as e:
print(f"语法检查时出错: {e}")
except Exception as e:
print(f"修复过程中出错: {e}")
if __name__ == "__main__":
fix_mockdata_syntax()