Skip to main content

类:Dock

类:Dock

🌐 Class: Dock

在 macOS Dock 中控制你的应用

进程: 主进程
此类未从 'electron' 模块导出。它仅作为 Electron API 中其他方法的返回值提供。

实例方法

🌐 Instance Methods

dock.bounce([type]) macOS

  • type 字符串(可选)- 可以是 criticalinformational。默认值是 informational

返回 Integer - 表示请求的 ID。

🌐 Returns Integer - an ID representing the request.

当传入 critical 时,Dock 图标会弹跳,直到应用变为活动状态或请求被取消。

🌐 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。

dock.cancelBounce(id) macOS

  • id 整数

取消 id 的弹跳。

🌐 Cancel the bounce of id.

dock.downloadFinished(filePath) macOS

  • filePath 字符串

如果 filePath 位于“下载”文件夹内,则退回“下载”堆栈。

🌐 Bounces the Downloads stack if the filePath is inside the Downloads folder.

dock.setBadge(text) macOS

  • text 字符串

设置要在扩展坞的徽章区域中显示的字符串。

🌐 Sets the string to be displayed in the dock’s badging area.

info

你需要确保你的应用具有显示通知的权限,才能使此方法生效。

dock.getBadge() macOS

返回 string - Dock 的徽章字符串。

🌐 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 - 指示 dock 图标是否可见。

🌐 Returns boolean - Whether the dock icon is visible.

dock.setMenu(menu) macOS

设置应用的 停靠菜单

🌐 Sets the application's dock menu.

dock.getMenu() macOS

返回 Menu | null - 应用的 停靠菜单

🌐 Returns Menu | null - The application's dock menu.

dock.setIcon(image) macOS

设置与此停靠图标关联的 image

🌐 Sets the image associated with this dock icon.