fix(chat): restore collapse max height in block mode

This commit is contained in:
JOJO 2026-04-27 01:42:52 +08:00
parent 3c1773dc01
commit e3e2d22dc4
2 changed files with 6 additions and 2 deletions

View File

@ -959,10 +959,11 @@ const registerCollapseContent = (key: string, el: Element | null) => {
if (!(el instanceof HTMLElement)) { if (!(el instanceof HTMLElement)) {
return; return;
} }
const COLLAPSE_MAX_HEIGHT = 600;
requestAnimationFrame(() => { requestAnimationFrame(() => {
const h = el.scrollHeight || el.offsetHeight || 0; const h = el.scrollHeight || el.offsetHeight || 0;
if (h > 0) { if (h > 0) {
el.style.setProperty('--collapse-max', `${h}px`); el.style.setProperty('--collapse-max', `${Math.min(h, COLLAPSE_MAX_HEIGHT)}px`);
} }
}); });
}; };

View File

@ -211,6 +211,7 @@ const viewportHeight = ref(0);
const contentHeights = ref<Record<string, number>>({}); const contentHeights = ref<Record<string, number>>({});
const ANIMATION_SYNC_MS = 360; const ANIMATION_SYNC_MS = 360;
const MORE_ANIMATION_MS = 300; const MORE_ANIMATION_MS = 300;
const COLLAPSE_MAX_HEIGHT = 600;
let syncRaf: number | null = null; let syncRaf: number | null = null;
let syncUntil = 0; let syncUntil = 0;
const isMoreAnimating = ref(false); const isMoreAnimating = ref(false);
@ -293,7 +294,9 @@ const setShellMetrics = () => {
const action = stackableActions.value[idx]; const action = stackableActions.value[idx];
const key = blockKey(action, idx); const key = blockKey(action, idx);
const content = el.querySelector('.collapsible-content') as HTMLElement | null; 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; nextContentHeights[key] = contentHeight;
// 使/ // 使/