Skip to content

Commit

Permalink
修复跨平台陷阱引发的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmader committed Oct 1, 2019
1 parent 46dcfbb commit bfc8ed1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

const os = require("os")
const { app, Tray, BrowserWindow, ipcMain, dialog, Notification } = require("electron")

let tray = null
Expand All @@ -30,7 +31,9 @@ const displayTray = async (icon, trayIcon) => {
})

// MacOS
app.dock.hide()
if (os.platform() == "darwin") {
app.dock.hide()
}

const minimizeNotificationDisabled = await new Promise((resolve) => {
const mainWindow = BrowserWindow.getAllWindows()[0]
Expand All @@ -54,9 +57,9 @@ const displayTray = async (icon, trayIcon) => {
})
} else if (Notification.isSupported()) {
new Notification({
icon,
title,
body: content,
icon,
}).show()
} else {
dialog.showMessageBox({
Expand All @@ -76,7 +79,9 @@ const destroyTray = () => {
const mainWindow = BrowserWindow.getAllWindows()[0]

// MacOS
app.dock.show()
if (os.platform() == "darwin") {
app.dock.show()
}

mainWindow.show()

Expand Down

0 comments on commit bfc8ed1

Please sign in to comment.