feat: get layout config from legao-design

This commit is contained in:
wanying.jwy 2020-08-18 16:07:50 +08:00
parent d886abc48d
commit b9103a225b
4 changed files with 22 additions and 30 deletions

View File

@ -47,36 +47,12 @@ const pages = Object.assign(project, {
}
}
}
debugger;
project.load({
version: '1.0.0',
componentsMap: [],
componentsTree,
config: {
layout: {
componentName: 'MiniappTabNav',
props: {
logo: '',
name: '测试网站',
tabBars: {
items: [
{
name: "页面1",
pagePath: "home1",
icon: "https://pre-go.alibaba-inc.com/filehandle?fileName…8e9-ff58-4e7a-bd24-9e5c32244e14.png&type=download",
activeIcon: ""
},
{
activeIcon: "",
name: "页面2",
icon: "",
pagePath: "home2"
}
]
}
},
},
},
config: project.config
}, true);
},
addPage(data: OldPageData | RootSchema) {

View File

@ -10,6 +10,10 @@ Object.assign(project, {
setSchema(schema: any) {
this.schema = schema;
},
setConfig(config: any) {
this.set('config', config);
},
});
export default project;

View File

@ -120,7 +120,7 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
if (Component) {
return <Component props={props}>{children}</Component>;
}
if (componentName) {
if (componentName && rendererContainer.getComponent(componentName)) {
return createElement(
rendererContainer.getComponent(componentName),
{

View File

@ -95,10 +95,22 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
render() {
const { rendererContainer, children } = this.props;
const layout = rendererContainer.layout;
if (layout) {
const { Component, props } = layout;
return <Component props={props}>{children}</Component>;
const { Component, props, componentName } = layout;
if (Component) {
return <Component key='layout' props={props}>{children}</Component>;
}
if (componentName && rendererContainer.getComponent(componentName)) {
return createElement(
rendererContainer.getComponent(componentName),
{
...props,
rendererContainer,
key: 'layout',
},
[children],
);
}
}
return <Fragment>{children}</Fragment>;