File tree Expand file tree Collapse file tree 3 files changed +63
-62
lines changed
multi-window-electron-desktop-app Expand file tree Collapse file tree 3 files changed +63
-62
lines changed Original file line number Diff line number Diff line change 1
- var app = require ( 'app' )
2
- var BrowserWindow = require ( 'browser-window' )
3
- var ipc = require ( 'ipc' )
4
-
5
- app . on ( 'ready' , function ( ) {
6
- var mainWindow = new BrowserWindow ( {
7
- width : 800 ,
8
- height : 600
9
- } )
10
- mainWindow . loadUrl ( 'file://' + __dirname + '/main.html' )
11
- mainWindow . openDevTools ( )
12
-
13
- var prefsWindow = new BrowserWindow ( {
14
- width : 400 ,
15
- height : 400 ,
16
- show : false
17
- } )
18
- prefsWindow . loadUrl ( 'file://' + __dirname + '/prefs.html' )
19
-
20
- ipc . on ( 'toggle-prefs' , function ( ) {
21
- if ( prefsWindow . isVisible ( ) )
22
- prefsWindow . hide ( )
23
- else
24
- prefsWindow . show ( )
25
- } )
26
- } )
1
+ const { app, BrowserWindow, ipcMain} = require ( 'electron' )
2
+
3
+ app . on ( 'ready' , function ( ) {
4
+ var mainWindow = new BrowserWindow ( {
5
+ width : 800 ,
6
+ height : 600
7
+ } )
8
+ mainWindow . loadURL ( 'file://' + __dirname + '/main.html' )
9
+ mainWindow . openDevTools ( )
10
+
11
+ var prefsWindow = new BrowserWindow ( {
12
+ width : 400 ,
13
+ height : 400 ,
14
+ show : false
15
+ } )
16
+ prefsWindow . loadURL ( 'file://' + __dirname + '/prefs.html' )
17
+
18
+ ipcMain . on ( 'toggle-prefs' , function ( ) {
19
+ if ( prefsWindow . isVisible ( ) )
20
+ prefsWindow . hide ( )
21
+ else
22
+ prefsWindow . show ( )
23
+ } )
24
+
25
+ } )
Original file line number Diff line number Diff line change 1
- var remote = require ( 'remote' )
2
- var ipc = require ( 'ipc' )
3
- var Menu = remote . require ( 'menu' )
4
-
5
- var menu = Menu . buildFromTemplate ( [
6
- {
7
- label : 'Electron' ,
8
- submenu : [
9
- {
10
- label : 'Prefs' ,
11
- click : function ( ) {
12
- ipc . send ( 'toggle-prefs' )
13
- }
14
- }
15
- ]
16
- }
17
- ] )
18
- Menu . setApplicationMenu ( menu )
1
+ const { remote, ipcRenderer} = require ( 'electron' )
2
+ const { Menu, MenuItem} = remote
3
+
4
+ const menu = new Menu ( )
5
+
6
+ menu . append ( new MenuItem (
7
+ {
8
+ label : 'Electron' ,
9
+ submenu : [
10
+ {
11
+ label : 'Prefs' ,
12
+ click : function ( ) {
13
+ ipcRenderer . send ( 'toggle-prefs' )
14
+ }
15
+ }
16
+ ]
17
+ } )
18
+ )
19
+
20
+ Menu . setApplicationMenu ( menu )
Original file line number Diff line number Diff line change 1
- < html >
2
- < head >
3
- < title > </ title >
4
- </ head >
5
- < body >
6
- Prefs
7
- < script >
8
- var ipc = require ( 'ipc ' )
9
-
10
- var button = document . createElement ( 'button' )
11
- button . textContent = 'Hide'
12
- button . addEventListener ( 'click' , function ( ) {
13
- ipc . send ( 'toggle-prefs' )
14
- } )
15
- document . body . appendChild ( button )
16
- </ script >
17
- </ body >
18
- </ html >
1
+ < html >
2
+ < head >
3
+ < title > </ title >
4
+ </ head >
5
+ < body >
6
+ Prefs
7
+ < script >
8
+ const { ipcRenderer } = require ( 'electron ' )
9
+
10
+ var button = document . createElement ( 'button' )
11
+ button . textContent = 'Hide'
12
+ button . addEventListener ( 'click' , function ( ) {
13
+ ipcRenderer . send ( 'toggle-prefs' )
14
+ } ) ;
15
+ document . body . appendChild ( button )
16
+ </ script >
17
+ </ body >
18
+ </ html >
You can’t perform that action at this time.
0 commit comments