下载优化
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
927bb9c6be
commit
4bee20d1cd
|
|
@ -39,8 +39,36 @@ function createFloders(obj, arr, r) {
|
|||
createFloders(obj[i], arr, r)
|
||||
}
|
||||
}
|
||||
function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
||||
function downLoadFileConcurrency(obj, arr, callback) {
|
||||
return new Promise(resolve => {
|
||||
let list = arr.splice(0, 6)
|
||||
let all = []
|
||||
list.forEach(file => {
|
||||
let res = getFile(file.url).then(r => {
|
||||
const arr = file.name.split('/')
|
||||
createFloders(obj, arr, r)
|
||||
if (callback) {
|
||||
callback({
|
||||
type: 'downLoad',
|
||||
data: r
|
||||
})
|
||||
}
|
||||
// zip.file(fileName, r, { binary: true });
|
||||
})
|
||||
all.push(res)
|
||||
})
|
||||
Promise.all(all).then(async () => {
|
||||
if (arr.length <= 0) {
|
||||
resolve(true)
|
||||
} else {
|
||||
let res = await downLoadFileConcurrency(obj, arr, callback)
|
||||
resolve(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
||||
return new Promise(async resolve => {
|
||||
try {
|
||||
if (callback) {
|
||||
callback({
|
||||
|
|
@ -50,22 +78,9 @@ function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
|||
console.log("同步下载打包开始时间:" + new Date());
|
||||
files = formatFiles(files)
|
||||
const zip = new JSZip();
|
||||
let all = []
|
||||
files.forEach(file => {
|
||||
let res = getFile(file.url).then(r => {
|
||||
const arr = file.name.split('/')
|
||||
createFloders(obj, arr, r)
|
||||
if (callback) {
|
||||
callback({
|
||||
type: 'downLoad',
|
||||
data: r
|
||||
})
|
||||
}
|
||||
// zip.file(fileName, r, { binary: true });
|
||||
})
|
||||
all.push(res)
|
||||
})
|
||||
Promise.all(all).then(() => {
|
||||
// let all = []
|
||||
let res = await downLoadFileConcurrency(obj, files, callback)
|
||||
if (res) {
|
||||
if (callback) {
|
||||
callback({
|
||||
type: 'downLoaded',
|
||||
|
|
@ -87,7 +102,7 @@ function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
|||
console.log("同步下载打包结束时间:" + new Date());
|
||||
FileSaver.saveAs(res, zipName) // 利用file-saver保存文件
|
||||
})
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,10 +215,10 @@
|
|||
<downloadRecord :isSystem="true" v-if="RecordVisible" />
|
||||
</el-dialog>
|
||||
<el-dialog :title="$t('dialog:title:downLoadProgress')" :visible.sync="downloadVisible" width="30%"
|
||||
:before-close="handleClose">
|
||||
:close-on-click-modal="false" :close-on-press-escape="false" :before-close="handleClose">
|
||||
<div v-if="downloadType == 'downLoad' || downloadType == 'start'">
|
||||
<span style="margin-bottom: 5px;">{{ $t('dialog:sattus:downLoading') }}</span>
|
||||
<el-progress :percentage="percentage"></el-progress>
|
||||
<el-progress :percentage="percentage * 1"></el-progress>
|
||||
</div>
|
||||
<div v-else>
|
||||
<span>{{ $t('dialog:sattus:ziping') }}</span>
|
||||
|
|
|
|||
Loading…
Reference in New Issue