diff --git a/packages/nc-gui/components/dlg/QuickImport.vue b/packages/nc-gui/components/dlg/QuickImport.vue index 8b65e6eec3..182a5f347a 100644 --- a/packages/nc-gui/components/dlg/QuickImport.vue +++ b/packages/nc-gui/components/dlg/QuickImport.vue @@ -152,7 +152,9 @@ if (isWorkerSupport) { (val) => { if (val) { importWorker = initWorker(importWorkerUrl) - } else importWorker?.terminate() + } else { + importWorker?.terminate() + } }, { immediate: true }, ) diff --git a/packages/nc-gui/utils/workerUtils.ts b/packages/nc-gui/utils/workerUtils.ts index 7bedbe3824..c0620e946b 100644 --- a/packages/nc-gui/utils/workerUtils.ts +++ b/packages/nc-gui/utils/workerUtils.ts @@ -1,3 +1,5 @@ +import getCrossOriginWorkerURL from 'crossoriginworker' + // Returns a blob:// URL which points // to a javascript file which will call // importScripts with the given URL @@ -6,18 +8,20 @@ export function getWorkerURL(url: string) { return URL.createObjectURL(new Blob([content], { type: 'text/javascript' })) } -export function initWorker(url: string) { +export async function initWorker(url: string) { let worker: Worker | null = null try { - if (/^https?:\/\/'/.test(url)) { - const worker_url = getWorkerURL(url) - worker = new Worker(worker_url) - URL.revokeObjectURL(worker_url) - } else { - worker = new Worker(url, { - type: 'module', - }) - } + const workerURL = await getCrossOriginWorkerURL(url) + worker = new Worker(workerURL) + // if (/^https?:\/\/'/.test(url)) { + // // const worker_url = getWorkerURL(url) + // // worker = new Worker(worker_url) + // // URL.revokeObjectURL(worker_url) + // } else { + // worker = new Worker(url, { + // type: 'module', + // }) + // } } catch (e) { console.error(e) }