diff --git a/src/utils/plugins/webWorker.ts b/src/utils/plugins/webWorker.ts index 1263c62..5b15656 100644 --- a/src/utils/plugins/webWorker.ts +++ b/src/utils/plugins/webWorker.ts @@ -3,20 +3,22 @@ * @Date: 2022-03-06 13:53:30 * @Description: 计算密集型任务 * @LastEditors: ShawnPhang - * @LastEditTime: 2024-04-18 20:02:55 + * @LastEditTime: 2024-08-20 16:12:54 */ export default class WebWorker { private worker: Worker | undefined - constructor(name: string) { + constructor(useWorker: any) { if (typeof Worker === 'undefined') { console.error('Web Worker is not supported in this browser.') } else { - const file = name ? `../widgets/${name}.worker.ts` : null - file && - (this.worker = new Worker(new URL(file, import.meta.url), { - type: 'module', - })) + // 动态引入无法打包,必须是静态的 + // const file = name ? `../widgets/${name}.worker.ts` : null + // file && + // (this.worker = new Worker(new URL(file, import.meta.url), { + // type: 'module', + // })) + this.worker = new useWorker() } } public start(data?: any, cb?: Function) { diff --git a/src/utils/widgets/loadPSD.worker.ts b/src/utils/plugins/worker/loadPSD.worker.ts similarity index 100% rename from src/utils/widgets/loadPSD.worker.ts rename to src/utils/plugins/worker/loadPSD.worker.ts diff --git a/src/views/Psd.vue b/src/views/Psd.vue index 993c49a..34f3a2a 100644 --- a/src/views/Psd.vue +++ b/src/views/Psd.vue @@ -3,7 +3,7 @@ * @Date: 2022-01-10 14:57:53 * @Description: Psd文件解析 * @LastEditors: ShawnPhang - * @LastEditTime: 2024-08-18 21:06:05 + * @LastEditTime: 2024-08-20 16:14:18 -->