Browse Source

refactor: change common -> index

(cherry picked from commit eb6be0d9d13a0834b6a7ada9aab846cfbbdfd664)
20230320
MengYX 3 years ago
parent
commit
8260e744ca
No known key found for this signature in database GPG Key ID: E63F9C7303E8F604
  1. 4
      src/component/FileSelector.vue
  2. 2
      src/decrypt/index.ts
  3. 4
      src/utils/worker.ts

4
src/component/FileSelector.vue

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

2
src/decrypt/common.ts → src/decrypt/index.ts

@ -13,7 +13,7 @@ import { SplitFilename } from '@/decrypt/utils';
import { storage } from '@/utils/storage';
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.
if (storage instanceof InMemoryStorage) {
await storage.setAll(config);

4
src/utils/worker.ts

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

Loading…
Cancel
Save