Skip to main content

injectContentManagerComponent() 已删除

¥injectContentManagerComponent() removed

在 Strapi 5 中,injectContentManagerComponent 方法已被删除,因为内容管理器现在是一个插件。管理面板 API 方法被 getPlugin('content-manager').injectComponent() 取代。

¥In Strapi 5, the injectContentManagerComponent method is removed because the Content Manager is now a plugin. The Admin Panel API method is replaced by getPlugin('content-manager').injectComponent().

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 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 中

¥In Strapi v4

组件注入内容管理器如下:

¥A component is injected into the Content Manager as follows:

app.injectContentManagerComponent('editView', 'right-links', {
name: 'PreviewButton',
Component: () => (
<Button onClick={() => window.alert('Not here, The preview is.')}>Preview</Button>
),
});

在 Strapi 5 中

¥In Strapi 5

组件注入内容管理器如下:

¥A component is injected into the Content Manager as follows:

app.getPlugin('content-manager').injectComponent('editView', 'right-links', {
name: 'PreviewButton',
Component: () => (
<Button onClick={() => window.alert('Not here, The preview is.')}>Preview</Button>
),
});

迁移步骤

¥Migration steps

将你的插件 index.ts 文件从以下位置更改:

¥Change your plugin index.ts file from:

app.injectContentManagerComponent()

以下内容:

¥to the following:

app.getPlugin('content-manager').injectComponent()