Skip to content

A full-featured download manager.

feat: add DockManager

Dr_rOotb7356702fc7f
diff --git a/src/main/ui/DockManager.js b/src/main/ui/DockManager.js
new file mode 100644
index 00000000..699d2961
--- /dev/null
+++ b/src/main/ui/DockManager.js
@@ -0,0 +1,36 @@
+import is from 'electron-is'
+import { EventEmitter } from 'events'
+import { app } from 'electron'
+import {
+ APP_RUN_MODE
+} from '@shared/constants'
+
+const isMac = is.macOS()
+
+export default class DockManager extends EventEmitter {
+ constructor (options) {
+ super()
+ this.options = options
+ const { runMode } = this.options
+ console.log('DockManager options', this.options)
+ if (runMode !== APP_RUN_MODE.STANDARD) {
+ this.hide()
+ }
+ }
+
+ show = isMac ? () => {
+ return app.dock.show()
+ } : () => {}
+
+ hide = isMac ? () => {
+ app.dock.hide()
+ } : () => {}
+
+ setBadge = isMac ? (text) => {
+ app.dock.setBadge(text)
+ } : (text) => {}
+
+ openDock = isMac ? (path) => {
+ app.dock.downloadFinished(path)
+ } : (path) => {}
+}