style: enhance stats docs with colored badges for post types

This commit is contained in:
fujie
2026-02-11 13:34:14 +08:00
parent 871e76b1df
commit 4032746243

View File

@@ -602,11 +602,24 @@ class OpenWebUIStats:
md.append("") md.append("")
# 按类型分类 # 按类型分类 (使用徽章)
md.append(t["type_title"]) md.append(t["type_title"])
md.append("") md.append("")
type_colors = {
"post": "blue",
"filter": "brightgreen",
"action": "orange",
"pipe": "blueviolet",
"pipeline": "purple",
"review": "yellow",
"prompt": "lightgrey",
}
for post_type, count in stats["by_type"].items(): for post_type, count in stats["by_type"].items():
md.append(f"- **{post_type}**: {count}") color = type_colors.get(post_type, "gray")
badge = f"![{post_type}](https://img.shields.io/badge/{post_type}-{count}-{color})"
md.append(f"- {badge}")
md.append("") md.append("")
# 详细列表 # 详细列表
@@ -633,7 +646,9 @@ class OpenWebUIStats:
f"post_{slug_hash}_sv", stats, user, delta, is_post=True f"post_{slug_hash}_sv", stats, user, delta, is_post=True
) )
# 版本号使用态 Shields.io 徽章 # 版本号使用态 Shields.io 徽章 (由于列表太长,我们这次没给所有 post 生成单独的 version json)
# 不过实际上 upload_gist_badges 是给 top 6 生成的。
# 对于完整列表,还是暂时用静态吧,避免要把几百个 version json 都生成出来传到 Gist
ver = post["version"] if post["version"] else "N/A" ver = post["version"] if post["version"] else "N/A"
ver_color = "blue" if post["version"] else "gray" ver_color = "blue" if post["version"] else "gray"
ver_badge = ( ver_badge = (