主要内容: - 包含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>
139 lines
5.2 KiB
Python
139 lines
5.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import re
|
|
import json
|
|
|
|
def fix_multiline_strings_in_js():
|
|
"""修复JS文件中的多行字符串问题"""
|
|
|
|
# 读取文件
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# 查找所有 "original": "..." 和 "modified": "..." 的模式
|
|
# 使用更精确的正则表达式来匹配这些字符串
|
|
|
|
def replace_multiline(match):
|
|
"""将多行字符串转换为转义的单行字符串"""
|
|
key = match.group(1)
|
|
value = match.group(2)
|
|
# 转义字符串中的特殊字符
|
|
escaped_value = json.dumps(value, ensure_ascii=False)
|
|
return f'"{key}": {escaped_value}'
|
|
|
|
# 处理 original 字段
|
|
pattern = r'"(original|modified)": "([\s\S]*?)"(?=,\s*"(?:modified|original)"|,\s*\})'
|
|
|
|
# 分段处理,避免一次性处理整个文件
|
|
lines = content.split('\n')
|
|
result_lines = []
|
|
in_content_block = False
|
|
buffer = []
|
|
|
|
for i, line in enumerate(lines):
|
|
if '"content": {' in line:
|
|
in_content_block = True
|
|
result_lines.append(line)
|
|
elif in_content_block and ('},\n' in line or '},' in line or line.strip() == '},'):
|
|
# 处理content块
|
|
in_content_block = False
|
|
if buffer:
|
|
# 处理buffer中的内容
|
|
block_text = '\n'.join(buffer)
|
|
|
|
# 查找original和modified字段
|
|
if '"original":' in block_text or '"modified":' in block_text:
|
|
# 提取original的值
|
|
original_match = re.search(r'"original":\s*"([\s\S]*?)"(?=,\s*"modified")', block_text)
|
|
modified_match = re.search(r'"modified":\s*"([\s\S]*?)"(?=\s*\})', block_text)
|
|
|
|
if original_match and modified_match:
|
|
original_value = original_match.group(1)
|
|
modified_value = modified_match.group(1)
|
|
|
|
# 转义并重建
|
|
new_block = f' "original": {json.dumps(original_value, ensure_ascii=False)},\n'
|
|
new_block += f' "modified": {json.dumps(modified_value, ensure_ascii=False)}'
|
|
result_lines.append(new_block)
|
|
else:
|
|
result_lines.extend(buffer)
|
|
else:
|
|
result_lines.extend(buffer)
|
|
buffer = []
|
|
result_lines.append(line)
|
|
elif in_content_block:
|
|
buffer.append(line)
|
|
else:
|
|
result_lines.append(line)
|
|
|
|
# 写回文件
|
|
fixed_content = '\n'.join(result_lines)
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|
f.write(fixed_content)
|
|
|
|
print("✅ 修复完成")
|
|
|
|
def simple_fix():
|
|
"""简单的修复方法:直接从备份文件复制结构,然后用正确格式的数据替换"""
|
|
import json
|
|
|
|
# 加载转换后的数据
|
|
with open('temp_mock_data.js', 'r', encoding='utf-8') as f:
|
|
temp_content = f.read()
|
|
|
|
# 提取industries的JSON部分
|
|
industries_match = re.search(r'const industries = (\[[\s\S]*?\]);', temp_content)
|
|
if industries_match:
|
|
industries_json_str = industries_match.group(1)
|
|
# 解析为Python对象
|
|
industries_data = json.loads(industries_json_str)
|
|
|
|
# 提取resumeTemplates的JSON部分
|
|
templates_match = re.search(r'const resumeTemplates = (\{[\s\S]*?\});', temp_content)
|
|
if templates_match:
|
|
templates_json_str = templates_match.group(1)
|
|
# 解析为Python对象
|
|
templates_data = json.loads(templates_json_str)
|
|
|
|
# 读取原始文件结构
|
|
with open('src/mocks/resumeInterviewMock.js.backup_final', 'r', encoding='utf-8') as f:
|
|
original = f.read()
|
|
|
|
# 保持原始文件的其他部分,只替换数据
|
|
# 找到industries的位置
|
|
industries_start = original.find('const industries = [')
|
|
industries_end = original.find('];', industries_start) + 2
|
|
|
|
# 找到resumeTemplates的位置
|
|
templates_start = original.find('const resumeTemplates = {')
|
|
templates_end = original.find('};', templates_start) + 2
|
|
|
|
# 构建新文件
|
|
new_content = original[:industries_start]
|
|
new_content += f'const industries = {json.dumps(industries_data, ensure_ascii=False, indent=2)};'
|
|
new_content += original[industries_end:templates_start]
|
|
new_content += f'const resumeTemplates = {json.dumps(templates_data, ensure_ascii=False, indent=2)};'
|
|
new_content += original[templates_end:]
|
|
|
|
# 保存
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|
f.write(new_content)
|
|
|
|
print("✅ 使用简单方法修复完成")
|
|
|
|
def main():
|
|
print("修复多行字符串问题...")
|
|
simple_fix()
|
|
|
|
# 验证
|
|
import subprocess
|
|
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
|
|
capture_output=True, text=True)
|
|
if result.returncode == 0:
|
|
print("✅ 语法检查通过!")
|
|
else:
|
|
print(f"❌ 仍有语法错误:{result.stderr[:200]}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |