From e3e2d22dc47225669f19de2932b78e396af68d4e Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Mon, 27 Apr 2026 01:42:52 +0800 Subject: [PATCH] fix(chat): restore collapse max height in block mode --- static/src/components/chat/ChatArea.vue | 3 ++- static/src/components/chat/StackedBlocks.vue | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/static/src/components/chat/ChatArea.vue b/static/src/components/chat/ChatArea.vue index 34d191e..55e50b6 100644 --- a/static/src/components/chat/ChatArea.vue +++ b/static/src/components/chat/ChatArea.vue @@ -959,10 +959,11 @@ const registerCollapseContent = (key: string, el: Element | null) => { if (!(el instanceof HTMLElement)) { return; } + const COLLAPSE_MAX_HEIGHT = 600; requestAnimationFrame(() => { const h = el.scrollHeight || el.offsetHeight || 0; if (h > 0) { - el.style.setProperty('--collapse-max', `${h}px`); + el.style.setProperty('--collapse-max', `${Math.min(h, COLLAPSE_MAX_HEIGHT)}px`); } }); }; diff --git a/static/src/components/chat/StackedBlocks.vue b/static/src/components/chat/StackedBlocks.vue index 0da69a6..da6e9e4 100644 --- a/static/src/components/chat/StackedBlocks.vue +++ b/static/src/components/chat/StackedBlocks.vue @@ -211,6 +211,7 @@ const viewportHeight = ref(0); const contentHeights = ref>({}); const ANIMATION_SYNC_MS = 360; const MORE_ANIMATION_MS = 300; +const COLLAPSE_MAX_HEIGHT = 600; let syncRaf: number | null = null; let syncUntil = 0; const isMoreAnimating = ref(false); @@ -293,7 +294,9 @@ const setShellMetrics = () => { const action = stackableActions.value[idx]; const key = blockKey(action, idx); const content = el.querySelector('.collapsible-content') as HTMLElement | null; - const contentHeight = content ? Math.ceil(content.scrollHeight) : 0; + const contentHeight = content + ? Math.min(Math.ceil(content.scrollHeight), COLLAPSE_MAX_HEIGHT) + : 0; nextContentHeights[key] = contentHeight; // 使用当前真实高度而非「展开/折叠」状态推导值,避免在折叠动画过程中出现高度骤减导致的闪烁