|
|
@ -92,8 +92,11 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
// 严格模式 用于尾调用优化
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
const dec = require("./decrypt/common");
|
|
|
|
const worker = require("workerize-loader!./decrypt/common");
|
|
|
|
|
|
|
|
const dec = require('./decrypt/common');
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: 'app',
|
|
|
|
name: 'app',
|
|
|
|
components: {},
|
|
|
|
components: {},
|
|
|
@ -104,12 +107,38 @@
|
|
|
|
playing_url: "",
|
|
|
|
playing_url: "",
|
|
|
|
playing_auto: false,
|
|
|
|
playing_auto: false,
|
|
|
|
format: '2',
|
|
|
|
format: '2',
|
|
|
|
|
|
|
|
workCount: 0,
|
|
|
|
|
|
|
|
cacheQueue: [],
|
|
|
|
|
|
|
|
cacheQueueOption: {
|
|
|
|
|
|
|
|
push: (element) => {
|
|
|
|
|
|
|
|
this.cacheQueue.push(element);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
pop: () => {
|
|
|
|
|
|
|
|
return this.cacheQueue.shift();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
size: () => {
|
|
|
|
|
|
|
|
return this.cacheQueue.length;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
workers: [],
|
|
|
|
|
|
|
|
idle_workers: [],
|
|
|
|
|
|
|
|
thread_num: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.$nextTick(function () {
|
|
|
|
this.$nextTick(function () {
|
|
|
|
this.finishLoad();
|
|
|
|
this.finishLoad();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (document.location.host !== "") {
|
|
|
|
|
|
|
|
this.thread_num = Math.max(navigator.hardwareConcurrency, 1);
|
|
|
|
|
|
|
|
for (let i = 0; i < this.thread_num; i++) {
|
|
|
|
|
|
|
|
this.workers.push(worker().CommonDecrypt);
|
|
|
|
|
|
|
|
this.idle_workers.push(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.workers.push(dec.CommonDecrypt);
|
|
|
|
|
|
|
|
this.idle_workers.push(0)
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
finishLoad() {
|
|
|
|
finishLoad() {
|
|
|
@ -125,9 +154,25 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handleFile(file) {
|
|
|
|
handleFile(file) {
|
|
|
|
|
|
|
|
// 有空闲worker 立刻处理文件
|
|
|
|
(async () => {
|
|
|
|
if (this.idle_workers.length > 0) {
|
|
|
|
let data = await dec.CommonDecrypt(file);
|
|
|
|
this.handleDoFile(file, this.idle_workers.shift());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 无空闲worker 则放入缓存队列
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
this.cacheQueueOption.push(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
handleCacheQueue(worker_id) {
|
|
|
|
|
|
|
|
// 调用方法消费缓存队列中的数据
|
|
|
|
|
|
|
|
if (this.cacheQueue.length === 0) {
|
|
|
|
|
|
|
|
this.idle_workers.push(worker_id);
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.handleDoFile(this.cacheQueueOption.pop(), worker_id);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
handleDoFile(file, worker_id) {
|
|
|
|
|
|
|
|
this.workers[worker_id](file).then(data => {
|
|
|
|
if (data.status) {
|
|
|
|
if (data.status) {
|
|
|
|
this.tableData.push(data);
|
|
|
|
this.tableData.push(data);
|
|
|
|
this.$notify.success({
|
|
|
|
this.$notify.success({
|
|
|
@ -147,7 +192,13 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
window._paq.push(["trackEvent", "Error", data.message, file.name]);
|
|
|
|
window._paq.push(["trackEvent", "Error", data.message, file.name]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
// 完成之后 执行新任务 todo: 可能导致call stack过长
|
|
|
|
|
|
|
|
this.handleCacheQueue(worker_id);
|
|
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
|
|
console.error(err, file);
|
|
|
|
|
|
|
|
window._paq.push(["trackEvent", "Error", err, file.name]);
|
|
|
|
|
|
|
|
this.handleCacheQueue(worker_id);
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handlePlay(index, row) {
|
|
|
|
handlePlay(index, row) {
|
|
|
|
this.playing_url = row.file;
|
|
|
|
this.playing_url = row.file;
|
|
|
@ -224,6 +275,7 @@
|
|
|
|
font-size: small;
|
|
|
|
font-size: small;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*noinspection CssUnusedSymbol*/
|
|
|
|
.el-upload-dragger {
|
|
|
|
.el-upload-dragger {
|
|
|
|
width: 80vw !important;
|
|
|
|
width: 80vw !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|