fix: 优化报告未生成时的导出提示

This commit is contained in:
meijiali
2026-07-03 18:02:01 +08:00
parent d6f0f7c1b0
commit 61bcb2ef86
4 changed files with 32 additions and 0 deletions
+1
View File
@@ -30,6 +30,7 @@
<div class="text-center text-muted py-5">
<div class="spinner-border text-warning mb-3" role="status"></div>
<p>报告生成中,请稍候...</p>
<p class="small mb-0">Markdown 报告将在分析完成后开放下载;评论 CSV 可先导出已抓取的数据。</p>
</div>
{% endif %}
{% endblock %}
+1
View File
@@ -31,6 +31,7 @@
<div class="text-center text-muted py-5">
<div class="spinner-border text-warning mb-3" role="status"></div>
<p>报告生成中,请稍候...</p>
<p class="small mb-0">Markdown 报告将在分析完成后开放下载;评论 CSV 可先导出已抓取的数据。</p>
</div>
{% endif %}
<section class="card"><div class="card-header">评论明细</div><div class="table-responsive">
+26
View File
@@ -1045,6 +1045,32 @@ fix: 修复报告和评论导出点击失效
- 评论为空时,用户希望“下载只有表头的 CSV”,还是“按钮禁用并提示暂无评论”。
完成记录:
- 完成日期:2026-07-03
- 相关改动:
- 在热点报告页和内容详情页的报告生成中状态增加可见提示:`Markdown 报告将在分析完成后开放下载;评论 CSV 可先导出已抓取的数据。`
- 保留 Markdown 按钮的 disabled 状态和 title,避免报告未生成时误触。
- 保留 CSV 导出入口,允许先导出已抓取评论。
- 补充集成测试,覆盖报告缺失时的可见提示和 CSV 入口。
- 验证命令:
- `docker cp app/. hot-comments-tool-app-1:/app/app/`
- `docker cp tests/. hot-comments-tool-app-1:/app/tests/`
- `docker exec hot-comments-tool-app-1 sh -lc 'python -m pytest /app/tests/integration/test_routes.py -q'`
- `curl -s http://localhost:8000/hotspots/6fea3e86-5954-43b6-b727-33a03d3b418a/report | rg -n "Markdown 报告|导出热点评论 CSV|报告生成中|导出 Markdown"`
- `curl -s -D /tmp/wo12-csv-headers.txt http://localhost:8000/api/export/hotspots/6fea3e86-5954-43b6-b727-33a03d3b418a/comments.csv -o /tmp/wo12-hotspot-comments.csv`
- 验证结果:
- 路由集成测试:`19 passed, 1 warning`
- 当前热点页显示 Markdown 未开放下载的解释文案。
- 当前热点 CSV 导出接口 GET 返回 200`Content-Disposition` 包含 UTF-8 文件名,文件大小 4978 bytes。
- 当前热点 Markdown 导出仍返回 404 `报告不存在`,原因是该 running 任务尚未生成热点级报告;页面已给出可见解释。
- 验收结论:
- 报告未生成时,导出 Markdown 不再表现为“点不动”而无解释。
- CSV 可先导出已抓取评论。
- 遗留问题:
- 评论为空时继续沿用“下载只有表头的 CSV”的既有策略;如需改为禁用按钮,需要用户另行确认。
- 当前任务仍停在 AI 分析中,热点级 Markdown 需要任务完成并生成报告后才能下载;归入 WO-13 的进度透明化和卡住提示。
### WO-13 抓取任务进度透明化与耗时预期
优先级:P0
+4
View File
@@ -312,9 +312,13 @@ def test_report_pages_render_empty_state_when_report_missing():
assert hotspot_response.status_code == 200
assert "报告生成中,请稍候" in hotspot_response.text
assert 'title="报告尚未生成"' in hotspot_response.text
assert "Markdown 报告将在分析完成后开放下载" in hotspot_response.text
assert "downloadExport('/api/export/hotspots/hot-no-report/comments.csv'" in hotspot_response.text
assert item_response.status_code == 200
assert "报告生成中,请稍候" in item_response.text
assert 'title="报告尚未生成"' in item_response.text
assert "Markdown 报告将在分析完成后开放下载" in item_response.text
assert "downloadExport('/api/export/items/item-no-report/comments.csv'" in item_response.text
def test_report_pages_warn_when_ai_sample_is_insufficient():