Skip to content

Commit

Permalink
feat(doc): remove auto load more
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenZhang committed Dec 25, 2024
1 parent c8d43d8 commit 4f3bea7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/locale/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mEnUS = {
Author: 'Author',
AccessDenied: 'Access Denied',
InputKeywords: 'Fuzzy Search',
LoadMore: 'Load More',
};

export default mEnUS;
1 change: 1 addition & 0 deletions src/locale/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mZhCN = {
Author: '作者',
AccessDenied: '未经授权访问',
InputKeywords: '关键字搜索',
LoadMore: '加载更多',
};

export default mZhCN;
27 changes: 13 additions & 14 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,10 @@ onMounted(() => window.addEventListener('resize', () => handleResize()));
onUnmounted(() => window.removeEventListener('resize', () => {}));
// load more
const container = document.getElementById('app-content-scroll');
const loadMore = () => {
if (
(container.scrollTop + container.clientHeight === container.scrollHeight) &&
(searchData.value.total > searchData.value.current * searchData.value.size)
) {
searchData.value.current += 1;
loadDocs(true);
}
searchData.value.current += 1;
loadDocs(true);
};
onMounted(() => {
container.addEventListener('scroll', () => loadMore());
});
onUnmounted(() => {
container.removeEventListener('scroll', () => {});
});
</script>

<template>
Expand Down Expand Up @@ -204,6 +192,17 @@ onUnmounted(() => {
</a-col>
</a-row>
</a-spin>
<div
style="width: 100%; display: flex; justify-content: center; margin-top: 20px;"
v-if="!docLoading && (searchData.total > searchData.current * searchData.size)"
>
<a-link @click="loadMore">
<div style="display: flex; flex-direction: column; align-items: center">
<div>{{ $t('LoadMore') }}</div>
<icon-down style="font-size: 14px" />
</div>
</a-link>
</div>
<skeleton
v-show="(docAppendLoading && docs.length) || (!docLoading && !docs.length)"
:animation="docAppendLoading"
Expand Down

0 comments on commit 4f3bea7

Please sign in to comment.