Skip to content

Commit

Permalink
Merge pull request #8 from LianjiaTech/fix/JsonEditor
Browse files Browse the repository at this point in the history
fix JsonEditor webWorker's bug
  • Loading branch information
好爸爸 authored Sep 28, 2020
2 parents d314a1d + 8d5af33 commit 00a7f25
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions client/src/components/JsonEditor/_utils.ts
Original file line number Diff line number Diff line change
@@ -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':
Expand All @@ -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 = {
Expand Down
5 changes: 4 additions & 1 deletion client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00a7f25

Please sign in to comment.