主要更新: - 更新所有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>
69 lines
2.1 KiB
Python
69 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import re
|
|
|
|
# 读取文件
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# 备份
|
|
import datetime
|
|
backup_time = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
|
|
with open(f'src/mocks/resumeInterviewMock.js.backup_quotes_{backup_time}', 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
# 修复所有在 question 和 answer 字段中的未转义引号
|
|
# 匹配 "question": "..." 或 "answer": "..." 中的内容
|
|
def fix_quotes_in_field(match):
|
|
field = match.group(1) # question 或 answer
|
|
value = match.group(2) # 字段值
|
|
|
|
# 替换内部的引号(不包括开头和结尾的引号)
|
|
# 查找所有未转义的引号
|
|
fixed_value = value
|
|
|
|
# 处理中文引号和英文引号
|
|
# 首先替换所有未转义的英文引号为转义的
|
|
parts = []
|
|
i = 0
|
|
while i < len(fixed_value):
|
|
if i > 0 and fixed_value[i] == '"' and fixed_value[i-1] != '\\':
|
|
parts.append('\\"')
|
|
else:
|
|
parts.append(fixed_value[i])
|
|
i += 1
|
|
|
|
if parts:
|
|
fixed_value = ''.join(parts)
|
|
|
|
return f'"{field}": "{fixed_value}"'
|
|
|
|
# 使用更精确的正则表达式
|
|
pattern = r'"(question|answer)":\s*"([^"\\]*(\\.[^"\\]*)*)"'
|
|
|
|
# 分块处理避免递归深度问题
|
|
lines = content.split('\n')
|
|
fixed_lines = []
|
|
|
|
for line in lines:
|
|
if '"question":' in line or '"answer":' in line:
|
|
# 检查是否有中文引号
|
|
if '"' in line or '"' in line:
|
|
# 替换中文引号
|
|
line = line.replace('"', '\\"').replace('"', '\\"')
|
|
|
|
# 修复可能的双转义
|
|
line = line.replace('\\\\"', '\\"')
|
|
line = line.replace(': "\\"', ': "') # 修复开头
|
|
line = line.replace('\\"",', '",') # 修复结尾
|
|
line = line.replace('\\""', '"') # 修复结尾2
|
|
|
|
fixed_lines.append(line)
|
|
|
|
content = '\n'.join(fixed_lines)
|
|
|
|
# 保存修复后的文件
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
print("引号修复完成!") |