类: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.
[!TIP] 另请参阅:关于如何实现 Dock 菜单的详细指南。
¥[!TIP] See also: A detailed guide about how to implement Dock menus.
实例方法
¥Instance Methods
dock.bounce([type]) macOS
-
type字符串(可选) - 可以是critical或informational。默认为informational¥
typestring (optional) - Can becriticalorinformational. 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.
[!NOTE] 此方法仅在应用未获得焦点时可用;当应用获得焦点时,它将返回 -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整数¥
idInteger
取消 id 的反弹。
¥Cancel the bounce of id.
dock.downloadFinished(filePath) macOS
-
filePath字符串¥
filePathstring
如果 filePath 位于“下载”文件夹内,则退回“下载”堆栈。
¥Bounces the Downloads stack if the filePath is inside the Downloads folder.
dock.setBadge(text) macOS
-
text字符串¥
textstring
设置要在扩展坞的徽章区域中显示的字符串。
¥Sets the string to be displayed in the dock’s badging area.
[!重要] 你需要确保你的应用具有显示通知的权限,此方法才能正常工作。
¥[!IMPORTANT] You need to ensure that your application has the permission to display notifications for this method to work.
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
menuMenu
设置应用的 停靠菜单。
¥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.