From 2209a7206f3a5235b38d80bc060e3d3341704fdd Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 5 Sep 2025 15:43:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0PCAP=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=88=86=E6=89=B9=E4=B8=8B=E8=BD=BD,=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=B5=8F=E8=A7=88=E5=99=A8=E9=99=90=E5=88=B6=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E4=B8=8B=E8=BD=BD10=E4=B8=AA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/traceManage/pcap/index.vue | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/views/traceManage/pcap/index.vue b/src/views/traceManage/pcap/index.vue index 401cec43..00b4ba77 100644 --- a/src/views/traceManage/pcap/index.vue +++ b/src/views/traceManage/pcap/index.vue @@ -454,6 +454,9 @@ function fnDownPCAP(row?: Record) { const hide = message.loading(t('common.loading'), 0); Promise.allSettled(reqArr) .then(resArr => { + type successType = { data: Blob; filename: string }[]; + const successResults: successType = []; + resArr.forEach((res, idx) => { const title = fromArr[idx].title; const taskCode = fromArr[idx].taskCode; @@ -466,11 +469,14 @@ function fnDownPCAP(row?: Record) { duration: 3, }); // 文件名 + let filename = `${title}_${Date.now()}.zip`; if (taskCode.startsWith('/tmp')) { - saveAs(resV.data, `${title}_${Date.now()}.pcap`); - } else { - saveAs(resV.data, `${title}_${Date.now()}.zip`); + filename = `${title}_${Date.now()}.pcap`; } + successResults.push({ + data: resV.data, + filename: filename, + }); } else { message.warning({ content: `${resV.msg}`, @@ -484,6 +490,26 @@ function fnDownPCAP(row?: Record) { }); } }); + + // 分批下载函数,每批3个,间隔300ms + const batchDownload = async (results: successType) => { + const batchSize = 3; + const delay = 3_000; // 毫秒 + + for (let i = 0; i < results.length; i += batchSize) { + const batch = results.slice(i, i + batchSize); + + // 处理当前批次 + batch.forEach(item => { + saveAs(item.data, item.filename); + }); + + await new Promise(resolve => setTimeout(() => resolve(true), delay)); + } + }; + + // 开始分批下载 + batchDownload(successResults); }) .finally(() => { hide();