修复 DiffEditor diffValue 显示 [Object object] 的问题 (#1050)

* Iframe 联动时导致 iframe 刷新问题

* src过期判断有问题

* iframe message事件监听器判断优化

* 修复 DiffEditor 显示 [Object object] 的问题
This commit is contained in:
RickCole 2020-11-10 15:43:42 +08:00 committed by GitHub
parent 8b36762b91
commit 0af075b3e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,11 @@
import React from 'react'; import React from 'react';
import {Renderer} from '../../factory'; import {Renderer} from '../../factory';
import {FormItem, FormControlProps, FormBaseControl} from './Item'; import {FormItem, FormControlProps, FormBaseControl} from './Item';
import {filter} from '../../utils/tpl';
import cx from 'classnames';
import LazyComponent from '../../components/LazyComponent'; import LazyComponent from '../../components/LazyComponent';
import debouce from 'lodash/debounce'; import {
import {isPureVariable} from '../../utils/tpl-builtin'; isPureVariable,
resolveVariableAndFilter
} from '../../utils/tpl-builtin';
import {SchemaTokenizeableString} from '../../Schema'; import {SchemaTokenizeableString} from '../../Schema';
import {autobind} from '../../utils/helper'; import {autobind} from '../../utils/helper';
@ -132,7 +132,10 @@ export class DiffEditor extends React.Component<DiffEditorProps, any> {
.getModel() .getModel()
.setValue( .setValue(
isPureVariable(diffValue as string) isPureVariable(diffValue as string)
? normalizeValue(filter(diffValue || '', data, '| raw'), language) ? normalizeValue(
resolveVariableAndFilter(diffValue || '', data, '| raw'),
language
)
: normalizeValue(diffValue, language) : normalizeValue(diffValue, language)
); );
} }
@ -183,7 +186,10 @@ export class DiffEditor extends React.Component<DiffEditorProps, any> {
this.editor.setModel({ this.editor.setModel({
original: this.monaco.editor.createModel( original: this.monaco.editor.createModel(
isPureVariable(diffValue as string) isPureVariable(diffValue as string)
? normalizeValue(filter(diffValue || '', data, '| raw'), language) ? normalizeValue(
resolveVariableAndFilter(diffValue || '', data, '| raw'),
language
)
: normalizeValue(diffValue, language), : normalizeValue(diffValue, language),
language language
), ),