From e76d1e018ef450029b25021eeace762df161fa02 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Sat, 7 Oct 2023 16:58:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A5=E5=BF=97=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9=20(#2440)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/logs.go | 19 ++++++++++++++++--- backend/app/service/ssh.go | 2 +- frontend/src/lang/modules/en.ts | 2 ++ frontend/src/lang/modules/tw.ts | 2 ++ frontend/src/lang/modules/zh.ts | 2 ++ .../src/views/container/image/prune/index.vue | 4 ++-- frontend/src/views/log/operation/index.vue | 2 ++ frontend/src/views/log/system/index.vue | 7 +++++-- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/backend/app/service/logs.go b/backend/app/service/logs.go index d212957a0..ab382a3e0 100644 --- a/backend/app/service/logs.go +++ b/backend/app/service/logs.go @@ -7,6 +7,7 @@ import ( "path/filepath" "sort" "strings" + "time" "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/model" @@ -50,8 +51,15 @@ func (u *LogService) ListSystemLogFile() ([]string, error) { if err != nil { return err } - if !info.IsDir() && (strings.HasSuffix(info.Name(), ".log") || strings.HasSuffix(info.Name(), ".log.gz")) { - files = append(files, strings.TrimSuffix(info.Name(), ".gz")) + if !info.IsDir() { + if info.Name() == "1Panel.log" { + files = append(files, time.Now().Format("2006-01-02")) + return nil + } + itemFileName := strings.TrimPrefix(info.Name(), "1Panel-") + itemFileName = strings.TrimSuffix(itemFileName, ".gz") + itemFileName = strings.TrimSuffix(itemFileName, ".log") + files = append(files, itemFileName) return nil } return nil @@ -113,6 +121,11 @@ func (u *LogService) PageOperationLog(req dto.SearchOpLogWithPage) (int64, inter } func (u *LogService) LoadSystemLog(name string) (string, error) { + if name == time.Now().Format("2006-01-02") { + name = "1Panel.log" + } else { + name = "1Panel-" + name + ".log" + } filePath := path.Join(global.CONF.System.DataDir, "log", name) if _, err := os.Stat(filePath); err != nil { fileGzPath := path.Join(global.CONF.System.DataDir, "log", name+".gz") @@ -120,7 +133,7 @@ func (u *LogService) LoadSystemLog(name string) (string, error) { return "", buserr.New("ErrHttpReqNotFound") } if err := handleGunzip(fileGzPath); err != nil { - return "", fmt.Errorf("handle ungzip file %s falied, err: %v", fileGzPath, err) + return "", fmt.Errorf("handle ungzip file %s failed, err: %v", fileGzPath, err) } } content, err := os.ReadFile(filePath) diff --git a/backend/app/service/ssh.go b/backend/app/service/ssh.go index cd1e5484c..cee2a2773 100644 --- a/backend/app/service/ssh.go +++ b/backend/app/service/ssh.go @@ -389,7 +389,7 @@ func sortFileList(fileNames []sshFileItem) []sshFileItem { return fileNames[i].Name > fileNames[j].Name }) itemFile = append(itemFile, fileNames[len(fileNames)-1]) - itemFile = append(itemFile, fileNames[:len(fileNames)-2]...) + itemFile = append(itemFile, fileNames[:len(fileNames)-1]...) return itemFile } sort.Slice(fileNames, func(i, j int) bool { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 7a8e7f63a..963a7405d 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -857,6 +857,8 @@ const message = { websites: 'Website', containers: 'Container', files: 'File Manage', + runtimes: 'Runtime', + process: 'Process', logs: 'Panel Logs', settings: 'Panel Setting', cronjobs: 'Cronjob', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 5526c240f..2bf1f67db 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -823,6 +823,8 @@ const message = { websites: '網站', containers: '容器', files: '文件管理', + runtimes: '運行環境', + process: '進程管理', logs: '日誌審計', settings: '面板設置', cronjobs: '計劃任務', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index c615505c6..aab8c0824 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -823,6 +823,8 @@ const message = { websites: '网站', containers: '容器', files: '文件管理', + runtimes: '运行环境', + process: '进程管理', logs: '日志审计', settings: '面板设置', cronjobs: '计划任务', diff --git a/frontend/src/views/container/image/prune/index.vue b/frontend/src/views/container/image/prune/index.vue index 183a9c526..b3ce995ec 100644 --- a/frontend/src/views/container/image/prune/index.vue +++ b/frontend/src/views/container/image/prune/index.vue @@ -17,14 +17,14 @@