From 42bb6fd367c361cd992ea8cb63300dfb7bf2caac Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 8 May 2025 11:16:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=AE=9A=E6=97=B6=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/templates/wx_logs.html | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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; + } } } });