From b14834e806a63edb12a7e83cc7335a05e96ad837 Mon Sep 17 00:00:00 2001 From: meijiali <你的邮箱@xxx.com> Date: Fri, 3 Jul 2026 15:29:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/hotspots/report.html | 13 +++++++++++-- app/templates/items/detail.html | 13 +++++++++++-- docs/MVP-WorkOrders.md | 21 +++++++++++++++++++++ tests/integration/test_routes.py | 6 ++++++ tests/unit/test_export.py | 5 +++++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/app/templates/hotspots/report.html b/app/templates/hotspots/report.html index f79965e..40d74c9 100644 --- a/app/templates/hotspots/report.html +++ b/app/templates/hotspots/report.html @@ -11,8 +11,17 @@

{{ hotspot.title }} 汇总报告

- 导出 Markdown 报告 - 导出热点评论 CSV + +
{% if report %} diff --git a/app/templates/items/detail.html b/app/templates/items/detail.html index f1ad40e..1741fbd 100644 --- a/app/templates/items/detail.html +++ b/app/templates/items/detail.html @@ -12,8 +12,17 @@

{{ item.title or item.source_item_id }}

- 导出 Markdown 报告 - 导出评论 CSV + +
{% if report %} diff --git a/docs/MVP-WorkOrders.md b/docs/MVP-WorkOrders.md index 3256c36..95263f0 100644 --- a/docs/MVP-WorkOrders.md +++ b/docs/MVP-WorkOrders.md @@ -598,6 +598,27 @@ fix: 增强 SQLite 数据库恢复与异常提示 feat: 优化导出文件质量 ``` +完成记录: + +```text +完成日期:2026-07-03 +相关 commit:feat: 优化导出文件质量 +验证命令: +- .venv/bin/python -m pytest tests/unit/test_export.py tests/integration/test_routes.py::test_result_pages_render_seeded_data tests/integration/test_routes.py::test_report_pages_render_empty_state_when_report_missing tests/integration/test_routes.py::test_export_routes_return_csv_and_markdown -q +- .venv/bin/python -m pytest tests/unit tests/integration -q +- docker compose up -d --build +- curl -f http://localhost:8000/health +- 抽样检查内容 CSV UTF-8-BOM、CSV 列数、Markdown 总结章节和页面 downloadExport 按钮 +- .venv/bin/python -m pytest tests/unit tests/integration --cov=app --cov-branch --cov-report=term-missing +验收结论: +- CSV 导出已覆盖 =、+、-、@ 公式注入前缀防护。 +- CSV 导出会替换 \n、\r、\r\n,避免单条评论破坏行结构。 +- CSV 导出使用 UTF-8-BOM,抽样文件以 BOM 开头。 +- 热点/内容报告和评论导出按钮使用 downloadExport,报告缺失时 Markdown 按钮置灰并提示“报告尚未生成”。 +- Markdown 导出读取预生成 report.markdown_content,抽样包含“## 总结”章节。 +遗留问题:评论为空时 CSV 仍返回只有表头的文件,后续可在 WO-09 文档说明空文件语义。 +``` + ### WO-08 Docker 与部署前清理 优先级:P1 diff --git a/tests/integration/test_routes.py b/tests/integration/test_routes.py index a2a8b0b..2a98360 100644 --- a/tests/integration/test_routes.py +++ b/tests/integration/test_routes.py @@ -262,6 +262,8 @@ def test_result_pages_render_seeded_data(): assert 'onclick="window.location.reload()"' in task_response.text assert hotspot_response.status_code == 200 assert "热点总结" in hotspot_response.text + assert "downloadExport('/api/export/hotspots/hot-result.md'" in hotspot_response.text + assert "downloadExport('/api/export/hotspots/hot-result/comments.csv'" in hotspot_response.text assert "评论样本" in hotspot_response.text assert "关联内容" in hotspot_response.text assert "正向" in hotspot_response.text @@ -272,6 +274,8 @@ def test_result_pages_render_seeded_data(): assert "