Skip to content

Commit

Permalink
fix(monaca editor): 线上 worker 文件加载跨域报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xjq7 committed Oct 23, 2022
1 parent f834537 commit 0f31824
Show file tree
Hide file tree
Showing 3 changed files with 33,984 additions and 4 deletions.
8 changes: 8 additions & 0 deletions client/public/editor.worker.js

Large diffs are not rendered by default.

33,974 changes: 33,974 additions & 0 deletions client/public/ts.worker.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions client/src/userWorker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as monaco from 'monaco-editor';
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';

// @ts-ignore
self.MonacoEnvironment = {
getWorker(_: any, label: string) {
if (label === 'typescript' || label === 'javascript') {
return new tsWorker();
return new Worker(window.location.origin + '/ts.worker.js?worker');
}
return new editorWorker();
return new Worker(window.location.origin + '/editor.worker.js?worker');
},
};

Expand Down

0 comments on commit 0f31824

Please sign in to comment.