feat: 优化日志加载 (#6593)

This commit is contained in:
zhengkunwang 2024-09-26 22:37:32 +08:00 committed by GitHub
parent cb6c58cb5d
commit 1d326afa93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
<template>
<div v-loading="isLoading">
<div v-loading="firstLoading">
<div v-if="defaultButton">
<el-checkbox border v-model="tailLog" class="float-left" @change="changeTail(false)">
{{ $t('commons.button.watch') }}
@ -78,6 +78,7 @@ const minPage = ref(1);
const maxPage = ref(1);
const logs = ref([]);
const isLoading = ref(false);
const firstLoading = ref(true);
const readReq = reactive({
id: 0,
@ -129,6 +130,7 @@ const getContent = (pre: boolean) => {
}
isLoading.value = true;
ReadByLine(readReq).then((res) => {
firstLoading.value = false;
if (!end.value && res.data.end) {
lastLogs.value = [...logs.value];
}
@ -193,7 +195,7 @@ const getContent = (pre: boolean) => {
maxPage.value = res.data.total;
minPage.value = res.data.total;
}
if (logs.value && logs.value.length > 3000) {
if (logs.value && logs.value.length > 1000) {
logs.value.splice(0, readReq.pageSize);
if (minPage.value > 1) {
minPage.value--;
@ -278,8 +280,6 @@ const init = () => {
}
readReq.latest = true;
search();
nextTick(() => {});
};
const clearLog = (): void => {