From f47db19702e7b519fcd9288f0636180018b6585e Mon Sep 17 00:00:00 2001 From: wangxiaoshuang <825034831@qq.com> Date: Fri, 7 Aug 2026 14:07:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/stream.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/utils/stream.js b/src/utils/stream.js index c8c80f8b..ae2b5f43 100644 --- a/src/utils/stream.js +++ b/src/utils/stream.js @@ -42,6 +42,11 @@ function zipFiles(zipName, files) { .pipeTo(zipFileOutputStream) .then(() => { console.log("同步下载打包结束时间:" + new Date()); + resolve(true) + }).catch(err => { + console.log(err); + resolve(false) + }).finally(() => { store.dispatch('trials/setUnLock', false) readableZipStream = null; zipFileOutputStream = null; @@ -51,20 +56,9 @@ function zipFiles(zipName, files) { }) Url = null } - resolve(true) - }).catch(err => { - console.log(err); - readableZipStream = null; - zipFileOutputStream = null; - if (Url && Url.length > 0) { - Url.forEach(url => { - URL.revokeObjectURL(url) - }) - Url = null - } - resolve(false) }); } else { + store.dispatch('trials/setUnLock', false) readableZipStream = null; zipFileOutputStream = null; if (Url && Url.length > 0) { @@ -91,13 +85,13 @@ async function updateFile(file, name) { // file = decodeUtf8(file); let res = await fetch(file); res.body.pipeTo(fileOutputStream).then(() => { - store.dispatch('trials/setUnLock', true) - fileOutputStream = null; resolve(true) }).catch(err => { console.log(err) - fileOutputStream = null; resolve(false) + }).finally(() => { + store.dispatch('trials/setUnLock', false) + fileOutputStream = null; }); } catch (err) { console.log(err) @@ -138,13 +132,17 @@ function downloadFileToUrl(url) { xhr.open('GET', url); xhr.responseType = 'arraybuffer'; xhr.onload = function () { - const arraybuffer = xhr.response; - let dataset = dcmjs.data.DicomMessage.readFile(arraybuffer) - let newDicomFile = dataset.write({ fragmentMultiframe: false, startOffset: false }) // fragmentMultiframe 原始数据是否进行分割 - const bufferArray = new Uint8Array(newDicomFile) - const blob = new Blob([bufferArray], { type: 'application/octet-stream' }) - const href = URL.createObjectURL(blob) - resolve(href) + try { + const arraybuffer = xhr.response; + let dataset = dcmjs.data.DicomMessage.readFile(arraybuffer) + let newDicomFile = dataset.write({ fragmentMultiframe: false, startOffset: false }) // fragmentMultiframe 原始数据是否进行分割 + const bufferArray = new Uint8Array(newDicomFile) + const blob = new Blob([bufferArray], { type: 'application/octet-stream' }) + const href = URL.createObjectURL(blob) + resolve(href) + } catch (err) { + reject(err); + } }; xhr.send(); })