diff --git a/admin/dashboard/templates/wx_logs.html b/admin/dashboard/templates/wx_logs.html index d2d87e5..ee71b52 100644 --- a/admin/dashboard/templates/wx_logs.html +++ b/admin/dashboard/templates/wx_logs.html @@ -17,6 +17,13 @@ + + + + + + + 刷新 @@ -43,12 +50,17 @@ logType: 'info', logLines: 100, logContent: [], + refreshInterval: 0, // 新增,定时刷新间隔(秒),0为不自动刷新 + refreshTimer: null, // 新增,定时器句柄 currentView: '9' // 设置当前菜单项 } }, mounted() { this.loadLogs(); }, + beforeDestroy() { + this.clearRefreshTimer(); + }, methods: { loadLogs() { this.loading = true; @@ -56,6 +68,13 @@ .then(response => { if (response.data.success) { this.logContent = response.data.data.content || []; + // 日志内容更新后自动滚动到底部 + this.$nextTick(() => { + const logDiv = this.$el.querySelector('.log-content'); + if (logDiv) { + logDiv.scrollTop = logDiv.scrollHeight; + } + }); } else { this.$message.error('加载日志失败'); } @@ -67,6 +86,20 @@ .finally(() => { this.loading = false; }); + }, + handleRefreshInterval() { + this.clearRefreshTimer(); + if (this.refreshInterval > 0) { + this.refreshTimer = setInterval(() => { + this.loadLogs(); + }, this.refreshInterval * 1000); + } + }, + clearRefreshTimer() { + if (this.refreshTimer) { + clearInterval(this.refreshTimer); + this.refreshTimer = null; + } } } });