Optimize Loading

remotes/origin/HEAD
MengYX 5 years ago
parent f99e885d9f
commit cc8e818142
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604

@ -10,18 +10,17 @@
</el-image> </el-image>
</template> </template>
</el-table-column> </el-table-column>
<!--todo: Check sortable--> <el-table-column label="歌曲">
<el-table-column label="歌曲" sortable>
<template slot-scope="scope"> <template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.title }}</span> <span style="margin-left: 10px">{{ scope.row.title }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="歌手" sortable> <el-table-column label="歌手">
<template slot-scope="scope"> <template slot-scope="scope">
<p>{{ scope.row.artist }}</p> <p>{{ scope.row.artist }}</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="专辑" sortable> <el-table-column label="专辑">
<template slot-scope="scope"> <template slot-scope="scope">
<p>{{ scope.row.album }}</p> <p>{{ scope.row.album }}</p>
</template> </template>

@ -27,14 +27,19 @@
}, },
mounted() { mounted() {
if (document.location.host !== "" && process.env.NODE_ENV === 'production') { if (document.location.host !== "" && process.env.NODE_ENV === 'production') {
const worker = require("workerize-loader!../decrypt/common");
this.thread_num = navigator.hardwareConcurrency || 1; this.thread_num = navigator.hardwareConcurrency || 1;
for (let i = 0; i < this.thread_num; i++) { const worker = require("workerize-loader!../decrypt/common");
//todo: Optimize for first loading // noinspection JSValidateTypes,JSUnresolvedVariable
// noinspection JSValidateTypes,JSUnresolvedVariable this.workers.push(worker().CommonDecrypt);
this.workers.push(worker().CommonDecrypt); this.idle_workers.push(0);
this.idle_workers.push(i); // 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 { } else {
const dec = require('../decrypt/common'); const dec = require('../decrypt/common');
this.workers.push(dec.CommonDecrypt); this.workers.push(dec.CommonDecrypt);

Loading…
Cancel
Save