refactor: change common -> index

This commit is contained in:
MengYX 2022-01-09 10:22:00 +08:00
parent fcf0a764ef
commit 50fa60c983
3 changed files with 5 additions and 5 deletions

View File

@ -37,7 +37,7 @@
<script> <script>
import { spawn, Worker, Pool } from 'threads'; import { spawn, Worker, Pool } from 'threads';
import { CommonDecrypt } from '@/decrypt/common.ts'; import { Decrypt } from '@/decrypt';
import { DecryptQueue } from '@/utils/utils'; import { DecryptQueue } from '@/utils/utils';
import { storage } from '@/utils/storage'; import { storage } from '@/utils/storage';
@ -74,7 +74,7 @@ export default {
}, },
async addFile(file) { async addFile(file) {
this.task_all++; this.task_all++;
this.queue.queue(async (dec = CommonDecrypt) => { this.queue.queue(async (dec = Decrypt) => {
console.log('start handling', file.name); console.log('start handling', file.name);
try { try {
this.$emit('success', await dec(file, await storage.getAll())); this.$emit('success', await dec(file, await storage.getAll()));

View File

@ -11,7 +11,7 @@ import { SplitFilename } from '@/decrypt/utils';
import { storage } from '@/utils/storage'; import { storage } from '@/utils/storage';
import InMemoryStorage from '@/utils/storage/InMemoryStorage'; import InMemoryStorage from '@/utils/storage/InMemoryStorage';
export async function CommonDecrypt(file: FileInfo, config: Record<string, any>): Promise<DecryptResult> { export async function Decrypt(file: FileInfo, config: Record<string, any>): Promise<DecryptResult> {
// Worker thread will fallback to in-memory storage. // Worker thread will fallback to in-memory storage.
if (storage instanceof InMemoryStorage) { if (storage instanceof InMemoryStorage) {
await storage.setAll(config); await storage.setAll(config);

View File

@ -1,4 +1,4 @@
import { expose } from 'threads/worker'; import { expose } from 'threads/worker';
import { CommonDecrypt } from '@/decrypt/common'; import { Decrypt } from '@/decrypt';
expose(CommonDecrypt); expose(Decrypt);