diff --git a/plugins/stats_dashboard/templates/robot_management.html b/plugins/stats_dashboard/templates/robot_management.html index ac6c984..43f5cc0 100644 --- a/plugins/stats_dashboard/templates/robot_management.html +++ b/plugins/stats_dashboard/templates/robot_management.html @@ -247,7 +247,8 @@ trendData: { dates: [], counts: [] - } + }, + charts: {} // 保留charts对象,以防其他地方还在使用 } }, computed: { @@ -261,25 +262,28 @@ }, // 计算属性用于趋势数据 totalMessages() { + if (!this.trendData || !this.trendData.counts) return 0; return this.trendData.counts.reduce((sum, count) => sum + parseInt(count || 0), 0); }, avgMessages() { - return this.trendData.dates.length > 0 ? - (this.totalMessages / this.trendData.dates.length).toFixed(2) : 0; + if (!this.trendData || !this.trendData.dates || this.trendData.dates.length === 0) return 0; + return (this.totalMessages / this.trendData.dates.length).toFixed(2); }, maxMessages() { - return this.trendData.counts.length > 0 ? - Math.max(...this.trendData.counts.map(c => parseInt(c || 0))) : 0; + if (!this.trendData || !this.trendData.counts || this.trendData.counts.length === 0) return 0; + return Math.max(...this.trendData.counts.map(c => parseInt(c || 0))); }, minMessages() { - return this.trendData.counts.length > 0 ? - Math.min(...this.trendData.counts.map(c => parseInt(c || 0))) : 0; + if (!this.trendData || !this.trendData.counts || this.trendData.counts.length === 0) return 0; + return Math.min(...this.trendData.counts.map(c => parseInt(c || 0))); }, maxDay() { + if (!this.trendData || !this.trendData.counts || !this.trendData.dates) return ''; const maxIndex = this.trendData.counts.indexOf(this.maxMessages.toString()); return maxIndex >= 0 ? this.trendData.dates[maxIndex] : ''; }, minDay() { + if (!this.trendData || !this.trendData.counts || !this.trendData.dates) return ''; const minIndex = this.trendData.counts.indexOf(this.minMessages.toString()); return minIndex >= 0 ? this.trendData.dates[minIndex] : ''; } @@ -530,6 +534,7 @@ // 计算百分比的方法 getPercentage(index) { + if (!this.trendData || !this.trendData.counts) return 0; const count = parseInt(this.trendData.counts[index] || 0); return this.totalMessages > 0 ? ((count / this.totalMessages) * 100).toFixed(2) : 0;