Optimize Loading

This commit is contained in:
MengYX 2020-02-11 16:35:45 +08:00
parent f99e885d9f
commit cc8e818142
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604
2 changed files with 15 additions and 11 deletions

View File

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

View File

@ -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);