下载优化

main^2
wangxiaoshuang 2026-08-07 14:07:50 +08:00
parent 3cf1cf5f91
commit f47db19702
1 changed files with 20 additions and 22 deletions

View File

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