通知

通知 用於顯示簡短資訊,會從 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 檔案後出現,詢問是否要更新其他檔案中的匯入敘述。

✔️ 建議做法

  • 僅在需要使用者立即互動時才使用強制回應對話方塊
  • 在適當的情況下,提供一個避免重複確認的動作(總是/從不動作)
  • 考慮使用核取方塊來記住使用者的選擇

❌ 不建議做法

  • 使用強制回應對話方塊來確認多個步驟
  • 使用強制回應對話方塊來顯示不需要使用者採取動作的訊息
  • 針對並非由使用者明確啟動的動作顯示強制回應對話方塊
© . This site is unofficial and not affiliated with Microsoft.