Skip to main content

管理面板扩展

¥Admin panel extension

Strapi 的管理面板是一个基于 React 的单页应用,它封装了 Strapi 应用的所有功能和已安装的插件。如果 Strapi 提供的 自定义选项 不足以满足你的用例,你将需要扩展 Strapi 的管理面板。

¥Strapi's admin panel is a React-based single-page application that encapsulates all the features and installed plugins of a Strapi application. If the customization options provided by Strapi are not enough for your use case, you will need to extend Strapi's admin panel.

扩展 Strapi 的管理面板意味着利用其 React 基础根据项目的特定需求调整和增强界面和功能,这可能意味着创建新组件或添加新类型的字段。

¥Extending Strapi's admin panel means leveraging its React foundation to adapt and enhance the interface and features according to the specific needs of your project, which might imply creating new components or adding new types of fields.

在 2 个用例中,你可能需要扩展管理面板:

¥There are 2 use cases where you might want to extend the admin panel:

  • 作为 Strapi 插件开发者,你希望开发一个 Strapi 插件,每次安装在任何 Strapi 应用中时,都会扩展管理面板。

    ¥As a Strapi plugin developer, you want to develop a Strapi plugin that extends the admin panel everytime it's installed in any Strapi application.

    这可以通过利用 管理面板 API 插件 来完成。

    ¥ This can be done by taking advantage of the Admin Panel API for plugins.

  • 作为 Strapi 开发者,你希望为只需要扩展 Strapi 应用特定实例的 Strapi 用户开发独特的解决方案。

    ¥As a Strapi developer, you want to develop a unique solution for a Strapi user who only needs to extend a specific instance of a Strapi application.

    这可以通过直接更新 /src/admin/app.[tsx|js] 文件来完成,该文件可以导入位于 /src/admin/extensions 中的任何文件。

    ¥ This can be done by directly updating the /src/admin/app.[tsx|js] file, which can import any file located in /src/admin/extensions.

其他资源
提示:开发时的热重载

在 Strapi 5 中,服务器默认以 watch-admin 模式运行,因此只要你更改其代码,管理面板就会自动重新加载。这简化了管理面板和前端插件的开发。要禁用此功能,请运行 yarn develop --no-watch-admin(参见 CLI 参考)。

¥In Strapi 5, the server runs in watch-admin mode by default, so the admin panel auto-reloads whenever you change its code. This simplifies admin panel and front-end plugins development. To disable this, run yarn develop --no-watch-admin (see CLI reference).