主要内容: - 包含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>
136 lines
4.7 KiB
Python
136 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import re
|
||
|
||
def safe_escape_js_string(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():
|
||
# 读取BIM工程师的修改版简历
|
||
with open('网页未导入数据/土木水利产业/土木水利修改版简历/BIM工程师.md', 'r', encoding='utf-8') as f:
|
||
bim_content = f.read()
|
||
|
||
# 安全转义内容
|
||
escaped_content = safe_escape_js_string(bim_content)
|
||
|
||
# 读取当前的resumeInterviewMock.js文件
|
||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
js_content = f.read()
|
||
|
||
# 查找错误的modified字段 - 从"modified": "# BIM工程师开始,到下一个"}结束
|
||
# 使用更加精确的正则表达式
|
||
pattern = r'"modified":\s*"# BIM工程师[^"]*"[^}]*"'
|
||
|
||
# 查找所有匹配
|
||
matches = list(re.finditer(pattern, js_content, re.DOTALL))
|
||
print(f"找到 {len(matches)} 个匹配")
|
||
|
||
if matches:
|
||
for match in matches:
|
||
print(f"匹配位置: {match.start()} - {match.end()}")
|
||
print(f"匹配内容开头: {match.group()[:100]}...")
|
||
|
||
# 使用更简单的方法:找到 "modified": " 开始,然后找到对应的结束引号
|
||
# 考虑到内容可能有未转义的引号,我们需要找到正确的结束位置
|
||
|
||
# 先定位到BIM工程师条目的大概位置
|
||
bim_pos = js_content.find('"position": "BIM工程师"')
|
||
if bim_pos == -1:
|
||
print("未找到BIM工程师条目")
|
||
return
|
||
|
||
print(f"BIM工程师条目位置: {bim_pos}")
|
||
|
||
# 从这个位置开始查找modified字段
|
||
modified_start = js_content.find('"modified":', bim_pos)
|
||
if modified_start == -1:
|
||
print("未找到modified字段")
|
||
return
|
||
|
||
print(f"modified字段开始位置: {modified_start}")
|
||
|
||
# 找到引号开始位置
|
||
quote_start = js_content.find('"', modified_start + len('"modified":'))
|
||
if quote_start == -1:
|
||
print("未找到modified字段的开始引号")
|
||
return
|
||
|
||
print(f"内容开始引号位置: {quote_start}")
|
||
|
||
# 从下一个字符开始,找到这个字段的结束位置
|
||
# 我们需要找到 "}作为整个对象的结束
|
||
current_pos = quote_start + 1
|
||
brace_count = 0
|
||
in_string = True
|
||
|
||
# 简单方法:找到下一个 "},这应该是content对象的结束
|
||
content_end = js_content.find('}', current_pos)
|
||
while content_end != -1:
|
||
# 检查这个}前面是否有"
|
||
check_pos = content_end - 1
|
||
while check_pos > current_pos and js_content[check_pos] in ' \n\t':
|
||
check_pos -= 1
|
||
if js_content[check_pos] == '"':
|
||
# 找到了正确的结束位置
|
||
break
|
||
content_end = js_content.find('}', content_end + 1)
|
||
|
||
if content_end == -1:
|
||
print("未找到content对象的结束位置")
|
||
return
|
||
|
||
print(f"content对象结束位置: {content_end}")
|
||
|
||
# 现在替换modified字段的值
|
||
# 找到 "modified": " 的结束位置,然后替换到下一个 " 之前的内容
|
||
modified_value_start = js_content.find('"', modified_start + len('"modified":'))
|
||
modified_value_start += 1 # 跳过开始的引号
|
||
|
||
# 找到这个值的结束引号 - 在content_end之前
|
||
modified_value_end = content_end
|
||
check_pos = content_end - 1
|
||
while check_pos > modified_value_start and js_content[check_pos] in ' \n\t':
|
||
check_pos -= 1
|
||
if js_content[check_pos] == '"':
|
||
modified_value_end = check_pos
|
||
|
||
print(f"modified值的位置: {modified_value_start} - {modified_value_end}")
|
||
|
||
# 构建新的内容
|
||
new_js_content = (js_content[:modified_value_start] +
|
||
escaped_content +
|
||
js_content[modified_value_end:])
|
||
|
||
# 保存修复后的文件
|
||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(new_js_content)
|
||
|
||
print("已成功替换BIM工程师的modified字段内容")
|
||
|
||
# 验证语法
|
||
import subprocess
|
||
try:
|
||
result = subprocess.run(['node', '-c', 'src/mocks/resumeInterviewMock.js'],
|
||
capture_output=True, text=True)
|
||
if result.returncode == 0:
|
||
print("✅ JavaScript语法检查通过")
|
||
else:
|
||
print("❌ JavaScript语法错误:")
|
||
print(result.stderr)
|
||
except Exception as e:
|
||
print("无法验证JavaScript语法:", e)
|
||
|
||
if __name__ == "__main__":
|
||
main() |