mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-12 01:24:38 +08:00
feat: Add pagination cache
This commit is contained in:
parent
598098c2ed
commit
77345a586c
2 changed files with 13 additions and 9 deletions
|
@ -153,6 +153,7 @@ const startIndex = ref(0);
|
||||||
const lastScrollTop = ref(0);
|
const lastScrollTop = ref(0);
|
||||||
const totalLines = ref(0);
|
const totalLines = ref(0);
|
||||||
const stopReading = ref(false);
|
const stopReading = ref(false);
|
||||||
|
const totalPages = ref(0);
|
||||||
const visibleLogs = computed(() => {
|
const visibleLogs = computed(() => {
|
||||||
const safeStartIndex = Math.max(0, Math.min(startIndex.value, Math.max(0, logs.value.length - visibleCount.value)));
|
const safeStartIndex = Math.max(0, Math.min(startIndex.value, Math.max(0, logs.value.length - visibleCount.value)));
|
||||||
if (safeStartIndex !== startIndex.value) {
|
if (safeStartIndex !== startIndex.value) {
|
||||||
|
@ -191,10 +192,15 @@ const onScroll = async () => {
|
||||||
await getContent(true);
|
await getContent(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (scrollHeight - scrollTop - clientHeight <= 50 && !end.value) {
|
||||||
if (scrollHeight - scrollTop - clientHeight <= 50 && !end.value && readReq.page < maxPage.value) {
|
if (readReq.page < maxPage.value) {
|
||||||
readReq.page = maxPage.value;
|
readReq.page = maxPage.value;
|
||||||
await getContent(false);
|
await getContent(false);
|
||||||
|
} else if (readReq.page < totalPages.value) {
|
||||||
|
maxPage.value++;
|
||||||
|
readReq.page = maxPage.value;
|
||||||
|
await getContent(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -246,10 +252,6 @@ const getContent = async (pre: boolean) => {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
firstLoading.value = false;
|
firstLoading.value = false;
|
||||||
}
|
}
|
||||||
if (res.data.scope != 'tail' && !pre && res.data.end && res.data.totalLines == totalLines.value) {
|
|
||||||
isLoading.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
totalLines.value = res.data.totalLines;
|
totalLines.value = res.data.totalLines;
|
||||||
|
|
||||||
|
@ -336,6 +338,7 @@ const getContent = async (pre: boolean) => {
|
||||||
|
|
||||||
logCount.value = logs.value.length;
|
logCount.value = logs.value.length;
|
||||||
end.value = res.data.end;
|
end.value = res.data.end;
|
||||||
|
totalPages.value = res.data.total;
|
||||||
emit('update:hasContent', logs.value.length > 0);
|
emit('update:hasContent', logs.value.length > 0);
|
||||||
if (readReq.latest) {
|
if (readReq.latest) {
|
||||||
readReq.page = res.data.total;
|
readReq.page = res.data.total;
|
||||||
|
|
|
@ -133,8 +133,9 @@ const globalStore = GlobalStore();
|
||||||
const loading = ref();
|
const loading = ref();
|
||||||
const data = ref();
|
const data = ref();
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
|
cacheSizeKey: 'backup-account-size',
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: Number(localStorage.getItem('backup-account-size')) || 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
type: '',
|
type: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
|
Loading…
Add table
Reference in a new issue