Skip to main content

ContentManagerAppState redux 已被修改

🌐 The ContentManagerAppState redux is modified

在 Strapi 5 中,内容管理器(Content Manager)的 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.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?No

重大变更描述

🌐 Breaking change description

在 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 中

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.