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 7c31546 commit 46dcfbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ app.on("ready", () => {
mainWindow.on("close", (e) => {
e.preventDefault()
mainWindow.hide()
displayTray(trayIcon)
displayTray(icon, trayIcon)
})

const onClosed = () => {
Expand Down
15 changes: 10 additions & 5 deletions app/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*
*/

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

let tray = null
let trayMenu = null
Expand All @@ -21,8 +20,8 @@ const getTrayMenu = () => {
return _trayMenu
}

const displayTray = async (icon) => {
tray = new Tray(icon)
const displayTray = async (icon, trayIcon) => {
tray = new Tray(trayIcon)
tray.setToolTip("AriaNg GUI v" + app.getVersion())
tray.setContextMenu(trayMenu || getTrayMenu())

Expand Down Expand Up @@ -51,8 +50,14 @@ const displayTray = async (icon) => {
tray.displayBalloon({
icon,
title,
content
content,
})
} else if (Notification.isSupported()) {
new Notification({
title,
body: content,
icon,
}).show()
} else {
dialog.showMessageBox({
type: "info",
Expand Down

0 comments on commit 46dcfbb

Please sign in to comment.