File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
main-process/native-ui/tray Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -2,20 +2,22 @@ const path = require('path')
2
2
const electron = require ( 'electron' )
3
3
const ipc = electron . ipcMain
4
4
const app = electron . app
5
+ const Menu = electron . Menu
6
+ const Tray = electron . Tray
5
7
6
8
let appIcon = null
7
9
8
10
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 ( )
17
19
}
18
- ] )
20
+ } ] )
19
21
appIcon . setToolTip ( 'Electron Demo in the tray.' )
20
22
appIcon . setContextMenu ( contextMenu )
21
23
} )
You can’t perform that action at this time.
0 commit comments