Performance improvement in multiple files

This commit is contained in:
1519715742@qq.com 2020-02-04 19:12:44 +08:00
parent 211b4e0206
commit 92bd0f6be3
1 changed files with 48 additions and 1 deletions

View File

@ -96,6 +96,19 @@
tableData: [],
playing_url: "",
playing_auto: false,
workCount: 0,
cacheQueue: [],
cacheQueueOption: {
push: (element) => {
this.cacheQueue.push(element);
},
pop: () => {
return this.cacheQueue.shift();
},
size: () => {
return this.cacheQueue.length;
}
},
}
},
mounted() {
@ -117,9 +130,43 @@
});
},
handleFile(file) {
//
if (file) {
console.log("workCount", this.workCount);
// 100
if (this.workCount < 100) {
//
this.workCount++;
// 100
this.handleDoFile(file);
}
// 100
else {
this.cacheQueueOption.push(file);
}
}
//
else {
this.workCount++;
this.handleDoFile(this.cacheQueueOption.pop());
}
},
handleCacheQueue() {
// 50
if (this.cacheQueueOption.size() > 0 && this.workCount < 50) {
this.handleFile(null);
console.log("size", this.cacheQueueOption.size(), this.workCount);
}
},
handleDoFile(file) {
(async () => {
let data = await dec.CommonDecrypt(file);
//
this.workCount--;
this.handleCacheQueue();
if (data.status) {
this.tableData.push(data);
this.$notify.success({