From 54aabab985245b7b5da00fc338b6f10b525f7dc5 Mon Sep 17 00:00:00 2001 From: engigu Date: Mon, 23 Mar 2026 23:25:19 +0800 Subject: [PATCH] feat: add logs auto scoller -- smooth --- web/src/views/history/LogViewer.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/src/views/history/LogViewer.vue b/web/src/views/history/LogViewer.vue index 3778275..66b68d2 100644 --- a/web/src/views/history/LogViewer.vue +++ b/web/src/views/history/LogViewer.vue @@ -34,17 +34,20 @@ function handleScroll() { } // 滚动到底部 -const scrollToBottom = async () => { +const scrollToBottom = async (smooth = true) => { await nextTick() if (scrollContainer.value && shouldAutoScroll.value) { - scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight + scrollContainer.value.scrollTo({ + top: scrollContainer.value.scrollHeight, + behavior: smooth ? 'smooth' : 'auto' + }) } } // 监听内容变化,实现自动滚动 watch(() => props.content, () => { if (props.open) { - scrollToBottom() + scrollToBottom(true) } }) @@ -63,7 +66,7 @@ watch(() => props.open, (val) => { searchKeyword.value = '' shouldAutoScroll.value = true // 每次重新打开都开启自动滚动 toggleBodyScroll(true) - scrollToBottom() + scrollToBottom(false) // 首次打开立刻定位,不滑动 } else { toggleBodyScroll(false) }