在 VS Code 中试试

通知

通知在 VS Code 右下角显示简要信息。

Example of a notification

您可以发送三种类型的通知

限制发送通知的数量非常重要,以尊重用户的注意力。为了帮助您决定是否应显示通知,请遵循我们的通知决策树

Show a multi-step quick pick if multi step user input is immediately needed. If user input is immediately needed but it is not multi-step show a modal dialog. If you need to show progress that is low priority show the progress in the status bar. If the interaction is triggered by the user find the right moment to show the notification and only then show it. If you need to show multiple notifications try to combine them into one. If the user does not really need to be notified consider to not show anything and relax.

通知示例

Information notification

此通知在用户运行更新版本命令后出现。请注意,没有额外的操作,纯粹是信息性的。

Warning notification

此示例突出显示了需要用户输入并显示解决问题操作的功能问题。

Error notification

此示例显示了一个带有解决问题操作的失败通知。

✔️ 应该

  • 仅在绝对必要时发送通知,以尊重用户的注意力
  • 为每个通知添加一个不再显示选项
  • 一次只显示一个通知

❌ 不应该

  • 发送重复通知
  • 用于推广
  • 在首次安装时请求反馈
  • 在没有操作时显示操作

进度通知

当需要显示不确定时间段的进度(例如,设置环境)时,可以使用进度通知。此类全局进度通知应作为最后手段使用,因为进度最好保持在上下文中(在视图或编辑器内)。

✔️ 应该

  • 显示查看更多详细信息(如日志)的链接
  • 随着设置的进行显示信息(初始化、构建等)
  • 提供取消操作的动作(如果适用)
  • 为超时场景添加计时器

❌ 不应该

  • 让通知一直显示进度

Progress notification

此示例使用进度通知显示远程连接的设置过程,同时还提供指向输出日志(详细信息)的链接。

当您需要立即获取用户输入以执行某个操作时,可以选择显示模态对话框。应谨慎使用此 UI 元素,因为模态对话框会阻止对话框外部的用户交互,直到其被关闭。

Modal dialog

此对话框在移动 JavaScript/TypeScript 文件后出现,要求更新其他文件中的导入语句。

✔️ 应该

  • 仅在需要立即用户交互时使用模态对话框
  • 酌情提供避免重复用户确认的操作(始终/从不操作)
  • 考虑使用复选框记住用户的选择

❌ 不应该

  • 使用模态对话框确认多个步骤
  • 使用模态对话框显示不需要用户操作的消息
  • 显示一个模态对话框用于非用户明确启动的操作