Revert "监控面板内容修改"

This reverts commit 455603de92.
This commit is contained in:
liuwei
2025-03-19 13:17:48 +08:00
parent 455603de92
commit 27b6fbf86f
4 changed files with 216 additions and 204 deletions

View File

@@ -112,10 +112,6 @@ class DashboardServer:
trend = self.stats_db.get_plugin_trend(plugin_name, days)
return jsonify({"success": True, "data": trend})
@app.route('/errors')
def errors():
return render_template('errors.html')
return app
def run(self) -> None:

View File

@@ -82,24 +82,25 @@
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b"
@select="handleSelect">
<el-menu-item index="/">
@select="handleSelect"
router>
<el-menu-item index="1" route="/">
<i class="el-icon-s-home"></i>
<span slot="title">首页概览</span>
</el-menu-item>
<el-menu-item index="/plugins">
<i class="el-icon-s-data"></i>
<el-menu-item index="2" route="/plugins">
<i class="el-icon-s-grid"></i>
<span slot="title">插件统计</span>
</el-menu-item>
<el-menu-item index="/users">
<el-menu-item index="3" route="/users">
<i class="el-icon-user"></i>
<span slot="title">用户统计</span>
</el-menu-item>
<el-menu-item index="/groups">
<el-menu-item index="4" route="/groups">
<i class="el-icon-s-cooperation"></i>
<span slot="title">群组统计</span>
</el-menu-item>
<el-menu-item index="/errors">
<el-menu-item index="5" route="/errors">
<i class="el-icon-warning"></i>
<span slot="title">错误日志</span>
</el-menu-item>

View File

@@ -232,102 +232,49 @@
}
// 准备数据
const dates = trendData.map(item => item.date);
const callCounts = trendData.map(item => item.call_count);
const successRates = trendData.map(item => item.success_rate);
const labels = trendData.map(item => item.stat_date);
const totalData = trendData.map(item => item.total_calls);
const successData = trendData.map(item => item.success_calls);
const errorData = trendData.map(item => item.error_calls);
// 创建图表
// 创建图表
this.charts.trendChart = new Chart(ctx, {
type: 'line',
data: {
labels: dates,
labels: labels,
datasets: [
{
label: '调用次数',
data: callCounts,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
label: '调用',
data: totalData,
fill: false,
backgroundColor: 'rgba(54, 162, 235, 0.6)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1,
yAxisID: 'y-axis-1'
tension: 0.1
},
{
label: '成功率(%)',
data: successRates,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
label: '成功调用',
data: successData,
fill: false,
backgroundColor: 'rgba(75, 192, 192, 0.6)',
borderColor: 'rgba(75, 192, 192, 1)',
tension: 0.1
},
{
label: '失败调用',
data: errorData,
fill: false,
backgroundColor: 'rgba(255, 99, 132, 0.6)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
yAxisID: 'y-axis-2'
tension: 0.1
}
]
},
options: {
responsive: true,
scales: {
yAxes: [
{
id: 'y-axis-1',
type: 'linear',
position: 'left',
ticks: {
beginAtZero: true
},
scaleLabel: {
display: true,
labelString: '调用次数'
}
},
{
id: 'y-axis-2',
type: 'linear',
position: 'right',
ticks: {
beginAtZero: true,
max: 100
},
scaleLabel: {
display: true,
labelString: '成功率(%)'
}
}
]
}
}
});
},
renderSuccessRateChart() {
const ctx = document.getElementById('successRateChart').getContext('2d');
// 销毁旧图表
if (this.charts.successRateChart) {
this.charts.successRateChart.destroy();
}
// 准备数据
const plugins = this.pluginStats.map(item => item.plugin_name);
const successRates = this.pluginStats.map(item => item.success_rate);
// 创建图表
this.charts.successRateChart = new Chart(ctx, {
type: 'bar',
data: {
labels: plugins,
datasets: [{
label: '成功率(%)',
data: successRates,
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
max: 100
}
}]
y: {
beginAtZero: true
}
}
}
});