perf: optimization file component (#10178)

This commit is contained in:
CityFun 2025-08-28 18:50:53 +08:00 committed by GitHub
parent bc8d564ce8
commit a1311a2a0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 11 deletions

View file

@ -1045,7 +1045,7 @@ func copyData(task *task.Task, app model.App, appDetail model.AppDetail, appInst
return return
} }
envPath := path.Join(appDir, ".env") envPath := path.Join(appDir, ".env")
var envParams map[string]string envParams := make(map[string]string)
if fileOp.Stat(envPath) { if fileOp.Stat(envPath) {
envs, _ := gotenv.Read(envPath) envs, _ := gotenv.Read(envPath)
if envParams = maps.Clone(envs); envParams == nil { if envParams = maps.Clone(envs); envParams == nil {

View file

@ -178,11 +178,9 @@ const onScroll = async () => {
return; return;
} }
if (scrollHeight - scrollTop - clientHeight <= 50 && !end.value) { if (scrollHeight - scrollTop - clientHeight <= 50 && !end.value && maxPage.value > 1) {
if (readReq.page < maxPage.value) { readReq.page = maxPage.value;
readReq.page++; await getContent(false);
await getContent(false);
}
} }
}; };
@ -255,7 +253,7 @@ const getContent = async (pre: boolean) => {
}), }),
); );
const newLogs = res.data.lines; const newLogs = res.data.lines;
if (newLogs.length === readReq.pageSize && readReq.page < res.data.total) { if (tailLog.value && newLogs.length === readReq.pageSize && readReq.page < res.data.total) {
readReq.page++; readReq.page++;
} }
if ( if (
@ -274,17 +272,43 @@ const getContent = async (pre: boolean) => {
if (logs.value.length == 0) { if (logs.value.length == 0) {
logs.value = newLogs; logs.value = newLogs;
console.log('首次加载');
} else { } else {
if (end.value) { // if (end.value) {
logs.value = pre ? [...newLogs, ...lastLogs.value] : [...lastLogs.value, ...newLogs]; // console.log('');
// if (pre) {
// console.log('' + newLogs.length + '');
// } else {
// console.log('' + newLogs.length + '');
// }
// logs.value = pre ? [...newLogs, ...logs.value] : [...lastLogs.value, ...newLogs];
// } else {
// console.log('');
// if (pre) {
// console.log('' + newLogs.length + '');
// } else {
// console.log('' + newLogs.length + '');
// }
// logs.value = pre ? [...newLogs, ...logs.value] : [...lastLogs.value, ...newLogs];
// }
// pre
if (pre) {
logs.value = [...newLogs, ...logs.value];
} else { } else {
logs.value = pre ? [...newLogs, ...logs.value] : [...logs.value, ...newLogs]; if (end.value) {
console.log('lastLogs 拼接');
logs.value = [...lastLogs.value, ...newLogs];
} else {
logs.value = [...logs.value, ...newLogs];
}
} }
} }
console.log(logs.value.length);
nextTick(() => { nextTick(() => {
if (logContainer.value) { if (logContainer.value) {
if (pre) { if (pre) {
console.log(logs.value[0]);
if (readReq.page > 1) { if (readReq.page > 1) {
const addedLines = newLogs.length; const addedLines = newLogs.length;
const newScrollPosition = lastScrollTop.value + (addedLines * logHeight) / 3; const newScrollPosition = lastScrollTop.value + (addedLines * logHeight) / 3;
@ -302,6 +326,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;
console.log('end=' + end.value);
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;
@ -314,6 +339,7 @@ const getContent = async (pre: boolean) => {
} }
} }
if (logs.value && logs.value.length > 3000) { if (logs.value && logs.value.length > 3000) {
console.log('日志过长,进行裁剪');
if (pre) { if (pre) {
logs.value.splice(logs.value.length - readReq.pageSize, readReq.pageSize); logs.value.splice(logs.value.length - readReq.pageSize, readReq.pageSize);
if (maxPage.value > 1) { if (maxPage.value > 1) {