ZhangQiPro/update_mockdata_report.py
sladro 29b58e6888 chore: ESLint代码规范修复 - 从779个问题降至13个警告
修复内容:
1.  ESLint配置完善
   - 添加浏览器全局变量:setTimeout, localStorage, getComputedStyle等
   - 禁用保留组件名规则 (vue/no-reserved-component-names)

2.  清理未使用的导入(自动修复648个警告)
   - BigScreenPortrait.vue: 移除reactive, mockPortraitData, generateChartData等
   - Evaluate.vue: 移除Search, Refresh, Download等未使用图标组件
   - Portrait.vue: 移除Download, Refresh组件
   - SubmissionDialog.vue: 移除Link组件
   - ReportCenter.vue: 移除onMounted导入

3.  修复未使用的变量
   - ReportAnalysis.vue: 移除未使用的index变量
   - FileUpload.vue: 移除未使用的index变量

修复结果:
- 修复前:779个问题(42错误,737警告)
- 修复后:13个问题(0错误,13警告)
- 修复率:98.3%

剩余13个警告:
- 未使用的error catch变量(4个)
- 未使用的index/role/student参数(7个)
- 未使用的导入DataAnalysis, getChartColors(2个)
- 所有警告不影响代码运行

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:29:59 +08:00

108 lines
3.4 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 -*-
"""
更新mockData.js中的mockReportData部分
"""
import json
import re
# 读取生成的报告数据
with open('分析报告/generated_report_data.json', 'r', encoding='utf-8') as f:
report_data = json.load(f)
# 读取mockData.js文件
with open('src/utils/mockData.js', 'r', encoding='utf-8') as f:
content = f.read()
# 构建新的mockReportData JavaScript对象
def build_monthly_scores_js(monthly_scores):
"""构建monthlyScores数组的JavaScript代码"""
lines = []
for score in monthly_scores:
lines.append(f" {{ month: '{score['month']}', overall: {score['overall']}, company: {score['company']}, teacher: {score['teacher']}, expert: {score['expert']}, peer: {score['peer']} }},")
return '\n'.join(lines)
def build_milestones_js(milestones):
"""构建里程碑数组的JavaScript代码"""
lines = []
for milestone in milestones:
lines.append(f" {{ date: '{milestone['date']}', event: '{milestone['event']}', score: {milestone['score']} }},")
return '\n'.join(lines)
def build_suggestions_js(suggestions):
"""构建建议对象的JavaScript代码"""
strengths = ",\n ".join([f"'{s}'" for s in suggestions['strengths']])
weaknesses = ",\n ".join([f"'{s}'" for s in suggestions['weaknesses']])
suggestions_list = ",\n ".join([f"'{s}'" for s in suggestions['suggestions']])
return f""" strengths: [
{strengths}
],
weaknesses: [
{weaknesses}
],
suggestions: [
{suggestions_list}
]"""
# 构建完整的mockReportData
report_sections = []
# 1. developmentTrends
trends_entries = []
for student_id, trend_data in report_data['developmentTrends'].items():
monthly_scores_js = build_monthly_scores_js(trend_data['monthlyScores'])
trends_entries.append(f""" {student_id}: {{
monthlyScores: [
{monthly_scores_js}
]
}}""")
development_trends = " // 发展趋势数据\n developmentTrends: {\n" + ",\n".join(trends_entries) + "\n }"
# 2. milestones
milestone_entries = []
for student_id, milestones in report_data['milestones'].items():
milestones_js = build_milestones_js(milestones)
milestone_entries.append(f""" {student_id}: [
{milestones_js}
]""")
milestones_section = " // 里程碑数据\n milestones: {\n" + ",\n".join(milestone_entries) + "\n }"
# 3. developmentSuggestions
suggestion_entries = []
for student_id, suggestions in report_data['developmentSuggestions'].items():
suggestions_js = build_suggestions_js(suggestions)
suggestion_entries.append(f""" {student_id}: {{
{suggestions_js}
}}""")
development_suggestions = " // 发展建议数据\n developmentSuggestions: {\n" + ",\n".join(suggestion_entries) + "\n }"
# 组装完整的mockReportData
new_report_data = f"""export const mockReportData = {{
{development_trends},
{milestones_section},
{development_suggestions}
}}"""
# 使用正则表达式替换mockReportData部分
pattern = r'export const mockReportData = \{[\s\S]*?\n\}'
replacement = new_report_data
# 执行替换
new_content = re.sub(pattern, replacement, content)
# 写回文件
with open('src/utils/mockData.js', 'w', encoding='utf-8') as f:
f.write(new_content)
print("✅ mockReportData更新完成")
print(" - 发展趋势: 40名学生 × 6个月")
print(" - 里程碑: 40名学生 × 2-4个事件")
print(" - 发展建议: 40名学生 × (优势+劣势+建议)")