File tree Expand file tree Collapse file tree 3 files changed +60
-60
lines changed
multi-window-electron-desktop-app Expand file tree Collapse file tree 3 files changed +60
-60
lines changed Original file line number Diff line number Diff line change 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
-
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
25
} )
Original file line number Diff line number Diff line change 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
-
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
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
- 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 >
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
18
</ html >
You can’t perform that action at this time.
0 commit comments