Files
ALL-teach_sys/frontend_大健康/clean_duplicate_questions_safe.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

93 lines
3.2 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
print("安全清理重复的questions数组...")
# 读取文件
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
content = f.read()
# 备份
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js.backup_clean_safe', 'w', encoding='utf-8') as f:
f.write(content)
# 对每个岗位群找到并删除第二个questions数组
industries = ['health_1', 'health_2', 'health_3', 'health_4', 'health_5',
'health_6', 'health_7', 'health_8', 'health_9', 'health_10', 'health_11']
for industry_id in industries:
print(f"处理 {industry_id}...")
# 找到该岗位群
pattern = rf'"id":\s*"{industry_id}"'
match = re.search(pattern, content)
if not match:
continue
start = match.start()
# 找到下一个岗位群或数组结束
next_pattern = rf'"id":\s*"health_\d+"'
next_matches = list(re.finditer(next_pattern, content[start + 10:]))
if next_matches:
end = start + 10 + next_matches[0].start()
else:
# 最后一个岗位群
end_match = re.search(r'\n\];', content[start:])
if end_match:
end = start + end_match.start()
else:
end = len(content)
# 获取该岗位群的内容
industry_content = content[start:end]
# 查找所有questions数组的开始位置
questions_matches = list(re.finditer(r'"questions":\s*\[', industry_content))
if len(questions_matches) > 1:
print(f" 发现 {len(questions_matches)} 个questions数组")
# 找到第二个questions的开始和结束
second_start = questions_matches[1].start()
# 计算括号平衡找到第二个questions的结束
bracket_count = 0
in_array = False
second_end = -1
for i in range(second_start, len(industry_content)):
if industry_content[i] == '[':
if not in_array and '"questions"' in industry_content[max(0, i-20):i]:
in_array = True
bracket_count = 1
elif in_array:
bracket_count += 1
elif industry_content[i] == ']' and in_array:
bracket_count -= 1
if bracket_count == 0:
second_end = i + 1
break
if second_end > 0:
# 找到第二个questions前的逗号
comma_before = industry_content.rfind(',', 0, second_start)
# 删除从逗号到questions结束的内容
if comma_before > 0:
new_industry_content = industry_content[:comma_before] + industry_content[second_end:]
# 替换原内容
content = content[:start] + new_industry_content + content[end:]
print(f" ✓ 删除了 {industry_id} 的第二个questions数组")
# 写回文件
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write(content)
print("✓ 清理完成!")