event load schema

This commit is contained in:
zude.hzd 2020-07-16 20:41:23 +08:00
parent ddaf8b66ff
commit 096603cb45
2 changed files with 22 additions and 4 deletions

View File

@ -234,6 +234,7 @@ export default class SourceEditor extends Component<{
let functionMap = transfrom.code2Schema(newCode);
let schema = editor.get('designer').project.getSchema();
let newSchema = transfrom.setFunction2Schema(functionMap,schema);
editor.get('designer').project.load(newSchema);
};
render() {

View File

@ -40,15 +40,11 @@ const transfrom = {
}
})
console.log(JSON.stringify(a.state));
console.log(functionMap);
if (a.state){
functionMap.state = a.state
}
return functionMap;
},
@ -63,12 +59,33 @@ const transfrom = {
if (key == 'state'){
pageNode.state = functionMap[key];
}else{
// 判断是否属于lifeCycles节点
if (LIFECYCLES_FUNCTION_MAP.react.indexOf(key)>=0){
// 判断有没有lifecycles节点
if (!pageNode.lifeCycles){
pageNode.lifeCycles = {}
}else{
pageNode.lifeCycles[key] = {
"type": "JSFunction",
"value": functionMap[key],
}
}
}else{
// methods节点
if (!pageNode.methods){
pageNode.methods = {}
}else{
pageNode.methods[key] = {
"type": "JSFunction",
"value": functionMap[key],
}
}
}
}
}
return schema;
}
};