feat(report): 优化统计报告页面的UI和布局

对生成的HTML统计报告进行了全面的视觉和结构重构,以提供更现代化、更具可读性的用户界面。

- 采用仪表盘式的双栏布局(主内容区和侧边栏),将图表移至侧边栏,使数据表格更聚焦。
- 全面更新了CSS样式,包括配色、字体、卡片、表格和标签页,提升了整体的美观度和用户体验。
- 引入了响应式设计,以更好地适配移动设备。
- 将默认输出文件名从 `maibot_statistics.html` 更改为 `mofox_bot_statistics.html` 以保持项目命名一致性。
This commit is contained in:
minecraft1024a
2025-11-13 12:47:36 +08:00
committed by Windpicker-owo
parent cfb111eca5
commit f604eacea0
4 changed files with 187 additions and 157 deletions

View File

@@ -10,7 +10,7 @@ services:
volumes:
- ./docker-config/core/.env:/app/.env # 持久化env配置文件
- ./docker-config/core:/app/config # 持久化bot配置文件
- ./data/core/maibot_statistics.html:/app/maibot_statistics.html #统计数据输出
- ./data/core/mofox_bot_statistics.html:/app/mofox_bot_statistics.html #统计数据输出
- ./data/app:/app/data # 共享目录
- ./data/core/plugins:/app/plugins # 插件目录
- ./data/core/logs:/app/logs # 日志目录

View File

@@ -115,7 +115,7 @@ class StatisticOutputTask(AsyncTask):
SEP_LINE = "-" * 84
def __init__(self, record_file_path: str = "maibot_statistics.html"):
def __init__(self, record_file_path: str = "mofox_bot_statistics.html"):
# 延迟300秒启动运行间隔300秒
super().__init__(task_name="Statistics Data Output Task", wait_before_start=0, run_interval=300)

View File

@@ -1,54 +1,159 @@
/* General Body Styles */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f7f6;
color: #333;
background-color: #F8F9FA; /* Light grey background */
color: #495057; /* Softer text color */
line-height: 1.6;
}
/* Main Container */
.container {
max-width: 900px;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 25px;
background-color: #FFFFFF; /* Pure white background */
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
border: 1px solid #EAEAEA;
}
/* Dashboard Layout */
.dashboard-layout {
display: flex;
gap: 30px;
}
.main-content {
flex: 65%;
min-width: 0;
}
.sidebar-content {
flex: 35%;
min-width: 0;
}
/* Responsive Design for Mobile */
@media (max-width: 992px) {
.dashboard-layout {
flex-direction: column;
}
.main-content, .sidebar-content {
flex: 1;
}
}
/* Typography */
h1, h2 {
color: #2c3e50;
border-bottom: 2px solid #3498db;
color: #212529;
padding-bottom: 10px;
margin-top: 0;
}
h1 {
text-align: center;
font-size: 2em;
font-size: 2.2em;
margin-bottom: 20px;
color: #4A90E2; /* Main blue for title */
}
h2 {
font-size: 1.5em;
margin-top: 30px;
}
p {
margin-bottom: 10px;
margin-top: 40px;
margin-bottom: 15px;
border-bottom: 2px solid #EAEAEA;
}
/* Info Banners */
.info-item {
background-color: #ecf0f1;
padding: 8px 12px;
border-radius: 4px;
margin-bottom: 8px;
background-color: #E9ECEF;
padding: 10px 15px;
border-radius: 6px;
margin-bottom: 20px;
font-size: 0.95em;
border: 1px solid #DEE2E6;
}
.info-item strong {
color: #2980b9;
color: #4A90E2;
}
/* Tabs */
.tabs {
border-bottom: 2px solid #DEE2E6;
display: flex;
margin-bottom: 20px;
}
.tabs button {
background: none;
border: none;
outline: none;
padding: 14px 20px;
cursor: pointer;
transition: all 0.3s ease;
font-size: 16px;
color: #6C757D;
border-bottom: 3px solid transparent;
margin-bottom: -2px; /* Align with container border */
}
.tabs button:hover {
color: #212529;
}
.tabs button.active {
color: #4A90E2;
border-bottom-color: #4A90E2;
}
.tab-content {
display: none;
padding-top: 10px;
}
.tab-content.active {
display: block;
}
/* Summary Cards */
.summary-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 20px;
margin: 20px 0;
}
.card {
background-color: #FFFFFF;
padding: 20px;
border-radius: 8px;
text-align: center;
border: 1px solid #EAEAEA;
transition: all 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 15px rgba(0,0,0,0.08);
}
.card h3 {
margin: 0 0 10px;
font-size: 1em;
color: #6C757D;
}
.card p {
margin: 0;
font-size: 1.8em;
font-weight: bold;
color: #212529;
}
/* Tables */
table {
width: 100%;
border-collapse: collapse;
@@ -57,121 +162,40 @@ table {
}
th, td {
border: 1px solid #ddd;
padding: 10px;
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #EAEAEA;
}
th {
background-color: #3498db;
background-color: #4A90E2;
color: white;
font-weight: bold;
font-size: 0.95em;
text-transform: uppercase;
letter-spacing: 0.5px;
}
tr:nth-child(even) {
background-color: #f9f9f9;
background-color: #F8F9FA;
}
.footer {
text-align: center;
margin-top: 30px;
font-size: 0.8em;
color: #7f8c8d;
}
.tabs {
overflow: hidden;
background: #ecf0f1;
display: flex;
}
.tabs button {
background: inherit;
border: none;
outline: none;
padding: 14px 16px;
cursor: pointer;
transition: 0.3s;
font-size: 16px;
}
.tabs button:hover {
background-color: #d4dbdc;
}
.tabs button.active {
background-color: #b3bbbd;
}
.tab-content {
display: none;
padding: 20px;
background-color: #fff;
border: 1px solid #ccc;
}
.tab-content.active {
display: block;
}
.summary-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
margin: 20px 0;
}
.card {
background-color: #ecf0f1;
padding: 15px;
border-radius: 5px;
text-align: center;
}
.card h3 {
margin: 0 0 10px;
font-size: 1em;
color: #2c3e50;
}
.card p {
margin: 0;
font-size: 1.2em;
font-weight: bold;
color: #34495e;
}
.chart-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-top: 20px;
tr:hover {
background-color: #E9ECEF;
}
/* Chart Container in Sidebar */
.chart-container {
position: relative;
height: 40vh;
height: 300px; /* Adjust height as needed */
width: 100%;
margin-bottom: 20px;
}
.time-range-btn {
background-color: #ecf0f1;
border: 1px solid #bdc3c7;
color: #2c3e50;
padding: 8px 16px;
margin: 0 5px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: all 0.3s ease;
/* Footer */
.footer {
text-align: center;
margin-top: 40px;
font-size: 0.85em;
color: #6C757D;
}
.time-range-btn:hover {
background-color: #d5dbdb;
}
.time-range-btn.active {
background-color: #3498db;
color: white;
border-color: #2980b9;
}

View File

@@ -1,44 +1,50 @@
<div id="{{ div_id }}" class="tab-content">
<p class="info-item">
<strong>统计时段: </strong>
{{ start_time }} ~ {{ end_time }}
</p>
{{ summary_cards }}
{{ static_charts }}
<div class="dashboard-layout">
<div class="main-content">
<p class="info-item">
<strong>统计时段: </strong>
{{ start_time }} ~ {{ end_time }}
</p>
{{ summary_cards }}
<h2>按模型分类统计</h2>
<table>
<tr><th>模型名称</th><th>调用次数</th><th>平均Token数</th><th>Token总量</th><th>TPS</th><th>每K Token成本</th><th>累计花费</th><th>平均耗时(秒)</th></tr>
<tbody>{{ model_rows }}</tbody>
</table>
<h2>按模型分类统计</h2>
<table>
<tr><th>模型名称</th><th>调用次数</th><th>平均Token数</th><th>Token总量</th><th>TPS</th><th>每K Token成本</th><th>累计花费</th><th>平均耗时(秒)</th></tr>
<tbody>{{ model_rows }}</tbody>
</table>
<h2>按供应商分类统计</h2>
<table>
<tr><th>供应商名称</th><th>调用次数</th><th>Token总量</th><th>TPS</th><th>每K Token成本</th><th>累计花费</th></tr>
<tbody>{{ provider_rows }}</tbody>
</table>
<h2>按供应商分类统计</h2>
<table>
<tr><th>供应商名称</th><th>调用次数</th><th>Token总量</th><th>TPS</th><th>每K Token成本</th><th>累计花费</th></tr>
<tbody>{{ provider_rows }}</tbody>
</table>
<h2>按模块分类统计</h2>
<table>
<thead>
<tr><th>模块名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
</thead>
<tbody>{{ module_rows }}</tbody>
</table>
<h2>按模块分类统计</h2>
<table>
<thead>
<tr><th>模块名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
</thead>
<tbody>{{ module_rows }}</tbody>
</table>
<h2>按请求类型分类统计</h2>
<table>
<thead>
<tr><th>请求类型</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
</thead>
<tbody>{{ type_rows }}</tbody>
</table>
<h2>按请求类型分类统计</h2>
<table>
<thead>
<tr><th>请求类型</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
</thead>
<tbody>{{ type_rows }}</tbody>
</table>
<h2>聊天消息统计</h2>
<table>
<thead>
<tr><th>联系人/群组名称</th><th>消息数量</th></tr>
</thead>
<tbody>{{ chat_rows }}</tbody>
</table>
<h2>聊天消息统计</h2>
<table>
<thead>
<tr><th>联系人/群组名称</th><th>消息数量</th></tr>
</thead>
<tbody>{{ chat_rows }}</tbody>
</table>
</div>
<div class="sidebar-content">
{{ static_charts }}
</div>
</div>
</div>