Skip to main content

草稿与发布

🌐 Draft & Publish

Page summary:

草稿与发布将草稿与已发布条目分开,让编辑可以在发布前进行内容准备。本文档展示了如何按内容类型启用该功能,以及如何管理发布或取消发布操作。

草稿和发布功能允许管理内容的草稿。

🌐 The Draft & Publish feature allows to manage drafts for your content.

IDENTITY CARD
计划
免费功能
角色与权限
激活
可用但默认禁用
环境
在开发和生产环境中均可用

配置

🌐 Configuration

配置此功能的路径: 内容类型构建器

要在内容管理器中使用草稿与发布管理你的内容类型,必须通过内容类型构建器启用该功能。草稿与发布可以为每个内容类型进行配置。

🌐 For your content types to be managed with Draft & Publish in the Content Manager, the feature must be enabled through the Content-type Builder. Draft & Publish can be configured for each content type.

  1. 编辑已创建的任意内容类型,或创建新的内容类型(更多信息请参见 Content Type Builder 文档)。
  2. 转到高级设置选项卡。
  3. 勾选草稿和发布选项。
  4. 点击 完成 按钮。
Content-type Builder's advanced settingsContent-type Builder's advanced settings

记录首次发布日期 experimental_firstPublishedAtThis feature requires the experimental_firstPublishedAt feature flag to be enabled.

🌐 Recording the first publication date experimental_firstPublishedAtThis feature requires the experimental_firstPublishedAt feature flag to be enabled.

当启用此未来功能标志时(参见 功能配置),Strapi 会自动向所有使用草稿与发布的内容类型添加一个 firstPublishedAt 属性。该属性会保存条目首次发布的日期和时间,即使条目被取消发布然后再次发布,该属性也不会更改。

🌐 When this future flag is enabled (see features configuration), Strapi automatically adds a firstPublishedAt attribute to all content-types that use Draft & Publish. The attribute saves the date and time when an entry is first published and never changes even if the entry is unpublished and published again.

Caution

如果功能标志随后被禁用,firstPublishedAt 属性及其存储的值将被移除。

🌐 If the feature flag is disabled later, the firstPublishedAt attribute and its stored values are removed.

使用

🌐 Usage

启用草稿与发布后,内容管理员的编辑视图 会在界面顶部显示你的内容类型条目的当前状态。你的内容可以有三种状态:

🌐 With Draft & Publish enabled, the Content Manager's edit view indicates the current status of your content type's entry at the top of the interface. Your content can have 3 statuses:

  • 已发布:内容已先前发布。没有保存的未完成草稿更改。
  • 已修改:内容之前已经发布。你对草稿版本进行了一些修改并保存了这些更改,但这些更改尚未发布。
  • 草稿:内容尚未发布。

当启用草稿与发布时,在 内容管理器 列表视图中,你可以使用 筛选器 按状态筛选条目。

🌐 When Draft & Publish is eanbled, in the Content Manager list view, you can filter entries by status using the Filters button.

处理草稿

🌐 Working with drafts

路径: 内容管理员,编辑你的内容类型视图

在编辑文档时,你可以看到 2 个选项卡:

🌐 While editing a document, you can see 2 tabs:

  • 草稿 标签是你可以编辑内容的地方。
  • 已发布 选项卡是只读选项卡,所有字段的编辑都被禁用。已发布 选项卡存在的唯一目的是显示已发布版本中字段的内容。
Editing draft versionEditing draft version

默认情况下,每个新创建的内容都是草稿。草稿可以随意修改和保存,使用界面右侧的 Entry 框中的 保存 按钮,直到它们准备好发布为止。

🌐 By default, each newly created content is a draft. Drafts can be modified and saved at will, using the Save button in the Entry box on the right side of the interface, until they are ready to be published.

一旦你对草稿进行了修改,你有3个可能的选项,所有这些选项都可以在界面右侧的 Entry 框中找到:

🌐 Once you made changes to a draft, you have 3 possible options, all available in the Entry box on the right side of the interface:

  • 发布你的文档(请参阅 发布草稿),
  • 保存你的草稿以便以后检索,
  • 或者通过点击 并选择 放弃更改来放弃更改。

发布草稿

🌐 Publishing a draft

路径: 内容管理员,编辑你的内容类型视图

要发布草稿,请点击界面右侧 Entry 框中的 发布 按钮。

🌐 To publish a draft, click on the Publish button in the Entry box on the right side of the interface.

草稿发布后:

🌐 After a draft is published:

  • 草稿已发布 标签的内容应完全相同(但 已发布 标签仍然是只读的)。
  • 位于文档标题下方的状态将切换为“已发布”.
Caution

在发布草稿之前,请确保它与其他未发布的内容没有关系,否则某些内容可能无法通过 API 访问。

🌐 Before publishing a draft, make sure it doesn't have relations with other non-published content, otherwise some of the content may not be available through the API.

当一个文档既有草稿版本又有已发布版本时,已发布版本可以在_已发布_标签中找到。如果文档只有草稿版本,则无法点击_已发布_标签。

🌐 When a document has both a draft and a published version available, the published version can be found in the Published tab. If the document has only a draft version, you can not click on the Published tab.

Editing published versionEditing published version
Tip

要安排发布(即在指定的日期和时间将草稿转换为已发布条目),你可以将其包含在一个发布中,并安排该发布的发布时间。有关更多信息,请参阅 发布功能 文档。

🌐 To schedule publication (i.e. convert a draft to a published entry at a given date and time) you can include it in a release and schedule the publication of that release. Please refer to the Releases feature documentation for more information.

取消发布内容

🌐 Unpublishing content

路径: 内容管理员,编辑你的内容类型视图

要取消发布已发布的内容:在“草稿”标签中,点击界面右侧“条目”框中的 ,然后选择取消发布按钮。

如果文档的草稿版本包含与已发布版本不同的内容,你可以决定在取消发布时如何处理这两种内容:

🌐 If the draft version of the document contains content different from the published version, you can decide what to do with both content when unpublishing:

  1. 在“草稿”标签中,点击界面右侧“条目”框中的 ,然后选择取消发布按钮。
  2. 在打开的确认对话框中,你可以选择:
    • 取消发布并保留最后的草稿,这样你当前在 草稿 标签中的所有内容都会被保留,但 已发布 标签中的所有内容肯定会被删除
    • 取消发布并替换最后的草稿,以丢弃 草稿 选项卡中的所有现有内容,并用 已发布 选项卡中所有字段的内容进行替换
  3. 点击 确认。所需的更改将应用于 草稿已发布 标签,并且条目的新状态也会显示在条目标题下方。
Unpublish a documentUnpublish a document

批量操作

🌐 Bulk actions

路径: 内容管理器,你的内容类型的列表视图

内容管理器的列表视图中选择多条条目将显示额外的按钮,以同时发布或取消发布多条条目。这就是所谓的“批量发布/取消发布”。

🌐 Selecting multiple entries from the Content Manager's list view will display additional buttons to publish or unpublish several entries simultaneously. This is what is called "bulk publishing/unpublishing".

Caution

如果安装了国际化功能,批量发布/取消发布操作只适用于当前选择的语言环境。

🌐 If the Internationalization feature is installed, the bulk publish/unpublish actions only apply to the currently selected locale.

Unpublish a documentUnpublish a document

批量发布草稿

🌐 Bulk publishing drafts

要同时发布多个条目:

🌐 To publish several entries at the same time:

  1. 从内容管理器的列表视图中,通过勾选条目记录左侧的框来选择要发布的条目。
  2. 点击表格标题上方的发布按钮。
  3. 在“发布条目”对话框中,检查已选择条目的列表及其状态:
    • 准备发布:条目可以发布
    • “[字段名称] 是必需的”,“[字段名称] 太短”或“[字段名称] 过长”:由于红色警告信息中提到的问题,该条目无法发布。
  4. (可选) 如果你的一些条目具有 状态,请点击 编辑按钮来修复问题,直到所有条目都具有 准备发布状态。请注意,在修复各种条目问题时,你需要点击 刷新 按钮以更新 发布条目 对话框。
  5. 点击 发布 按钮。
  6. 在确认对话框中,通过再次点击 发布 按钮来确认你的选择。

批量取消发布内容

🌐 Bulk unpublishing content

要同时取消发布多个条目:

🌐 To unpublish several entries at the same time:

  1. 从内容管理器的列表视图中,通过勾选条目记录左侧的框来选择要取消发布的条目。
  2. 点击位于表格标题上方的 取消发布 按钮。
  3. 在确认对话框中,通过再次点击 取消发布 按钮来确认你的选择。

与 API 一起使用

🌐 Usage with APIs

可以使用 status 参数通过可从 Strapi 的内容 API 访问的各种前端 API 请求、创建、更新和删除草稿或已发布的内容:

🌐 Draft or published content can be requested, created, updated, and deleted using the status parameter through the various front-end APIs accessible from Strapi's Content API:

在 Strapi 的后端服务器上,文档服务 API 还可用于与本地化内容进行交互:

🌐 On the back-end server of Strapi, the Document Service API can also be used to interact with localized content: