更好地组织 NGXS 状态

问题描述

我有一个相当复杂的状态(这里是认部分,看看它是如何嵌套的),而且我的操作数量非常大,所以文件大约有 500 loc。不确定更好地组织它的最佳实践是什么。不确定使用子状态(如果可能的话)是否会让事情变得更好。

name: 'exhibition',defaults: {
    loading: false,editable: false,selectedPage: 1,selectedLanguage: 'Language',selectedSection: 0,id: 0,title: 'Some title',thumbnail: 'assets/images/thumbnail/placeholder-thumbnail.png',create_date: new Date(),note: 'Note',published: false,pages: [
        {
            introductory: false,background_color: '#fae7cc',page_number: 1,row_number: 20,column_number: 20,language: 'Language',sections: [
                {
                    section_order: 1,x_coordinate: 1,y_coordinate: 1,width: 20,height: 20,content: {
                        text_content: '<p>insert in some text</p>',content_type: 'text',file: {
                            name: '',file: '',file_type: ''
                        }
                    }
                }
            ]
        }
    ]
}

解决方法

您可能需要考虑使用 composition

并排创建商店