From 51bb42c493a1cea4724b831f079983012c19641f Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:39:12 +0800 Subject: [PATCH] feat: Add download task button to view current ongoing download tasks (#7995) --- agent/app/api/v2/file.go | 4 +- agent/router/ro_file.go | 4 +- frontend/src/api/modules/files.ts | 4 +- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/ja.ts | 1 + frontend/src/lang/modules/ko.ts | 1 + frontend/src/lang/modules/ms.ts | 1 + frontend/src/lang/modules/pt-br.ts | 1 + frontend/src/lang/modules/ru.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../src/views/host/file-management/index.vue | 24 +++- .../host/file-management/process/index.vue | 119 ++++++++++++++---- 13 files changed, 125 insertions(+), 38 deletions(-) diff --git a/agent/app/api/v2/file.go b/agent/app/api/v2/file.go index a3d1c151e..e3d64b120 100644 --- a/agent/app/api/v2/file.go +++ b/agent/app/api/v2/file.go @@ -748,7 +748,7 @@ var wsUpgrade = websocket.Upgrader{ }, } -func (b *BaseApi) Ws(c *gin.Context) { +func (b *BaseApi) WgetProcess(c *gin.Context) { ws, err := wsUpgrade.Upgrade(c.Writer, c.Request, nil) if err != nil { return @@ -758,7 +758,7 @@ func (b *BaseApi) Ws(c *gin.Context) { go wsClient.Write() } -func (b *BaseApi) Keys(c *gin.Context) { +func (b *BaseApi) ProcessKeys(c *gin.Context) { res := &response.FileProcessKeys{} keys := global.CACHE.PrefixScanKey("file-wget-") res.Keys = keys diff --git a/agent/router/ro_file.go b/agent/router/ro_file.go index 2f5794703..8b6599c4c 100644 --- a/agent/router/ro_file.go +++ b/agent/router/ro_file.go @@ -33,8 +33,8 @@ func (f *FileRouter) InitRouter(Router *gin.RouterGroup) { fileRouter.GET("/download", baseApi.Download) fileRouter.POST("/chunkdownload", baseApi.DownloadChunkFiles) fileRouter.POST("/size", baseApi.Size) - fileRouter.GET("/ws", baseApi.Ws) - fileRouter.GET("/keys", baseApi.Keys) + fileRouter.GET("/wget/process", baseApi.WgetProcess) + fileRouter.GET("/wget/process/keys", baseApi.ProcessKeys) fileRouter.POST("/read", baseApi.ReadFileByLine) fileRouter.POST("/batch/role", baseApi.BatchChangeModeAndOwner) diff --git a/frontend/src/api/modules/files.ts b/frontend/src/api/modules/files.ts index 31f74d256..7f16a2ebc 100644 --- a/frontend/src/api/modules/files.ts +++ b/frontend/src/api/modules/files.ts @@ -85,8 +85,8 @@ export const computeDirSize = (params: File.DirSizeReq) => { return http.post('files/size', params, TimeoutEnum.T_5M); }; -export const fileKeys = () => { - return http.get('files/keys'); +export const fileWgetKeys = () => { + return http.get('files//wget/process/keys'); }; export const getRecycleList = (params: ReqPage) => { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 17255a35c..4e0f33195 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1392,6 +1392,7 @@ const message = { minimap: 'Code Mini Map', fileCanNotRead: 'File can not read', panelInstallDir: '1Panel installation directory cannot be deleted', + wgetTask: 'Download Task', }, ssh: { autoStart: 'Auto Start', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 0b06ccfde..30f403414 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -1334,6 +1334,7 @@ const message = { minimap: 'コードミニマップ', fileCanNotRead: 'ファイルは読み取れません', panelInstallDir: `1Panelインストールディレクトリは削除できません`, + wgetTask: 'ダウンロードタスク', }, ssh: { setting: '設定', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 8996281ae..efd3579b7 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -1320,6 +1320,7 @@ const message = { minimap: '코드 미니맵', fileCanNotRead: '파일을 읽을 수 없습니다.', panelInstallDir: `1Panel 설치 디렉터리는 삭제할 수 없습니다.`, + wgetTask: '다운로드 작업', }, ssh: { setting: '설정', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index bc748eab3..1d0211ecb 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -1377,6 +1377,7 @@ const message = { minimap: 'Peta mini kod', fileCanNotRead: 'Fail tidak dapat dibaca', panelInstallDir: 'Direktori pemasangan 1Panel tidak boleh dipadamkan', + wgetTask: 'Tugas Muat Turun', }, ssh: { setting: 'tetapan', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 91822ca82..e3cde982e 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -1362,6 +1362,7 @@ const message = { minimap: 'Mini mapa de código', fileCanNotRead: 'O arquivo não pode ser lido', panelInstallDir: 'O diretório de instalação do 1Panel não pode ser excluído', + wgetTask: 'Tarefa de Download', }, ssh: { setting: 'configuração', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index df1c68951..eb82a693e 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -1366,6 +1366,7 @@ const message = { minimap: 'Мини-карта кода', fileCanNotRead: 'Файл не может быть прочитан', panelInstallDir: 'Директорию установки 1Panel нельзя удалить', + wgetTask: 'Задача загрузки', }, ssh: { setting: 'настройка', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 5b1967861..9275b2473 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1344,6 +1344,7 @@ const message = { minimap: '縮略圖', fileCanNotRead: '此文件不支持預覽', panelInstallDir: '1Panel 安裝目錄不能删除', + wgetTask: '下載任務', }, ssh: { autoStart: '開機自啟', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 29ba22db9..ef87c170c 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1317,6 +1317,7 @@ const message = { minimap: '缩略图', fileCanNotRead: '此文件不支持预览', panelInstallDir: '1Panel 安装目录不能删除', + wgetTask: '下载任务', }, ssh: { autoStart: '开机自启', diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue index 2f8a5128a..4fcd3fca8 100644 --- a/frontend/src/views/host/file-management/index.vue +++ b/frontend/src/views/host/file-management/index.vue @@ -102,6 +102,12 @@ {{ $t('menu.terminal') }} + + + {{ $t('file.wgetTask') }} + + + {{ $t('file.paste') }}({{ fileMove.count }}) @@ -291,7 +297,7 @@ - + @@ -313,6 +319,7 @@ import { addFavorite, removeFavorite, searchFavorite, + fileWgetKeys, } from '@/api/modules/files'; import { computeSize, copyText, dateFormat, getFileType, getIcon, getRandomStr, downloadFile } from '@/utils/util'; import { File } from '@/api/interface/file'; @@ -386,7 +393,6 @@ const fileUpload = reactive({ path: '' }); const fileRename = reactive({ path: '', oldName: '' }); const fileWget = reactive({ path: '' }); const fileMove = reactive({ oldPaths: [''], type: '', path: '', name: '', count: 0 }); -const processPage = reactive({ open: false }); const createRef = ref(); const roleRef = ref(); @@ -411,6 +417,7 @@ const favorites = ref([]); const batchRoleRef = ref(); const dialogVscodeOpenRef = ref(); const previewRef = ref(); +const processRef = ref(); // editablePath const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchable(paths); @@ -754,11 +761,17 @@ const closeMovePage = (submit: Boolean) => { }; const openProcess = () => { - processPage.open = true; + processRef.value.acceptParams(); }; -const closeProcess = () => { - processPage.open = false; +const processCount = ref(0); +const getWgetProcess = async () => { + try { + const res = await fileWgetKeys(); + if (res.data && res.data.keys.length > 0) { + processCount.value = res.data.keys.length; + } + } catch (error) {} }; const openRename = (item: File.File) => { @@ -965,6 +978,7 @@ onMounted(() => { nextTick(function () { handlePath(); }); + getWgetProcess(); }); diff --git a/frontend/src/views/host/file-management/process/index.vue b/frontend/src/views/host/file-management/process/index.vue index b9fa3f02d..b5a4063e1 100644 --- a/frontend/src/views/host/file-management/process/index.vue +++ b/frontend/src/views/host/file-management/process/index.vue @@ -1,39 +1,68 @@ + +