下载优化
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)
|
createFloders(obj[i], arr, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
function downLoadFileConcurrency(obj, arr, callback) {
|
||||||
return new Promise(resolve => {
|
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 {
|
try {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback({
|
callback({
|
||||||
|
|
@ -50,22 +78,9 @@ function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
||||||
console.log("同步下载打包开始时间:" + new Date());
|
console.log("同步下载打包开始时间:" + new Date());
|
||||||
files = formatFiles(files)
|
files = formatFiles(files)
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
let all = []
|
// let all = []
|
||||||
files.forEach(file => {
|
let res = await downLoadFileConcurrency(obj, files, callback)
|
||||||
let res = getFile(file.url).then(r => {
|
if (res) {
|
||||||
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(() => {
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback({
|
callback({
|
||||||
type: 'downLoaded',
|
type: 'downLoaded',
|
||||||
|
|
@ -87,7 +102,7 @@ function zipFilesJsZip(zipName, files, obj = {}, callback) {
|
||||||
console.log("同步下载打包结束时间:" + new Date());
|
console.log("同步下载打包结束时间:" + new Date());
|
||||||
FileSaver.saveAs(res, zipName) // 利用file-saver保存文件
|
FileSaver.saveAs(res, zipName) // 利用file-saver保存文件
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,10 +215,10 @@
|
||||||
<downloadRecord :isSystem="true" v-if="RecordVisible" />
|
<downloadRecord :isSystem="true" v-if="RecordVisible" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog :title="$t('dialog:title:downLoadProgress')" :visible.sync="downloadVisible" width="30%"
|
<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'">
|
<div v-if="downloadType == 'downLoad' || downloadType == 'start'">
|
||||||
<span style="margin-bottom: 5px;">{{ $t('dialog:sattus:downLoading') }}</span>
|
<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>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<span>{{ $t('dialog:sattus:ziping') }}</span>
|
<span>{{ $t('dialog:sattus:ziping') }}</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue