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) => { eventDataList.map((item) => {
field.parent.setPropValue(item.name, { field.parent.setPropValue(item.name, {
type: 'JSFunction', 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; return item;
}); });

View File

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

View File

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