From 43fee42198e8697185b427b1fa3eb79409603393 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 20 Jun 2025 17:06:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=A6=96=E6=AC=A1=E6=89=93=E5=BC=80?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=A5=E5=BF=97=E6=9F=A5=E7=9C=8B=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=BB=9A=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E5=BA=95=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/component/task-view/index.vue | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue index 8fa58455..e625ecb7 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue @@ -119,6 +119,31 @@ export default { logs: [], }); } + + async function scrollBottom(node: any, force = false) { + let el = document.querySelector(`.pi-task-view-logs.id-${node.node.id}`); + if (!el) { + return; + } + //判断当前是否在底部 + let isBottom = true; + if (el) { + isBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 5; + } + if (force) { + isBottom = true; + } + await nextTick(); + el = document.querySelector(`.pi-task-view-logs.id-${node.node.id}`); + //如果在底部则滚动到底部 + if (isBottom && el) { + el?.scrollTo({ + top: el.scrollHeight, + behavior: "smooth", + }); + } + } + for (let node of nodes) { if (currentHistory?.value?.logs != null) { node.logs = computed(() => { @@ -146,30 +171,12 @@ export default { return node.logs.value.length; }, async () => { - let el = document.querySelector(`.pi-task-view-logs.id-${node.node.id}`); - if (!el) { - return; - } - //判断当前是否在底部 - let isBottom = true; - if (el) { - isBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 5; - console.log("isBottom", isBottom, el.scrollHeight, el.scrollTop, el.clientHeight); - } - await nextTick(); - el = document.querySelector(`.pi-task-view-logs.id-${node.node.id}`); - //如果在底部则滚动到底部 - if (isBottom && el) { - el?.scrollTo({ - top: el.scrollHeight, - behavior: "smooth", - }); - } - }, - { - immediate: true, + await scrollBottom(node); } ); + nextTick(() => { + scrollBottom(node, true); + }); } }