儀表板
目錄
使用者通知
浮動通知為使用者提供簡短的通知。它們暫時出現,不應中斷使用者體驗。它們也不需要使用者輸入即可消失。
成功
▸ success(msg
): void
用於顯示成功型別的浮動通知訊息。
ddClient.desktopUI.toast.success("message");
警告
▸ warning(msg
): void
用於顯示警告型別的浮動通知訊息。
ddClient.desktopUI.toast.warning("message");
錯誤
▸ error(msg
): void
用於顯示錯誤型別的浮動通知訊息。
ddClient.desktopUI.toast.error("message");
有關方法引數和可用返回型別的更多詳細資訊,請參閱 Toast API 參考。
已廢棄的使用者通知
這些方法已廢棄,將在未來版本中移除。請使用上面指定的方法。
window.ddClient.toastSuccess("message");
window.ddClient.toastWarning("message");
window.ddClient.toastError("message");
開啟檔案選擇對話方塊
此函式會開啟一個檔案選擇器對話方塊,要求使用者選擇一個檔案或資料夾。
▸ showOpenDialog(dialogProperties
): Promise
< OpenDialogResult
>
dialogProperties
引數是傳遞給 Electron 的標誌列表,用於自定義對話方塊的行為。例如,您可以傳遞 multiSelections
允許使用者選擇多個檔案。有關完整列表,請參閱 Electron 的文件。
const result = await ddClient.desktopUI.dialog.showOpenDialog({
properties: ["openDirectory"],
});
if (!result.canceled) {
console.log(result.paths);
}
開啟一個 URL
此函式使用系統預設瀏覽器開啟外部 URL。
▸ openExternal(url
): void
ddClient.host.openExternal("https://docker.com");
URL 必須具有
http
或https
協議。
有關方法引數和可用返回型別的更多詳細資訊,請參閱 桌面主機 API 參考。
已廢棄的使用者通知
此方法已廢棄,將在未來版本中移除。請使用上面指定的方法。
window.ddClient.openExternal("https://docker.com");
導航到儀表盤路由
在您的擴充套件中,您還可以導航到 Docker Desktop 儀表盤的其他部分。