Merge branch 'fix/ducheng-0911-bugs' into 'release/1.0.0'

fix:event-setter with params



See merge request !977021
This commit is contained in:
荣彬 2020-09-13 21:51:51 +08:00
commit 14baf5ba10
4 changed files with 25 additions and 15 deletions

View File

@ -215,7 +215,8 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
eventDataList.map((item) => {
field.parent.setPropValue(item.name, {
type: 'JSFunction',
value: `function(){ this.${item.relatedEventName}(${item.paramStr?item.paramStr:''}) }`,
// 需要传下入参
value: `function(){this.${item.relatedEventName}.apply(this,Array.prototype.slice.call(arguments).concat([${item.paramStr?item.paramStr:''}])) }`,
});
return item;
});

View File

@ -80,7 +80,6 @@ export default class EventBindDialog extends Component<PluginProps> {
const { editor, config } = this.props;
editor.on(`${config.pluginKey}.openDialog`, (bindEventName: String,setterName:String,paramStr:String) => {
console.log('paramStr:'+paramStr);
this.openDialog(bindEventName);
this.setState({
setterName,
paramStr
@ -96,6 +95,8 @@ export default class EventBindDialog extends Component<PluginProps> {
})
}
}
this.openDialog(bindEventName);
});
}

View File

@ -56,7 +56,8 @@ export default class SourceEditor extends Component<{
state = {
isFullScreen:false,
tabKey: TAB_KEY.JS_TAB,
isShowSaveBtn:true
isShowSaveBtn:true,
visiable:false
};
componentWillMount() {
@ -77,6 +78,9 @@ export default class SourceEditor extends Component<{
editor.on('skeleton.panel-dock.unactive',(pluginName,dock)=>{
if (pluginName == 'sourceEditor'){
this.saveSchema();
this.setState({
visiable:false
})
}
})
@ -142,6 +146,7 @@ export default class SourceEditor extends Component<{
jsCode,
css,
selectTab: TAB_KEY.JS_TAB,
visiable:true
});
};
@ -272,18 +277,21 @@ export default class SourceEditor extends Component<{
const {jsCode} = this.state;
const {editor} = this.props;
let functionMap = transfrom.code2Schema(jsCode);
let schema = editor.get('designer').project.getSchema();
//let oldSchemaStr = JSON.stringify(schema);
let newSchema = transfrom.setFunction2Schema(functionMap, schema);
if (newSchema!=''){
editor.get('designer').project.setSchema(newSchema);
successFlag && Message.success('保存成功')
}
if (functionMap!=null){
let schema = editor.get('designer').project.getSchema();
//let oldSchemaStr = JSON.stringify(schema);
let newSchema = transfrom.setFunction2Schema(functionMap, schema);
if (newSchema!=''){
editor.get('designer').project.setSchema(newSchema);
successFlag && Message.success('保存成功')
}
}
}
render() {
const { selectTab, jsCode, css ,isShowSaveBtn} = this.state;
const { selectTab, jsCode, css ,isShowSaveBtn,visiable} = this.state;
const tabs = [
{ tab: 'index.js', key: TAB_KEY.JS_TAB },
{ tab: 'style.css', key: TAB_KEY.CSS_TAB },
@ -298,7 +306,7 @@ export default class SourceEditor extends Component<{
))}
</Tab>
{ isShowSaveBtn && <div className="button-container"><Button type="primary" onClick={()=>this.saveSchema(successFlag)}></Button></div>}
{ visiable &&
<div style={{ height: '100%' }} className="editor-context-container">
<div id="jsEditorDom" className="editor-context" ref={this.editorJsRef}>
<MonacoEditor
@ -319,8 +327,7 @@ export default class SourceEditor extends Component<{
/>
</div>
</div>
}
{/* <div className="full-screen-container" onClick={this.fullScreen}>
<img src="https://gw.alicdn.com/tfs/TB1d7XqE1T2gK0jSZFvXXXnFXXa-200-200.png"></img>
</div> */}

View File

@ -23,7 +23,8 @@ const transfrom = {
A = eval('('+newCode + ')');
a = new A();
}catch(e){
return ''
console.log(e.message);
return null
}
let functionNameList = Object.getOwnPropertyNames(a.__proto__);