Skip to content

Commit f999585

Browse files
author
Taois
committed
feat:多级目录问题修复
1 parent 673542d commit f999585

File tree

4 files changed

+272
-184
lines changed

4 files changed

+272
-184
lines changed

dashboard/src/components/SearchResults.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<!-- 加载状态 -->
3838
<div v-else-if="loading && videos.length === 0" class="loading-container">
39-
<a-spin size="large" />
39+
<a-spin :size="32" />
4040
<p class="loading-text">正在搜索...</p>
4141
</div>
4242

dashboard/src/components/VideoGrid.vue

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@scroll="handleScroll"
55
class="video-scroll-container"
66
ref="scrollbarRef"
7-
:style="'height:' + scrollAreaHeight + 'px; overflow: auto;'"
7+
:style="{ height: containerHeightRef + 'px', overflow: 'auto' }"
88
>
99
<a-grid :cols="{ xs: 2, sm: 3, md: 4, lg: 5, xl: 6, xxl: 8 }" :rowGap="16" :colGap="12">
1010
<a-grid-item
@@ -139,7 +139,9 @@ const router = useRouter();
139139
const visitedStore = useVisitedStore();
140140
const containerRef = ref(null);
141141
const scrollbarRef = ref(null);
142-
const scrollAreaHeight = ref(0);
142+
// 使用非响应式变量避免递归更新
143+
let containerHeight = 0;
144+
const containerHeightRef = ref(0);
143145
144146
// ActionRenderer相关
145147
const actionRendererRef = ref(null);
@@ -331,8 +333,9 @@ const updateScrollAreaHeight = () => {
331333
const newHeight = Math.max(containerHeight - footerHeight - heightReduction, 250); // 降低最小高度
332334
333335
// 只有当高度真正发生变化时才更新
334-
if (Math.abs(scrollAreaHeight.value - newHeight) > 5) {
335-
scrollAreaHeight.value = newHeight;
336+
if (Math.abs(containerHeight - newHeight) > 5) {
337+
containerHeight = newHeight;
338+
containerHeightRef.value = newHeight;
336339
}
337340
338341
console.log(`视频数量: ${videoCount}, 估算行数: ${estimatedRows}, 列数: ${gridCols}, 容器宽度: ${containerWidth}px, 最终高度: ${newHeight}px`);
@@ -452,29 +455,44 @@ onBeforeUnmount(() => {
452455
let updateTimer = null;
453456
let lastVideosLength = 0;
454457
let lastShowStats = false;
458+
let lastVideosHash = '';
459+
460+
// 计算videos数组的简单hash
461+
const getVideosHash = (videos) => {
462+
if (!videos || videos.length === 0) return '';
463+
return videos.map(v => v.vod_id || '').join(',');
464+
};
455465
456466
watch([() => props.videos, () => props.showStats], ([newVideos, newShowStats]) => {
457-
// 避免不必要的更新
458-
if (newVideos.length === lastVideosLength && newShowStats === lastShowStats) {
467+
const newVideosHash = getVideosHash(newVideos);
468+
469+
// 更严格的条件检查,避免不必要的更新
470+
if (newVideos.length === lastVideosLength &&
471+
newShowStats === lastShowStats &&
472+
newVideosHash === lastVideosHash) {
459473
return;
460474
}
461475
462476
lastVideosLength = newVideos.length;
463477
lastShowStats = newShowStats;
478+
lastVideosHash = newVideosHash;
464479
465480
// 清除之前的定时器
466481
if (updateTimer) {
467482
clearTimeout(updateTimer);
468483
}
469484
470-
// 使用防抖避免频繁更新
485+
// 使用防抖避免频繁更新,增加延迟
471486
updateTimer = setTimeout(() => {
472-
nextTick(() => {
473-
checkTextOverflow();
474-
updateScrollAreaHeight();
475-
});
476-
}, 100);
477-
}, { deep: true });
487+
// 再次检查是否需要更新,避免组件已卸载时的更新
488+
if (containerRef.value && !isUpdatingHeight && !isCheckingOverflow) {
489+
nextTick(() => {
490+
checkTextOverflow();
491+
updateScrollAreaHeight();
492+
});
493+
}
494+
}, 200); // 增加延迟到200ms
495+
}, { deep: false }); // 移除deep监听,减少触发频率
478496
479497
// 滚动位置恢复方法
480498
const restoreScrollPosition = (scrollPosition) => {

0 commit comments

Comments
 (0)