Optimize Loading
This commit is contained in:
@@ -27,14 +27,19 @@
|
||||
},
|
||||
mounted() {
|
||||
if (document.location.host !== "" && process.env.NODE_ENV === 'production') {
|
||||
const worker = require("workerize-loader!../decrypt/common");
|
||||
this.thread_num = navigator.hardwareConcurrency || 1;
|
||||
for (let i = 0; i < this.thread_num; i++) {
|
||||
//todo: Optimize for first loading
|
||||
// noinspection JSValidateTypes,JSUnresolvedVariable
|
||||
this.workers.push(worker().CommonDecrypt);
|
||||
this.idle_workers.push(i);
|
||||
}
|
||||
const worker = require("workerize-loader!../decrypt/common");
|
||||
// noinspection JSValidateTypes,JSUnresolvedVariable
|
||||
this.workers.push(worker().CommonDecrypt);
|
||||
this.idle_workers.push(0);
|
||||
// delay to optimize for first loading
|
||||
setTimeout(() => {
|
||||
for (let i = 1; i < this.thread_num; i++) {
|
||||
// noinspection JSValidateTypes,JSUnresolvedVariable
|
||||
this.workers.push(worker().CommonDecrypt);
|
||||
this.idle_workers.push(i);
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
const dec = require('../decrypt/common');
|
||||
this.workers.push(dec.CommonDecrypt);
|
||||
|
Reference in New Issue
Block a user