Skip to main content

内容历史

GrowthThis feature is available with a Growth plan. EnterpriseThis feature is available with an Enterprise plan. 5.0.0This feature requires Strapi version 5.0.0 or later.
Page summary:

内容历史记录存储以前的文档版本,方便编辑者在内容管理器中比较和恢复之前的状态。本文档说明了如何浏览和恢复工作流程,以便快速回滚错误。版本仅为在内容管理器中编辑的内容创建,在增长计划中保留 14 天,在企业计划中保留 30 天。

在 内容管理器中,内容历史记录功能使你能够浏览并恢复使用内容管理器创建的文档的先前版本。

IDENTITY CARD
计划
CMS 增长或企业计划
角色与权限
无
激活
默认情况下可用,如需计划
环境
在开发和生产环境中均可用

只有当文档通过管理面板中的 内容管理器被修改时,才会创建一个版本。通过其他方式修改的内容不会出现在文档的内容历史中:这包括 REST API、GraphQL API、文档服务 API、生命周期钩子、定时任务,以及 strapi import 和 strapi transfer 命令。

Note

内容历史并不是记录文档所做的每一次更改。通过程序生成的文档,比如迁移脚本创建的文档或调用 REST API 的集成创建的文档,是没有对应版本的,因此文档可能与内容历史中列出的最近版本不同。

🌐 Content History is not a record of every change made to a document. Documents written programmatically, such as those created by a migration script or an integration calling the REST API, have no corresponding version, and a document can therefore differ from the most recent version listed in its Content History.

要追踪管理员面板用户执行的操作,请使用 审计日志。

🌐 To trace the actions performed by users of the admin panel, use Audit Logs.

配置​

🌐 Configuration

唯一可以配置的就是版本在被删除前会保留多久。

🌐 The only configurable aspect is how long versions are kept before they are deleted.

内容历史不是永久存档。版本会自动删除:每天午夜有个任务运行,会删除所有超过保留期限的版本,期限从每个版本的创建日期开始计算。

🌐 Content History is not a permanent archive. Versions are deleted automatically: a job runs once a day, at midnight, and deletes every version older than the retention period, counted from the creation date of each version.

保留期限由你计划的许可证规定:

🌐 The retention period is defined by the license of your plan:

计划默认保留期最长保留期
CMS 增长14 天14 天
CMS 企业30 天90 天

在成长计划中,保留期无法延长。联系 Strapi sales team 升级到企业计划,企业计划默认提供30天,并且可以延长至最多90天。

Note

在引入14天默认期限时,那些已经使用30天保留期的增长项目仍然保持不变。

🌐 Growth projects that were already using a 30-day retention period when the 14-day default was introduced keep it.

Caution

被保留作业删除的版本无法从内容历史界面恢复。

🌐 Versions deleted by the retention job cannot be recovered from the Content History interface.

基于代码的配置​

🌐 Code-based configuration

保留期限可以通过 /config/admin 文件的 history.retentionDays 参数缩短,但绝不能延长。当许可证和配置文件都定义了一个值时,以两者中较低的为准。

🌐 The retention period can be shortened, but never extended, with the history.retentionDays parameter of the /config/admin file. When both the license and the configuration file define a value, the lower of the 2 applies.

/config/admin.js
module.exports = ({ env }) => ({
// … other configuration properties
history: {
retentionDays: 7,
},
});

在管理面板里没有对应的设置:保留期限只能从 /config/admin 文件里缩短。

🌐 There is no equivalent setting in the admin panel: the retention period can only be shortened from the /config/admin file.

使用​

🌐 Usage

使用此功能的路径: 内容管理器
在内容类型的编辑视图中:点击 (右上角)然后 内容历史.

浏览内容历史​

🌐 Browsing Content History

使用内容历史记录,你可以通过以下方式浏览内容:

🌐 With Content History, you can browse your content through:

  • 左侧的主视图列出了右侧侧边栏中所选版本的字段及其内容。
  • 右侧的侧边栏列出了可用版本的总数以及每个版本:
    • 创建版本的日期和时间,
    • 创建它的用户,
    • 以及其状态是草稿、已修改还是已发布(有关文档状态的更多信息,请参见 草稿与发布)。
Accessing the Content History of a documentAccessing the Content History of a document
Note

内容历史的主要视图清楚地说明了某个字段在内容类型的其他版本中是不存在的、已删除的还是已重命名的。对于所选版本未知的字段,将在其他字段下方以“未知字段”标题显示。

🌐 The main view of Content History clearly states whether a field was inexistent, deleted, or renamed in other versions of the content-type. Fields that are unknown for the selected version will be displayed under an Unknown fields heading below the other fields.

恢复先前的版本​

🌐 Restoring a previous version

你可以选择恢复文档的先前版本。恢复版本时,该版本的内容将覆盖当前草稿版本的内容。文档状态将变为“已修改”,然后你就可以随时发布该内容(参见发布草稿)。

🌐 You can choose to restore a previous version of a document. When restoring a version, the content of this version will override the content of the current draft version. The document switches to the Modified status and you will then be able to publish the content whenever you want (see Publishing a draft).

  1. 浏览内容历史记录并通过右侧的侧边栏选择一个版本。
  2. 点击 恢复 按钮。
  3. 在“确认”窗口中,点击恢复。
Note

如果为内容类型启用了国际化 (i18n) 功能,恢复具有唯一字段(即其内容在所有语言环境中相同的字段)的版本将会恢复该字段在所有语言环境中的内容。

🌐 If the Internationalization (i18n) feature is enabled for the content-type, restoring a version with a unique field (i.e. a field whose content is the same for all locales) will restore the content of this field for all locales.

Restoring version with Content HistoryRestoring version with Content History