Skip to main content

Strapi v4 到 Strapi 5 重大变化

¥Strapi v4 to Strapi 5 breaking changes

本页面列出了 Strapi 5 中引入的所有重大更改。重大更改分为与主题相关的类别,对于下表中的每一行,你将找到:

¥The present page lists all the breaking changes introduced in Strapi 5. Breaking changes are grouped into topic-related categories, and for each line in the following tables line you will find:

  • 重大更改的简短描述,

    ¥a short description of the breaking change,

  • 以及另外 2 列,"影响插件" 和 "由 codemods 处理",总结重大更改是否也会影响插件,以及重大更改是否由 升级 CLI 工具 中的 codemod 自动处理。

    ¥and 2 other columns, "Affects plugins" and "Handled by codemods", that sum up whether the breaking change also affects plugins and whether the breaking change is automatically handled by a codemod from the upgrade CLI tool.

你可以单击下表中任何重大更改的描述以跳转到包含更多详细信息的相应页面。

¥You can click on the description of any breaking change in the following tables to jump to the corresponding page with more details.

💡 提示
  • 要查看可用 codemods 的完整列表,请在终端中运行 npx @strapi/upgrade codemods ls 命令。

    ¥To view a full list of available codemods, run the npx @strapi/upgrade codemods ls command in your terminal.

  • 要深入了解 codemods 执行的代码,请转到 GitHub 存储库中的 codemods 列表

    ¥To have a deeper look at the code executed by the codemods, head over to the list of codemods in the GitHub repository.

数据库

¥Database

描述影响插件由 codemods 处理
内容类型始终具有功能列是的
不再支持 MySQL v5
长度超过 55 个字符的数据库标识符将自动缩短是的✅ 是的
SQLite 客户端仅支持 better-sqlite3✅ 是的
MySQL 客户端仅支持 mysql2✅ 是的

依赖

¥Dependencies

描述影响插件由 codemods 处理
CLI 默认包管理器不再是 yarn
Vite 是 Strapi 5 中的默认打包器是的
Strapi 5 使用 react-router-dom v6是的✅ 是的
Strapi 5 使用 koa-body v6是的
Strapi 5 中删除了 Webpack 别名是的
Apollo Server v3 升级到 Apollo Server v4是的

配置

¥Configuration

描述影响插件由 codemods 处理
某些 env 专用配置选项由服务器配置处理
配置文件名应满足严格要求
服务器日志级别为 http
模型配置路径使用 uid 而不是点符号是的👷 部分
webhooks.populateRelations 服务器配置已被删除是的
public 中间件中已删除 defaultIndex 选项
服务器代理配置选项分组在 server.proxy 对象下

Strapi 对象、方法、包和后端定制

¥Strapi objects, methods, packages, and back-end customization

描述影响插件由 codemods 处理
strapi.fetch uses the native fetch() API是的
strapi 工厂导入已更改是的👷 部分
Strapi 5 中已删除 isSupportedImage 方法是的
strapi-utils 已重构是的✅ 是的
核心服务方法使用文档服务 API是的
i18n 现在是 strapi 核心的一部分是的✅ 是的

插件、提供程序和管理面板自定义

¥Plugins, providers, and admin panel customization

描述影响插件由 codemods 处理
用户和权限 register.allowedFields 默认为 []✅ 是的
helper-plugin 已删除是的👷 部分
injectContentManagerComponent() 已被删除,取而代之的是 getPlugin('content-manager').injectComponent()是的
不支持某些 Mailgun 提供商旧变量是的
lockIcon 属性已由 licenseOnly 替换是的
ContentManagerAppState redux 已修改是的
EditViewLayoutListViewLayout 已重构是的
管理面板 RBAC redux 存储已更新是的
权限提供程序实例的 getWhere 方法已被删除是的

内容 API

¥Content API

描述影响插件由 codemods 处理
Strapi 5 具有一种新的扁平化 API 调用响应格式是的
REST API 输入在控制器中默认验证是的
GraphQL API 已更新是的
实体服务 API 已弃用,并由文档服务 API 取代是的👷 部分
在 API 调用中应使用 documentId 而不是 id是的👷 部分
根据文档服务 API 方法,数据库生命周期钩子的触发方式不同是的
publicationState 参数不受支持,已由 status 替换是的✅ 是的
按 id 排序不再可能按时间顺序排序是的✅ 是的
Document Service API 没有 findPage() 方法是的
Strapi 保留了一些属性和内容类型名称是的
在创建条目时上传文件不再可能是的
应使用详细填充策略填充组件和动态区域是的