ContentManagerAppState redux 已修改

页面摘要: 在 Strapi 5 中,ContentManagerAppState redux store 移除了 RESET_INIT_DATA 和 GET_INIT_DATA action,并将 SET_INIT_DATA 的负载结构改为不再将属性嵌套在 data 对象中。

在 Strapi 5 中,内容管理器的 redux store 已更改,并移除了部分 redux action。值得注意的是,内容管理器的 useContentManagerInitData redux 状态已重构以移除 ModelsContext。用户可能在中间件或订阅者中依赖原始结构;这样做会导致他们的应用出错。

本页面是破坏性变更数据库的一部分,提供有关该破坏性变更的信息,以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

破坏性变更说明

在 Strapi v4 中

redux store 可以触发以下 action:

  • 'ContentManager/App/RESET_INIT_DATA’
  • 'ContentManager/App/GET_INIT_DATA’
  • 'ContentManager/App/SET_INIT_DATA’

负载将属性嵌套在 data 对象内。例如,对于 SET_INIT_DATA action,负载格式如下:

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

在 Strapi 5 中

redux store 不再触发以下 action:

  • 'ContentManager/App/RESET_INIT_DATA’
  • 'ContentManager/App/GET_INIT_DATA’

负载数据不再将属性嵌套在 data 对象中。例如,对于 SET_INIT_DATA action,负载格式如下:

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

迁移

本节汇总了关于该破坏性变更的有用说明和操作步骤。

手动操作步骤

Strapi 5 中的 redux store 仍会触发 'ContentManager/App/SET_INIT_DATA’,因此用户应改为仅在自己的中间件中监听此 action。

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