Skip to content

Commit 7c9ef06

Browse files
author
Jessica Lord
committed
Merge pull request electron#212 from electron/windows-icon
Update windows Tray icon
2 parents 74aa0dc + a62b6fb commit 7c9ef06

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

main-process/native-ui/tray/tray.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ const path = require('path')
22
const electron = require('electron')
33
const ipc = electron.ipcMain
44
const app = electron.app
5+
const Menu = electron.Menu
6+
const Tray = electron.Tray
57

68
let appIcon = null
79

810
ipc.on('put-in-tray', function (event) {
9-
const iconPath = path.join(__dirname, 'iconTemplate.png')
10-
appIcon = new electron.Tray(iconPath)
11-
const contextMenu = electron.Menu.buildFromTemplate([
12-
{ label: 'Remove',
13-
click: function (menuItem, browserWindow) {
14-
event.sender.send('tray-removed')
15-
appIcon.destroy()
16-
}
11+
const iconName = process.platform === 'win32' ? 'windows-icon.png' : 'iconTemplate.png'
12+
const iconPath = path.join(__dirname, iconName)
13+
appIcon = new Tray(iconPath)
14+
const contextMenu = Menu.buildFromTemplate([{
15+
label: 'Remove',
16+
click: function () {
17+
event.sender.send('tray-removed')
18+
appIcon.destroy()
1719
}
18-
])
20+
}])
1921
appIcon.setToolTip('Electron Demo in the tray.')
2022
appIcon.setContextMenu(contextMenu)
2123
})
2.48 KB
Loading

0 commit comments

Comments
 (0)