调整趋势图功能,加入了查询数据库,分析群聊聊天数量的功能
This commit is contained in:
@@ -433,10 +433,11 @@
|
|||||||
axios.get(`/api/robot/group/${this.currentGroupId}/message_trend?days=${this.trendDays}`)
|
axios.get(`/api/robot/group/${this.currentGroupId}/message_trend?days=${this.trendDays}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
this.$nextTick(() => {
|
// 使用setTimeout确保DOM已完全渲染
|
||||||
|
setTimeout(() => {
|
||||||
this.renderTrendChart(response.data.data);
|
this.renderTrendChart(response.data.data);
|
||||||
this.trendLoading = false;
|
this.trendLoading = false;
|
||||||
});
|
}, 300);
|
||||||
} else {
|
} else {
|
||||||
this.$message.error('加载消息趋势失败');
|
this.$message.error('加载消息趋势失败');
|
||||||
this.trendLoading = false;
|
this.trendLoading = false;
|
||||||
@@ -451,7 +452,17 @@
|
|||||||
|
|
||||||
renderTrendChart(data) {
|
renderTrendChart(data) {
|
||||||
try {
|
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) {
|
if (this.charts.trendChart) {
|
||||||
|
|||||||
Reference in New Issue
Block a user