@@ -192,15 +192,20 @@ const checkContentHeight = () => {
192192 contentHeight = scrollContainer .scrollHeight ;
193193 const clientHeight = scrollContainer .clientHeight ;
194194
195+ // 计算理想的容器高度(基于窗口大小)
196+ const windowHeight = window .innerHeight || document .documentElement .clientHeight || 600 ;
197+ const idealHeight = Math .max (windowHeight - 200 , 400 );
198+
195199 // 如果内容高度小于等于容器高度,说明无法产生滚动
196200 if (contentHeight <= clientHeight && props .videos && props .videos .length > 0 ) {
197201 // 检查是否还有更多数据可以加载
198202 const hasMoreData = props .hasMore !== false ;
199203
200204 if (hasMoreData) {
201- // 减小容器高度以强制产生滚动条,但不能太小
202- const minHeight = Math .min (400 , contentHeight - 50 );
203- if (minHeight > 200 && containerHeight > minHeight) {
205+ // 减小容器高度以强制产生滚动条,但降低幅度要小,只需要能产生滚动即可
206+ // 减少200px的降低量,只降低必要的最小高度
207+ const minHeight = Math .min (670 , contentHeight - 10 ); // 从contentHeight-50改为contentHeight-10,减少降低幅度
208+ if (minHeight > 470 && containerHeight > minHeight) { // 从200改为400,减少过度降低
204209 containerHeight = minHeight;
205210 containerHeightTrigger .value ++ ;
206211
@@ -214,7 +219,7 @@ const checkContentHeight = () => {
214219 if (autoLoadTimer) clearTimeout (autoLoadTimer);
215220 autoLoadTimer = setTimeout (() => {
216221 checkAutoLoadMore ();
217- }, 500 );
222+ }, 100 ); // 减少延迟时间
218223 } else {
219224 // 如果容器已经很小了,直接触发加载更多
220225 console .log (' [DEBUG] 容器已达最小高度,直接触发加载更多' );
@@ -223,6 +228,21 @@ const checkContentHeight = () => {
223228 } else {
224229 console .log (' [DEBUG] 没有更多数据可加载,保持当前状态' );
225230 }
231+ } else if (contentHeight > clientHeight) {
232+ // 内容高度大于容器高度,说明可以产生滚动
233+ // 检查是否需要恢复到理想高度
234+ if (containerHeight < idealHeight && contentHeight >= idealHeight * 0.8 ) {
235+ // 如果当前容器高度小于理想高度,且内容足够多,则恢复到理想高度
236+ containerHeight = idealHeight;
237+ containerHeightTrigger .value ++ ;
238+
239+ console .log (' [DEBUG] 恢复容器高度到理想高度:' , {
240+ contentHeight,
241+ clientHeight,
242+ idealHeight,
243+ newContainerHeight: containerHeight
244+ });
245+ }
226246 }
227247 } catch (error) {
228248 console .error (' checkContentHeight error:' , error);
@@ -256,6 +276,42 @@ const checkAutoLoadMore = () => {
256276 }
257277};
258278
279+ // 检查并恢复容器高度到理想状态
280+ const checkHeightRestore = () => {
281+ if (isProcessing) return ;
282+
283+ try {
284+ const container = containerRef .value ;
285+ if (! container) return ;
286+
287+ const scrollContainer = container .querySelector (' .arco-scrollbar-container' );
288+ if (! scrollContainer) return ;
289+
290+ const contentHeight = scrollContainer .scrollHeight ;
291+ const clientHeight = scrollContainer .clientHeight ;
292+
293+ // 计算理想的容器高度
294+ const windowHeight = window .innerHeight || document .documentElement .clientHeight || 600 ;
295+ const idealHeight = Math .max (windowHeight - 200 , 400 );
296+
297+ // 如果内容足够多且当前容器高度小于理想高度,则恢复
298+ if (contentHeight > idealHeight * 0.8 && containerHeight < idealHeight) {
299+ containerHeight = idealHeight;
300+ containerHeightTrigger .value ++ ;
301+
302+ console .log (' [DEBUG] 主动恢复容器高度:' , {
303+ contentHeight,
304+ clientHeight,
305+ idealHeight,
306+ oldContainerHeight: containerHeight,
307+ newContainerHeight: idealHeight
308+ });
309+ }
310+ } catch (error) {
311+ console .error (' checkHeightRestore error:' , error);
312+ }
313+ };
314+
259315// ActionRenderer相关
260316const actionRendererRef = ref (null );
261317const showActionRenderer = ref (false );
@@ -444,6 +500,11 @@ const handleScroll = (e) => {
444500 if (scrollHeight - scrollTop < 50 ) {
445501 emit (' scroll-bottom' );
446502 emit (' load-more' );
503+
504+ // 延迟检查高度恢复,因为加载更多内容后可能需要恢复高度
505+ setTimeout (() => {
506+ checkHeightRestore ();
507+ }, 200 ); // 减少延迟时间,让高度恢复更快
447508 }
448509};
449510
@@ -598,8 +659,12 @@ watch([() => props.videos, () => props.showStats], ([newVideos, newShowStats]) =
598659 console .log (' Videos updated:' , newVideos .length );
599660 // 检查内容高度
600661 checkContentHeight ();
662+ // 延迟检查高度恢复,确保内容已经渲染完成
663+ setTimeout (() => {
664+ checkHeightRestore ();
665+ }, 50 ); // 减少延迟时间,让用户无感知
601666 }
602- }, 300 ); // 增加延迟时间
667+ }, 50 ); // 大幅减少延迟时间,让高度调整更快响应
603668
604669 updateTimer ._lastUpdate = Date .now ();
605670}, { deep: false , flush: ' post' }); // 使用post flush避免同步更新
0 commit comments