调整趋势图功能,加入了查询数据库,分析群聊聊天数量的功能

This commit is contained in:
liuwei
2025-03-26 13:55:52 +08:00
parent 850d81a9ff
commit 759076589b

View File

@@ -433,10 +433,11 @@
axios.get(`/api/robot/group/${this.currentGroupId}/message_trend?days=${this.trendDays}`)
.then(response => {
if (response.data.success) {
this.$nextTick(() => {
// 使用setTimeout确保DOM已完全渲染
setTimeout(() => {
this.renderTrendChart(response.data.data);
this.trendLoading = false;
});
}, 300);
} else {
this.$message.error('加载消息趋势失败');
this.trendLoading = false;
@@ -451,7 +452,17 @@
renderTrendChart(data) {
try {
const ctx = document.getElementById('messageTrendChart').getContext('2d');
// 获取Canvas元素
const canvas = document.getElementById('messageTrendChart');
if (!canvas) {
console.error('找不到Canvas元素ID: messageTrendChart');
this.$message.error('无法找到图表元素,请尝试重新打开对话框');
this.trendLoading = false;
return;
}
const ctx = canvas.getContext('2d');
// 销毁旧图表
if (this.charts.trendChart) {