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

122 lines
4.7 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('\\', '\\\\')
# 转义双引号
text = text.replace('"', '\\"')
# 转义换行符
text = text.replace('\n', '\\n')
# 转义回车符
text = text.replace('\r', '\\r')
# 转义制表符
text = text.replace('\t', '\\t')
return text
def main():
# 读取完整的项目数据
with open('complete_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:
lines = f.readlines()
# 处理每一行
new_lines = []
i = 0
while i < len(lines):
line = lines[i]
# 检查是否是项目ID行
if '"id":' in line:
# 提取ID
id_match = re.search(r'"id":\s*(\d+)', line)
if id_match:
project_id = int(id_match.group(1))
# 查找对应的完整数据
complete_project = next((p for p in complete_data if p['id'] == project_id), None)
if complete_project:
# 添加当前行
new_lines.append(line)
i += 1
# 处理后续的行查找并替换overview, process, keyPoints
replaced = {'overview': False, 'process': False, 'keyPoints': False}
while i < len(lines) and not all(replaced.values()):
current_line = lines[i]
if '"overview":' in current_line and not replaced['overview']:
# 替换overview行
overview = escape_for_js(complete_project['overview'])
indent = ' '
new_lines.append(f'{indent}"overview": "{overview}",\n')
replaced['overview'] = True
i += 1
elif '"process":' in current_line and not replaced['process']:
# 替换process行
process = escape_for_js(complete_project['process'])
indent = ' '
new_lines.append(f'{indent}"process": "{process}",\n')
replaced['process'] = True
i += 1
elif '"keyPoints":' in current_line and not replaced['keyPoints']:
# 替换keyPoints行
keypoints = escape_for_js(complete_project['keypoints'])
indent = ' '
# 检查是否是最后一个字段
if current_line.rstrip().endswith('"'):
new_lines.append(f'{indent}"keyPoints": "{keypoints}"\n')
else:
new_lines.append(f'{indent}"keyPoints": "{keypoints}",\n')
replaced['keyPoints'] = True
i += 1
else:
new_lines.append(current_line)
i += 1
else:
new_lines.append(line)
i += 1
else:
new_lines.append(line)
i += 1
else:
new_lines.append(line)
i += 1
# 保存更新后的文件
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
f.writelines(new_lines)
print("✅ 项目详情已完整更新")
# 验证JavaScript语法
import subprocess
result = subprocess.run(['node', '-c', 'src/mocks/projectLibraryMock.js'],
capture_output=True, text=True)
if result.returncode == 0:
print("✅ JavaScript语法检查通过")
else:
print(f"❌ JavaScript语法错误:\n{result.stderr}")
# 显示错误位置附近的内容
error_match = re.search(r':(\d+):', result.stderr)
if error_match:
error_line = int(error_match.group(1))
print(f"\n错误位置附近的内容(行 {error_line-2}{error_line+2}:")
with open('src/mocks/projectLibraryMock.js', 'r', encoding='utf-8') as f:
all_lines = f.readlines()
for line_num in range(max(0, error_line-3), min(len(all_lines), error_line+2)):
print(f"{line_num+1:4}: {all_lines[line_num].rstrip()}")
if __name__ == "__main__":
main()