diff --git a/plugins/stats_dashboard/templates/robot_management.html b/plugins/stats_dashboard/templates/robot_management.html index 982d0eb..64e8c27 100644 --- a/plugins/stats_dashboard/templates/robot_management.html +++ b/plugins/stats_dashboard/templates/robot_management.html @@ -45,7 +45,7 @@ - + @@ -136,82 +130,6 @@ 确定 - - - -
- -

加载中...

-
-
-
-

消息数量趋势

- -
- - - - - - - - - - - - - - - - - -
日期消息数量
{{ date }} - {{ trendData.counts[index] }} - ({{ getPercentage(index) }}%) -
-
-
-
总计{{ totalMessages }}
-
-
暂无数据
- - -
-

统计摘要

-
-
-
总消息数
-
{{ totalMessages }}
-
-
-
日均消息数
-
{{ avgMessages }}
-
-
-
最高消息日
-
{{ maxDay }} ({{ maxMessages }})
-
-
-
最低消息日
-
{{ minDay }} ({{ minMessages }})
-
-
-
-
-
- - 最近7天 - 最近14天 - 最近30天 - -
-
-
{% endblock %} @@ -239,16 +157,7 @@ { required: true, message: '请输入群组ID', trigger: 'blur' }, { pattern: /^\S+$/, message: '群组ID不能包含空格', trigger: 'blur' } ] - }, - // 趋势图相关数据 - trendDialogVisible: false, - trendLoading: false, - trendDays: 7, - trendData: { - dates: [], - counts: [] - }, - charts: {} // 保留charts对象,以防其他地方还在使用 + } } }, computed: { @@ -259,33 +168,6 @@ (group.group_id && group.group_id.toLowerCase().includes(query)) || (group.group_name && group.group_name.toLowerCase().includes(query)) ); - }, - // 计算属性用于趋势数据 - totalMessages() { - if (!this.trendData || !this.trendData.counts) return 0; - return this.trendData.counts.reduce((sum, count) => sum + parseInt(count || 0), 0); - }, - avgMessages() { - if (!this.trendData || !this.trendData.dates || this.trendData.dates.length === 0) return 0; - return (this.totalMessages / this.trendData.dates.length).toFixed(2); - }, - maxMessages() { - 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() { - 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] : ''; } }, mounted() { @@ -495,87 +377,8 @@ this.$message.error('批量移除失败: ' + error.message); }); }).catch(() => {}); - }, - // 查看消息趋势 - viewMessageTrend(group) { - this.currentGroupId = group.group_id; - this.currentGroupName = group.group_name || group.group_id; - this.trendDialogVisible = true; - }, - - // 对话框打开后的回调 - onTrendDialogOpened() { - console.log('对话框已打开'); - this.$nextTick(() => { - this.loadMessageTrend(); - }); - }, - - loadMessageTrend() { - this.trendLoading = true; - - axios.get(`/api/robot/group/${this.currentGroupId}/message_trend?days=${this.trendDays}`) - .then(response => { - if (response.data.success) { - // 直接更新数据,让Vue的响应式系统处理渲染 - this.trendData = response.data.data || { dates: [], counts: [] }; - this.trendLoading = false; - } else { - this.$message.error('加载消息趋势失败'); - // 设置默认值 - this.trendData = { dates: [], counts: [] }; - this.trendLoading = false; - } - }) - .catch(error => { - console.error('加载消息趋势失败:', error); - this.$message.error('加载消息趋势失败: ' + error.message); - // 设置默认值 - this.trendData = { dates: [], counts: [] }; - this.trendLoading = false; - }); - }, - - // 计算百分比的方法 - getPercentage(index) { - if (!this.trendData || !this.trendData.counts || !Array.isArray(this.trendData.counts)) return 0; - if (index < 0 || index >= this.trendData.counts.length) return 0; - - const count = parseInt(this.trendData.counts[index] || 0); - return this.totalMessages > 0 ? - ((count / this.totalMessages) * 100).toFixed(2) : 0; - }, - - // 确保在打开对话框时重置 trendData - viewMessageTrend(group) { - this.currentGroupId = group.group_id; - this.currentGroupName = group.group_name || group.group_id; - // 重置 trendData 为默认值 - this.trendData = { dates: [], counts: [] }; - this.trendDialogVisible = true; } - - // ... 其他方法保持不变 ... } }); -{% endblock %} - -{% block styles %} - {% endblock %} \ No newline at end of file