Class: Dock

Control your app in the macOS dock

进程:主进程

The following example shows how to bounce your icon on the dock.

  1. const { app } = require('electron')
  2. app.dock.bounce()

实例方法

dock.bounce([type]) macOS

  • type String (optional) - Can be critical or informational. The default is informational

Returns Integer - an ID representing the request.

当传入的是 critical 时, dock 中的应用将会开始弹跳, 直到这个应用被激活或者这个请求被取消。

When informational is passed, the dock icon will bounce for one second. However, the request remains active until either the application becomes active or the request is canceled.

Nota Bene: This method can only be used while the app is not focused; when the app is focused it will return -1.

dock.cancelBounce(id) macOS

  • id Integer

取消这个 id 对应的请求。

dock.downloadFinished(filePath) macOS

  • filePath String

如果 filePath 位于 Downloads 文件夹中,则弹出下载队列。

dock.setBadge(text) macOS

  • text String

设置应用在 dock 中显示的字符串。

dock.getBadge() macOS

返回 String - 应用在 dock 中显示的字符串。

dock.hide() macOS

隐藏 dock 中的图标。

dock.show() macOS

Returns Promise<void> - Resolves when the dock icon is shown.

dock.isVisible() macOS

Returns Boolean - Whether the dock icon is visible.

dock.setMenu(menu) macOS

Sets the application’s [dock menu][dock-menu].

dock.getMenu() macOS

Returns Menu | null - The application’s [dock menu][dock-menu].

dock.setIcon(image) macOS

设置image作为应用在 dock 中显示的图标