Browse Source

Performance improvement in multiple files

20230320
1519715742@qq.com 5 years ago
parent
commit
92bd0f6be3
  1. 49
      src/App.vue

49
src/App.vue

@ -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({

Loading…
Cancel
Save