From 5701599a14c26967c94bef1840d14bfa0c38c526 Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Mon, 23 Mar 2026 00:31:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 8 + README.md | 10 ++ scripts/debug_render.py | 11 +- .../templates/format/chat_quality_item.html | 143 +++++++++++++-- .../templates/format/image_template.html | 14 +- .../templates/format/pdf_template.html | 10 +- .../templates/hack/chat_quality_item.html | 146 +++++++++++++-- .../templates/hack/image_template.html | 24 +-- .../templates/hack/pdf_template.html | 14 +- .../retro_futurism/chat_quality_item.html | 3 +- .../scrapbook/chat_quality_item.html | 6 +- .../templates/simple/chat_quality_item.html | 135 ++++++++++++-- .../templates/simple/image_template.html | 18 +- .../templates/simple/pdf_template.html | 14 +- .../spring_festival/chat_quality_item.html | 167 +++++++++++++++--- .../spring_festival/image_template.html | 18 +- .../spring_festival/pdf_template.html | 12 +- 17 files changed, 605 insertions(+), 148 deletions(-) diff --git a/.gitignore b/.gitignore index 1c9ea24..7cf5bb5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,11 @@ data/t2i_templates/base.html .sisyphus/ data/plugin_data/astrbot_plugin_qq_group_daily_analysis/cache/avatars/123456789_40.jpg data/plugin_data/astrbot_plugin_qq_group_daily_analysis/cache/avatars/987654321_40.jpg +debug_format.html +debug_hack.html +debug_retro.html +debug_scrapbook.html +debug_simple.html +debug_spring_festival.html +debug_spring.html +data/debug_data/avatar/cache.db diff --git a/README.md b/README.md index a98f24a..fa49aaf 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,16 @@ python scripts/debug_render.py -t retro_futurism -o my_output.html python scripts/debug_render.py -h ``` +``` +uv run scripts\debug_render.py -t scrapbook -o debug_scrapbook.html +uv run scripts\debug_render.py -t hack -o debug_hack.html +uv run scripts\debug_render.py -t retro_futurism -o debug_retro.html +uv run scripts\debug_render.py -t format -o debug_format.html +uv run scripts\debug_render.py -t simple -o debug_simple.html +uv run scripts\debug_render.py -t spring_festival -o debug_spring.html +``` + + **工具特性:** - 使用 Mock 数据模拟真实的群聊分析结果 diff --git a/scripts/debug_render.py b/scripts/debug_render.py index 8e682a6..b6f4e82 100644 --- a/scripts/debug_render.py +++ b/scripts/debug_render.py @@ -317,14 +317,15 @@ async def debug_render( } # 3. Initialize Generator - generator = ReportGenerator(config_manager) - - # Override internal methods to facilitate debugging without real dependencies - generator._get_user_avatar_data = mock_get_user_avatar + data_dir = Path("data/debug_data") + data_dir.mkdir(parents=True, exist_ok=True) + generator = ReportGenerator(config_manager, data_dir) # 4. Prepare Render Data # Note: _prepare_render_data handles converting Entities to template-friendly dicts - render_payload = await generator._prepare_render_data(analysis_result) + render_payload = await generator._prepare_render_data( + analysis_result, avatar_url_getter=mock_get_user_avatar + ) # Use Jinja2 renderer final_html = generator.html_templates.render_template( diff --git a/src/infrastructure/reporting/templates/format/chat_quality_item.html b/src/infrastructure/reporting/templates/format/chat_quality_item.html index f7768b6..9ff985a 100644 --- a/src/infrastructure/reporting/templates/format/chat_quality_item.html +++ b/src/infrastructure/reporting/templates/format/chat_quality_item.html @@ -1,25 +1,130 @@ -
-
-

{{ title }}

- {% if subtitle %}{{ subtitle }}{% endif %} + + +
+
+
{{ title }}
+ {% if subtitle %}
{{ subtitle }}
{% endif %}
- -
- {% for dimension in dimensions %} -
-
- {{ dimension.name }} - {{ dimension.percentage }}% + +
+ {% set colors = ['#007bff', '#6610f2', '#6f42c1', '#e83e8c', '#fd7e14', '#28a745', '#20c997', '#17a2b8'] %} + + {% for dim in dimensions %} + {% if dim.percentage > 0 %} +
-
-
-
-

{{ dimension.comment }}

-
+ {% endif %} {% endfor %}
- -
- {{ summary }} + +
+ {% for dim in dimensions %} + {% if dim.percentage > 0 %} +
+ {{ dim.name }} + {{ dim.percentage }}% +
{{ dim.comment }}
+
+ {% endif %} + {% endfor %} +
+ +
+ EXECUTIVE SUMMARY + {{ summary }}
+ diff --git a/src/infrastructure/reporting/templates/format/image_template.html b/src/infrastructure/reporting/templates/format/image_template.html index a5c3603..abd7104 100644 --- a/src/infrastructure/reporting/templates/format/image_template.html +++ b/src/infrastructure/reporting/templates/format/image_template.html @@ -516,19 +516,19 @@
24小时活跃度分布
- {{hourly_chart_html}} + {{hourly_chart_html | safe}}
- + {% if chat_quality_html %}

群聊质量分析

- {{ chat_quality_html }} + {{ chat_quality_html | safe }}
{% endif %} - - {{topics_html}} - {{titles_html}} - {{quotes_html}} + + {{topics_html | safe}} + {{titles_html | safe}} + {{quotes_html | safe}}
- - {{topics_html}} - {{titles_html}} - {{quotes_html}} + + {{topics_html | safe}} + {{titles_html | safe}} + {{quotes_html | safe}}
- +
@@ -364,21 +364,21 @@
activity.log
- {{hourly_chart_html}} + {{hourly_chart_html | safe}}
- +
$ cat users
- {{titles_html}} + {{titles_html | safe}}
- +
$ grep golden
- {{quotes_html}} + {{quotes_html | safe}}
diff --git a/src/infrastructure/reporting/templates/retro_futurism/chat_quality_item.html b/src/infrastructure/reporting/templates/retro_futurism/chat_quality_item.html index 227049e..6faf065 100644 --- a/src/infrastructure/reporting/templates/retro_futurism/chat_quality_item.html +++ b/src/infrastructure/reporting/templates/retro_futurism/chat_quality_item.html @@ -148,7 +148,7 @@ style="width: {{ dim.percentage }}%; background-color: {{ bg_colors[loop.index0 % bg_colors|length] }}; color: {{ txt_colors[loop.index0 % txt_colors|length] }};" title="{{ dim.comment }}"> - {{ dim.name }} {{ dim.percentage }}% + {{ dim.name }}
{% endif %} @@ -161,6 +161,7 @@ {% if dim.percentage > 0 %}
{{ dim.name }}
+
PROPORTION: {{ dim.percentage }}%
{{ dim.comment }}
{% endif %} diff --git a/src/infrastructure/reporting/templates/scrapbook/chat_quality_item.html b/src/infrastructure/reporting/templates/scrapbook/chat_quality_item.html index ac6645f..fe19ab2 100644 --- a/src/infrastructure/reporting/templates/scrapbook/chat_quality_item.html +++ b/src/infrastructure/reporting/templates/scrapbook/chat_quality_item.html @@ -270,9 +270,9 @@ {% set tape_rot = loop.cycle('2deg', '-1deg', '3deg', '-2deg', '1deg', '-3deg') %}
-
- {{ dim.name }} - {{ '%.1f'|format(safe_percentage) }}% +
+ {{ dim.name }} + {{ '%.1f'|format(safe_percentage) }}%
{{ dim.comment }}
diff --git a/src/infrastructure/reporting/templates/simple/chat_quality_item.html b/src/infrastructure/reporting/templates/simple/chat_quality_item.html index 6b07fa1..2620d3e 100644 --- a/src/infrastructure/reporting/templates/simple/chat_quality_item.html +++ b/src/infrastructure/reporting/templates/simple/chat_quality_item.html @@ -1,21 +1,120 @@ -
-

{{ title }}

- {% if subtitle %}

{{ subtitle }}

{% endif %} - - {% for dimension in dimensions %} -
-
- {{ dimension.name }} - {{ dimension.percentage }}% -
-
-
-
-

{{ dimension.comment }}

+ + +
+
+
{{ title }}
+ {% if subtitle %}
{{ subtitle }}
{% endif %}
- {% endfor %} - -
- {{ summary }} + +
+ {% set colors = ['#4dabf7', '#ff922b', '#51cf66', '#f06595', '#845ef7', '#339af0'] %} + + {% for dim in dimensions %} + {% if dim.percentage > 0 %} +
+
+ {% endif %} + {% endfor %} +
+ +
+ {% for dim in dimensions %} + {% if dim.percentage > 0 %} +
+ {{ dim.name }} + {{ dim.percentage }}% +
{{ dim.comment }}
+
+ {% endif %} + {% endfor %} +
+ +
+ Summary + {{ summary }}
+ diff --git a/src/infrastructure/reporting/templates/simple/image_template.html b/src/infrastructure/reporting/templates/simple/image_template.html index 077d3a0..3453944 100644 --- a/src/infrastructure/reporting/templates/simple/image_template.html +++ b/src/infrastructure/reporting/templates/simple/image_template.html @@ -37,21 +37,21 @@

活跃度图表

- {{hourly_chart_html}} + {{hourly_chart_html | safe}}
- + {% if chat_quality_html %}

群聊质量分析

- {{ chat_quality_html }} + {{ chat_quality_html | safe }}
{% endif %} - - {{topics_html}} - - {{titles_html}} - - {{quotes_html}} + + {{topics_html | safe}} + + {{titles_html | safe}} + + {{quotes_html | safe}}