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();