Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

区块配置会出现无限嵌套,结构太深的情况 #81

Open
w3cmark opened this issue Dec 22, 2019 · 0 comments
Open

区块配置会出现无限嵌套,结构太深的情况 #81

w3cmark opened this issue Dec 22, 2019 · 0 comments
Milestone

Comments

@w3cmark
Copy link
Contributor

w3cmark commented Dec 22, 2019

目前的配置:

const config = {
    resources: {
        res1: {
            api: {}
            fields: {}
        },
        res2: {
            api: {}
            fields: {}
        },
        ...
    },
    blocks: {
        block1: {
            type: 'form',
            resource: 'res1',
            blocks: {
                block1_1: {
                    type: 'component',
                    blocks: {
                        ...
                    }
                }
            }
        },
        block2: {
            type: 'list',
            resource: 'res2',
            blocks: {
                block1_1: {
                    type: 'component',
                    blocks: {
                        ...
                    }
                }
            }
        }
    }
}

还有个问题,像上面写配置的方式,无法实现block的复用(比如上面的block1_1),只能通过抽出来用变量保存,然后再复用。这样就离纯json配置的目标又远一步了。

AMS框架拿到用户配置时,会在内部做拉平处理。

解决方案:

新增resource类型,资源和区块声明级别拉平,增加支持通过base: 'blockname'来继承已有区块,增加布局描述字段

尽量避免使用blocks来嵌套子区块(除非使用插槽)

const config = {
    res1: {
        type: 'resource',
        api: {},
        fields: {}
    },
    res2: {
        type: 'resource',
        api: {},
        fields: {}
    },
    block0: {
        type: 'component',
        ...
    },
    block1_1: {
        base: 'block0',
        type: 'component',
        ...
    },
    block1: {
        type: 'form',
        resource: 'res1',
        ...
    },
    block2: {
        type: 'list',
        resource: 'res2',
        ...
    },
    layout: [ // 布局结构描述
        {
            block1: [
                'block1_1',
                'block1_2'
            ]
        },
        {
            block2: [
                {
                    'block2_1': [
                        'block2_1_1',
                        'block2_1_2'
                    ]
                },
                'block2_2'
            ]
        }
    ]
}

还需要解决的问题:

  1. 如何避免死循环嵌套的问题
  2. 当block多的时候如何定位(通过增加布局描述解决)
@w3cmark w3cmark added this to the v1.0 milestone Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant