类:Dock
类:Dock
¥Class: Dock
在 macOS Dock 中控制你的应用
¥Control your app in the macOS dock
进程:主进程
该类不是从 'electron'
模块导出的。它仅可用作 Electron API 中其他方法的返回值。
¥Process: Main
This class is not exported from the 'electron'
module. It is only available as a return value of other methods in the Electron API.
以下示例展示了如何在扩展坞上弹起图标。
¥The following example shows how to bounce your icon on the dock.
const { app } = require('electron')
app.dock.bounce()
实例方法
¥Instance Methods
dock.bounce([type])
macOS
-
type
字符串(可选) - 可以是critical
或informational
。默认为informational
¥
type
string (optional) - Can becritical
orinformational
. The default isinformational
返回 Integer
- 代表请求的 ID。
¥Returns Integer
- an ID representing the request.
当 critical
被传递时,停靠栏图标将弹起,直到应用变为活动状态或请求被取消。
¥When critical
is passed, the dock icon will bounce until either the
application becomes active or the request is canceled.
当 informational
经过时,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.
注意:此方法只能在应用未聚焦时使用;当应用获得焦点时,它将返回 -1。
¥Note: 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
整数¥
id
Integer
取消 id
的反弹。
¥Cancel the bounce of id
.
dock.downloadFinished(filePath)
macOS
-
filePath
字符串¥
filePath
string
如果 filePath 位于“下载”文件夹内,则退回“下载”堆栈。
¥Bounces the Downloads stack if the filePath is inside the Downloads folder.
dock.setBadge(text)
macOS
-
text
字符串¥
text
string
设置要在扩展坞的徽章区域中显示的字符串。
¥Sets the string to be displayed in the dock’s badging area.
dock.getBadge()
macOS
返回 string
- 码头的徽章字符串。
¥Returns string
- The badge string of the dock.
dock.hide()
macOS
隐藏停靠栏图标。
¥Hides the dock icon.
dock.show()
macOS
返回 Promise<void>
- 当显示停靠栏图标时解决。
¥Returns Promise<void>
- Resolves when the dock icon is shown.
dock.isVisible()
macOS
返回 boolean
- 停靠栏图标是否可见。
¥Returns boolean
- Whether the dock icon is visible.
dock.setMenu(menu)
macOS
menu
Menu
设置应用的 停靠菜单。
¥Sets the application's dock menu.
dock.getMenu()
macOS
返回 Menu | null
- 该应用的 停靠菜单。
¥Returns Menu | null
- The application's dock menu.
dock.setIcon(image)
macOS
image
(NativeImage | string)
设置与此 Dock 图标关联的 image
。
¥Sets the image
associated with this dock icon.