From 8d5af331cdba656cef99939ff2580a2ad08397f9 Mon Sep 17 00:00:00 2001 From: pengyuanyuan003 Date: Mon, 28 Sep 2020 16:33:14 +0800 Subject: [PATCH] fix JsonEditor webWorker's bug --- client/src/components/JsonEditor/_utils.ts | 5 +++-- client/src/index.ts | 5 ++++- plugin/src/components/Field/components/JsonEditor/_utils.ts | 2 +- .../components/Field/components/TableEditor/interface.d.ts | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/src/components/JsonEditor/_utils.ts b/client/src/components/JsonEditor/_utils.ts index 8b39fe7..f492e66 100644 --- a/client/src/components/JsonEditor/_utils.ts +++ b/client/src/components/JsonEditor/_utils.ts @@ -1,4 +1,5 @@ -const publicPath = window.location.protocol + process.env.PUBLIC_URL +const publicPath = window.$$PUBLIC_URL + function getWorkerUrl(workerId: string, label: string) { switch (label) { case 'json': @@ -21,7 +22,7 @@ function getWorkerUrl(workerId: string, label: string) { if (process.env.NODE_ENV === 'production') { ;(window as any).MonacoEnvironment = { - getWorkerUrl: function(workerId: string, label: string) { + getWorkerUrl: function (workerId: string, label: string) { const url = getWorkerUrl(workerId, label) return `data:text/javascript;charset=utf-8,${encodeURIComponent(` self.MonacoEnvironment = { diff --git a/client/src/index.ts b/client/src/index.ts index 97e5c7a..723ced3 100755 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -22,7 +22,10 @@ import './index.less' import _history from './utils/history' // JsonEditor 组件配置 -window.$$PUBLIC_URL = window.location.protocol + process.env.PUBLIC_URL +window.$$PUBLIC_URL = + process.env.NODE_ENV === 'development' + ? window.location.origin + '/' + : window.location.protocol + process.env.PUBLIC_URL initGlobalResource() diff --git a/plugin/src/components/Field/components/JsonEditor/_utils.ts b/plugin/src/components/Field/components/JsonEditor/_utils.ts index c9be04c..89584c9 100644 --- a/plugin/src/components/Field/components/JsonEditor/_utils.ts +++ b/plugin/src/components/Field/components/JsonEditor/_utils.ts @@ -20,7 +20,7 @@ function getWorkerUrl(_workerId: string, label: string) { } } -if (process.env.NODE_ENV === 'production') { +if (publicPath) { ;(window as any).MonacoEnvironment = { getWorkerUrl: function(workerId: string, label: string) { const url = getWorkerUrl(workerId, label) diff --git a/plugin/src/components/Field/components/TableEditor/interface.d.ts b/plugin/src/components/Field/components/TableEditor/interface.d.ts index 52592f0..df94bcc 100644 --- a/plugin/src/components/Field/components/TableEditor/interface.d.ts +++ b/plugin/src/components/Field/components/TableEditor/interface.d.ts @@ -4,7 +4,7 @@ import { BaseProps, JsonSchema } from '~/types' * Table组件列配置 */ export interface TableColumn { - visible: boolean | ((text: any, row: any) => boolean) + visible?: boolean | ((text: any, row: any) => boolean) title: string dataIndex?: string fixed?: 'left' | 'right' | boolean