1
0
forked from um/web

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> </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>

View File

@ -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
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 // noinspection JSValidateTypes,JSUnresolvedVariable
this.workers.push(worker().CommonDecrypt); this.workers.push(worker().CommonDecrypt);
this.idle_workers.push(i); 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);