From 5d43d52fbc8af05c47fe46fb7c83253fa8af8463 Mon Sep 17 00:00:00 2001 From: lizijiee <562949697@qq.com> Date: Wed, 20 Mar 2024 18:08:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20ai=E5=B7=A5=E5=8D=95=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82=E5=A2=9E=E5=8A=A0=E6=8B=A6?= =?UTF-8?q?=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/worksheet/aside/WorkSheetList.vue | 27 ++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/views/worksheet/aside/WorkSheetList.vue b/src/views/worksheet/aside/WorkSheetList.vue index a755ad0..d562ab2 100644 --- a/src/views/worksheet/aside/WorkSheetList.vue +++ b/src/views/worksheet/aside/WorkSheetList.vue @@ -12,6 +12,7 @@ const activeId = ref(""); const el = ref(null); const keyword = ref(""); const canloadMore = ref(true); +const isLoading = ref(false); defineProps({ showFieldList: { @@ -28,27 +29,27 @@ function selectHandler(id: string, index: number) { workStore.setActive(index); } -const { isLoading } = useInfiniteScroll( +useInfiniteScroll( el as any, () => { loadMore(); }, { distance: 10, - interval: 800, - canLoadMore: () => { - // console.log('canloadmore excuted!') - return canloadMore.value; - }, + interval: 1500, + canLoadMore: () => canloadMore.value } ); async function loadMore() { if (isLoading.value || el.value == null) return; - - // console.log('loadmore') - const more = await fetchList(); - data.value.push(...more); + isLoading.value = true; + try { + const more = await fetchList(); + data.value.push(...more); + } finally { + isLoading.value = false; + } } async function fetchList() { @@ -56,7 +57,11 @@ async function fetchList() { pagination.pageNo += 1; const result = await workStore.fetchOrderList(pagination, keyword.value); const { data, pageCount } = result; - canloadMore.value = pageCount >= pagination.pageNo && pageCount !== 0; + if(pageCount !== 0){ + canloadMore.value = pageCount >= pagination.pageNo ; + }else{ + canloadMore.value = false; + } return data || []; } catch (error) { canloadMore.value = false;