From dc86cbc1eed84bd94b1d9a78e9428c23a1643cc1 Mon Sep 17 00:00:00 2001
From: ssongliu <73214554+ssongliu@users.noreply.github.com>
Date: Thu, 28 Sep 2023 17:16:19 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BC=93=E5=AD=98=E6=B8=85=E7=90=86?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E4=B8=8B=E8=BD=BD=E6=A3=80?=
=?UTF-8?q?=E6=9F=A5=E9=A1=B9=20(#2415)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/service/setting_clean.go | 85 +++-
frontend/src/lang/modules/en.ts | 11 +-
frontend/src/lang/modules/tw.ts | 10 +-
frontend/src/lang/modules/zh.ts | 11 +-
.../src/views/setting/panel/clean/index.vue | 444 +++++++++---------
frontend/src/views/setting/panel/index.vue | 37 +-
6 files changed, 339 insertions(+), 259 deletions(-)
diff --git a/backend/app/service/setting_clean.go b/backend/app/service/setting_clean.go
index 6abddb06c..0a402109a 100644
--- a/backend/app/service/setting_clean.go
+++ b/backend/app/service/setting_clean.go
@@ -88,12 +88,10 @@ func (u *SettingService) SystemScan() dto.CleanData {
})
SystemClean.SystemClean = treeData
- uploadPath := path.Join(global.CONF.System.BaseDir, "1panel/uploads")
- uploadTreeData := loadTreeWithAllFile(true, uploadPath, "upload", uploadPath, fileOp)
+ uploadTreeData := loadUploadTree(fileOp)
SystemClean.UploadClean = append(SystemClean.UploadClean, uploadTreeData...)
- downloadPath := path.Join(global.CONF.System.BaseDir, "1panel/download")
- downloadTreeData := loadTreeWithAllFile(true, downloadPath, "download", downloadPath, fileOp)
+ downloadTreeData := loadDownloadTree(fileOp)
SystemClean.DownloadClean = append(SystemClean.DownloadClean, downloadTreeData...)
logTree := loadLogTree(fileOp)
@@ -153,8 +151,24 @@ func (u *SettingService) SystemClean(req []dto.Clean) {
case "upload":
dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/uploads", item.Name))
+ case "upload_app":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/uploads/app", item.Name))
+ case "upload_database":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/uploads/database", item.Name))
+ case "upload_website":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/uploads/website", item.Name))
+ case "upload_directory":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/uploads/directory", item.Name))
case "download":
- dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/download", item.Name))
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/downloads", item.Name))
+ case "download_app":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/downloads/app", item.Name))
+ case "download_database":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/downloads/database", item.Name))
+ case "download_website":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/downloads/website", item.Name))
+ case "download_directory":
+ dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/downloads/directory", item.Name))
case "system_log":
if len(item.Name) == 0 {
@@ -248,6 +262,64 @@ func loadUnusedFile(fileOp fileUtils.FileOp) []dto.CleanTree {
return treeData
}
+func loadUploadTree(fileOp fileUtils.FileOp) []dto.CleanTree {
+ var treeData []dto.CleanTree
+ path1 := path.Join(global.CONF.System.BaseDir, "1panel/upload/app")
+ list1 := loadTreeWithAllFile(true, path1, "upload_app", path1, fileOp)
+ size1, _ := fileOp.GetDirSize(path1)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_app", Size: uint64(size1), Children: list1, Type: "upload_app", IsRecommend: true})
+
+ path2 := path.Join(global.CONF.System.BaseDir, "1panel/upload/website")
+ list2 := loadTreeWithAllFile(true, path2, "upload_website", path2, fileOp)
+ size2, _ := fileOp.GetDirSize(path2)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_website", Size: uint64(size2), Children: list2, Type: "upload_website", IsRecommend: true})
+
+ path3 := path.Join(global.CONF.System.BaseDir, "1panel/upload/database")
+ list3 := loadTreeWithAllFile(true, path3, "upload_app", path3, fileOp)
+ size3, _ := fileOp.GetDirSize(path3)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_database", Size: uint64(size3), Children: list3, Type: "upload_database", IsRecommend: true})
+
+ path4 := path.Join(global.CONF.System.BaseDir, "1panel/upload/directory")
+ list4 := loadTreeWithAllFile(true, path4, "upload_app", path4, fileOp)
+ size4, _ := fileOp.GetDirSize(path4)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_directory", Size: uint64(size4), Children: list4, Type: "upload_directory", IsRecommend: true})
+
+ path5 := path.Join(global.CONF.System.BaseDir, "1panel/uploads")
+ uploadTreeData := loadTreeWithAllFile(true, path5, "upload", path5, fileOp)
+ treeData = append(treeData, uploadTreeData...)
+
+ return treeData
+}
+
+func loadDownloadTree(fileOp fileUtils.FileOp) []dto.CleanTree {
+ var treeData []dto.CleanTree
+ path1 := path.Join(global.CONF.System.BaseDir, "1panel/download/app")
+ list1 := loadTreeWithAllFile(true, path1, "download_app", path1, fileOp)
+ size1, _ := fileOp.GetDirSize(path1)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_app", Size: uint64(size1), Children: list1, Type: "download_app", IsRecommend: true})
+
+ path2 := path.Join(global.CONF.System.BaseDir, "1panel/download/website")
+ list2 := loadTreeWithAllFile(true, path2, "download_website", path2, fileOp)
+ size2, _ := fileOp.GetDirSize(path2)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_website", Size: uint64(size2), Children: list2, Type: "download_website", IsRecommend: true})
+
+ path3 := path.Join(global.CONF.System.BaseDir, "1panel/download/database")
+ list3 := loadTreeWithAllFile(true, path3, "download_app", path3, fileOp)
+ size3, _ := fileOp.GetDirSize(path3)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_database", Size: uint64(size3), Children: list3, Type: "download_database", IsRecommend: true})
+
+ path4 := path.Join(global.CONF.System.BaseDir, "1panel/download/directory")
+ list4 := loadTreeWithAllFile(true, path4, "download_app", path4, fileOp)
+ size4, _ := fileOp.GetDirSize(path4)
+ treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_directory", Size: uint64(size4), Children: list4, Type: "download_directory", IsRecommend: true})
+
+ path5 := path.Join(global.CONF.System.BaseDir, "1panel/download")
+ uploadTreeData := loadTreeWithAllFile(true, path5, "download", path5, fileOp)
+ treeData = append(treeData, uploadTreeData...)
+
+ return treeData
+}
+
func loadLogTree(fileOp fileUtils.FileOp) []dto.CleanTree {
var treeData []dto.CleanTree
path1 := path.Join(global.CONF.System.BaseDir, "1panel/log")
@@ -318,6 +390,9 @@ func loadTreeWithAllFile(isCheck bool, originalPath, treeType, pathItem string,
if treeType == "system_log" && file.Name() == "1Panel.log" {
continue
}
+ if (treeType == "upload" || treeType == "download") && file.IsDir() && (file.Name() == "app" || file.Name() == "database" || file.Name() == "website" || file.Name() == "directory") {
+ continue
+ }
size := uint64(0)
name := strings.TrimPrefix(path.Join(pathItem, file.Name()), originalPath+"/")
if file.IsDir() {
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 1c37e5e05..932959bc2 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -1038,6 +1038,7 @@ const message = {
newPassword: 'New password',
retryPassword: 'Confirm password',
duplicatePassword: 'The new password cannot be the same as the original password, please re-enter!',
+ diskClean: 'Cache Clean',
thirdParty: 'Third-party account',
createBackupAccount: 'Add {0}',
@@ -1224,7 +1225,7 @@ const message = {
system: 'System Junk',
systemHelper:
- 'Scan system junk (specifically includes temporary files generated during snapshots, upgrades, and obsolete file contents during version iterations)',
+ 'Temporary files generated during snapshots, upgrades, and obsolete file contents during version iterations',
panelOriginal: 'System snapshot recovery backup files',
upgrade: 'System upgrade backup files',
cache: 'System cache files',
@@ -1237,11 +1238,9 @@ const message = {
oldAppsBak: 'Unused application backup directories',
upload: 'Temporary upload files',
- uploadHelper:
- 'Scan temporary upload directory (specifically includes temporary files uploaded from the system backup list)',
+ uploadHelper: 'Temporary files uploaded from the system backup list',
download: 'Temporary Download Files',
- downloadHelper:
- 'Scan temporary download directory (specifically includes temporary files downloaded from third-party backup accounts by the system)',
+ downloadHelper: 'Temporary files downloaded from third-party backup accounts by the system',
website: 'Website',
app: 'Application',
database: 'Database',
@@ -1249,7 +1248,7 @@ const message = {
systemLog: 'System Log Files',
systemLogHelper:
- 'Scan system junk (specifically includes system log information, container build or image pull log information, and log files generated in scheduled tasks)',
+ 'System log information, container build or image pull log information, and log files generated in scheduled tasks',
dockerLog: 'Container operation log files',
taskLog: 'Scheduled task execution log files',
shell: 'Shell script scheduled tasks',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index 5f4e43e58..268e91094 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -995,6 +995,7 @@ const message = {
newPassword: '新密碼',
retryPassword: '確認密碼',
duplicatePassword: '新密碼不能與原始密碼一致,請重新輸入!',
+ diskClean: '缓存清理',
thirdParty: '第三方賬號',
createBackupAccount: '添加 {0}',
@@ -1162,7 +1163,7 @@ const message = {
selectScan: '已選中垃圾文件共計: ',
system: '系統垃圾',
- systemHelper: '掃描系統垃圾(具體包括:快照、升級等過程中產生的臨時文件以及版本叠代過程中廢棄的文件內容)',
+ systemHelper: '快照、升級等過程中產生的臨時文件以及版本叠代過程中廢棄的文件內容',
panelOriginal: '系統快照恢復前備份文件',
upgrade: '系統升級備份文件',
cache: '系統緩存文件',
@@ -1175,17 +1176,16 @@ const message = {
oldAppsBak: '廢棄應用備份目錄',
upload: '臨時上傳文件',
- uploadHelper: '掃描臨時上傳目錄(具體包括:系統上傳備份列表中上傳的臨時文件)',
+ uploadHelper: '系統上傳備份列表中上傳的臨時文件',
download: '臨時下載文件',
- downloadHelper: '掃描臨時下載目錄(具體包括:系統從第三方備份賬號下載的臨時文件)',
+ downloadHelper: '系統從第三方備份賬號下載的臨時文件',
website: '網站',
app: '應用',
database: '數據庫',
directory: '應用',
systemLog: '系統日誌文件',
- systemLogHelper:
- '掃描系統垃圾(具體包括:系統日誌信息、容器構建或鏡像拉取等日誌信息以及計劃任務中產生的日誌文件)',
+ systemLogHelper: '系統日誌信息、容器構建或鏡像拉取等日誌信息以及計劃任務中產生的日誌文件',
dockerLog: '容器操作日誌文件',
taskLog: '計劃任務執行日誌文件',
shell: 'Shell 腳本計劃任務',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 2550803fb..e31c06179 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -995,7 +995,7 @@ const message = {
newPassword: '新密码',
retryPassword: '确认密码',
duplicatePassword: '新密码不能与原始密码一致,请重新输入!',
- diskClean: '磁盘清理',
+ diskClean: '缓存清理',
thirdParty: '第三方账号',
createBackupAccount: '添加 {0}',
@@ -1162,7 +1162,7 @@ const message = {
selectScan: '已选中垃圾文件共计: ',
system: '系统垃圾',
- systemHelper: '扫描系统垃圾(具体包括:快照、升级等过程中产生的临时文件以及版本迭代过程中废弃的文件内容)',
+ systemHelper: '快照、升级等过程中产生的临时文件以及版本迭代过程中废弃的文件内容',
panelOriginal: '系统快照恢复前备份文件',
upgrade: '系统升级备份文件',
cache: '系统缓存文件',
@@ -1175,17 +1175,16 @@ const message = {
oldAppsBak: '废弃应用备份目录',
upload: '临时上传文件',
- uploadHelper: '扫描临时上传目录(具体包括:系统上传备份列表中上传的临时文件)',
+ uploadHelper: '系统上传备份列表中上传的临时文件',
download: '临时下载文件',
- downloadHelper: '扫描临时下载目录(具体包括:系统从第三方备份账号下载的临时文件)',
+ downloadHelper: '系统从第三方备份账号下载的临时文件',
website: '网站',
app: '应用',
database: '数据库',
directory: '应用',
systemLog: '系统日志文件',
- systemLogHelper:
- '扫描系统垃圾(具体包括:系统日志信息、容器构建或镜像拉取等日志信息以及计划任务中产生的日志文件)',
+ systemLogHelper: '系统日志信息、容器构建或镜像拉取等日志信息以及计划任务中产生的日志文件',
dockerLog: '容器操作日志文件',
taskLog: '计划任务执行日志文件',
shell: 'Shell 脚本计划任务',
diff --git a/frontend/src/views/setting/panel/clean/index.vue b/frontend/src/views/setting/panel/clean/index.vue
index b2023675a..b4b05876d 100644
--- a/frontend/src/views/setting/panel/clean/index.vue
+++ b/frontend/src/views/setting/panel/clean/index.vue
@@ -5,223 +5,225 @@