按design_summary规范重构群总结卡片模板

- gemini_summary_card 调整为 420px 固定宽度与高密度小字号布局,贴合 Clean Technical 规范\n- 话题卡片严格采用 Background/Key Points/Conclusion 三段论结构并保留结论高亮块\n- 个人雷达标签改为药丸样式并增加彩色高亮逻辑,未命中维持 Slate 背景\n- 新增资源库列表的 GitHub 风格行结构(左图标、中标题、右箭头)\n- 双栏挂件恢复 Marketplace 与 Unresolved Pool 并排展示,节省纵向空间\n- 核心知识点改为深色高反差模块,强化长图视觉焦点\n- main.py 新增模板命名模块与资源库结构化提取,保障模板字段与数据一致
This commit is contained in:
liuwei
2026-04-23 11:02:45 +08:00
parent 93e86f98e8
commit c4f29084bc
3 changed files with 265 additions and 187 deletions

View File

@@ -1133,6 +1133,47 @@ class MessageSummaryPlugin(MessagePluginInterface):
modules["top_contributors"] = modules["top_contributors"][:3]
return modules
@classmethod
def _build_resource_hub_items(cls, resources: List[str]) -> List[Dict[str, str]]:
"""把资源文本转换为“资源库列表”展示数据。
设计说明:
1. 该方法只做轻量规则分类,不依赖额外模型推理,保证稳定与速度;
2. 输出包含 icon/type/title模板可直接渲染“左图标-中标题-右箭头”结构;
3. 资源条目数量限制在 6 条,避免长图膨胀。
"""
items: List[Dict[str, str]] = []
for raw in resources or []:
text = cls._strip_markdown_inline(str(raw or "").strip())
if not text:
continue
lower = text.lower()
# 说明:以关键词做资源类型判断,优先覆盖仓库、文档、链接、附件四类。
if "github.com" in lower or "gitlab" in lower or "仓库" in text:
icon = ""
kind = "Repo"
elif "http://" in lower or "https://" in lower or "链接" in text:
icon = ""
kind = "Link"
elif any(k in lower for k in [".pdf", ".doc", ".ppt", "文档", "手册", "白皮书"]):
icon = ""
kind = "Doc"
else:
icon = ""
kind = "Item"
items.append(
{
"icon": icon,
"type": kind,
"title": text[:72],
}
)
if len(items) >= 6:
break
return items
def _render_summary_template_html(
self,
group_name: str,
@@ -1156,6 +1197,7 @@ class MessageSummaryPlugin(MessagePluginInterface):
topic_titles = [card.get("title", "") for card in topic_cards]
auxiliary_sections = self._build_auxiliary_sections(sections, topic_titles)
named_modules = self._build_template_named_modules(sections)
resource_hub_items = self._build_resource_hub_items(named_modules.get("shared_resources", []))
# 说明:
# 1. 这里注入“本地字体 CSS”到模板避免依赖 Google Fonts 等外网资源;
# 2. 字体文件统一从仓库根目录 fonts/ 下读取,便于部署时统一管理;
@@ -1178,6 +1220,7 @@ class MessageSummaryPlugin(MessagePluginInterface):
"summary_unresolved_pool": named_modules.get("unresolved_pool", []),
"summary_core_points": named_modules.get("core_points", []),
"summary_top_contributors": named_modules.get("top_contributors", []),
"summary_resource_hub": resource_hub_items,
"summary_fallback_text": layout_data.get("fallback_text", ""),
"summary_metrics": metrics_data,
"local_font_css": Markup(local_font_css),