Skip to content

Commit 28a909e

Browse files
committed
fix: optimize data loading in ParagraphList component
1 parent 79537ca commit 28a909e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ui/src/views/knowledge/component/ParagraphList.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,20 @@ const props = defineProps({
7070
knowledgeId: String
7171
})
7272
73+
// 初始化加载数据
74+
watchEffect(() => {
75+
if (props.modelValue && props.modelValue.length > 0) {
76+
const end = page_size.value * current_page.value;
77+
localParagraphList.value = props.modelValue.slice(0, Math.min(end, props.modelValue.length));
78+
}
79+
})
80+
7381
// 监听分页变化,只加载需要的数据
7482
watchEffect(() => {
7583
const start = 0;
7684
const end = page_size.value * current_page.value;
77-
// 只获取所需数量的数据,而不是每次都对整个数组进行切片
78-
if (end <= props.modelValue.length) {
79-
localParagraphList.value = props.modelValue.slice(start, end);
80-
}
85+
// 不管数据量多少,都确保获取所有应该显示的数据
86+
localParagraphList.value = props.modelValue.slice(start, Math.min(end, props.modelValue.length));
8187
})
8288
8389
const paragraph_list = computed(() => {

0 commit comments

Comments
 (0)