Skip to main content

ContentManagerAppState redux 已修改

¥The ContentManagerAppState redux is modified

在 Strapi 5 中,内容管理器的 redux 存储已更改,并且删除了一些 redux 操作。值得注意的是,内容管理器的 useContentManagerInitData redux 状态已重构以删除 ModelsContext。用户可能依赖中间件或订阅者中的原始结构;这样做会破坏他们的应用。

¥In Strapi 5, the redux store for the Content Manager has been changed and some redux actions were removed. Notably, the useContentManagerInitData redux state for the Content Manager has been refactored to remove ModelsContext. Users might be relying on the original structure in a middleware or subscriber; doing so this will break their application.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

\🔌 此重大更改是否会影响插件?\
\🤖 此重大更改是否由 codemod 自动处理?\

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

redux 存储可以触发以下操作:

¥The redux store can fire the following actions:

  • 'ContentManager/App/RESET_INIT_DATA’

  • 'ContentManager/App/GET_INIT_DATA’

  • 'ContentManager/App/SET_INIT_DATA’

有效负载将属性嵌套在 data 对象内。例如,对于 SET_INIT_DATA 操作,有效负载具有以下格式:

¥The payload nests attributes inside the data object. For instance, for the SET_INIT_DATA action, the payload is of the following format:

  data: {
authorizedCollectionTypeLinks: ContentManagerAppState['collectionTypeLinks'];
authorizedSingleTypeLinks: ContentManagerAppState['singleTypeLinks'];
components: ContentManagerAppState['components'];
contentTypeSchemas: ContentManagerAppState['models'];
fieldSizes: ContentManagerAppState['fieldSizes'];
};

在 Strapi 5 中

¥In Strapi 5

redux 存储不再触发以下操作:

¥The redux store no longer fires the following actions:

  • 'ContentManager/App/RESET_INIT_DATA’

  • 'ContentManager/App/GET_INIT_DATA’

有效负载数据不再将属性嵌套在 data 对象中。例如,对于 SET_INIT_DATA 操作,有效负载具有以下格式:

¥The payload data does not nest attributes within a data object anymore. For instance, for the SET_INIT_DATA action, the payload is of the following format:

{
authorizedCollectionTypeLinks: ContentManagerAppState['collectionTypeLinks'];
authorizedSingleTypeLinks: ContentManagerAppState['singleTypeLinks'];
components: ContentManagerAppState['components'];
contentTypeSchemas: ContentManagerAppState['models'];
fieldSizes: ContentManagerAppState['fieldSizes'];
}

迁移

¥Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

¥This section regroups useful notes and procedures about the introduced breaking change.

手动程序

¥Manual procedure

Strapi 5 中的 redux 存储继续触发 'ContentManager/App/SET_INIT_DATA’,因此用户应该只在他们的中间件中监听此操作。

¥The redux store in Strapi 5 continues to fire 'ContentManager/App/SET_INIT_DATA’, so users should instead listen for this action in their middlewares only.

此外,可能需要根据新的有效负载格式调整自定义代码。

¥Additionally, adjustments to your custom code might need to be done based on the new payload format.