This repository has been archived by the owner on May 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
29 lines (26 loc) · 1.46 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// To run this file you will need to put both `main.js` and `basic.html` in the location that you used `npm start`.
// This time we will also include BrowserWindow.
// You can view documentation on what is possible with this item and other Electron objects here: https://electronjs.org/docs/api
const {app, BrowserWindow } = require('electron');
global.$ = require('jquery/dist/jquery')
// This might be something you will do regularly in javascript if you want to maintain a reference to an object.
// If you do not keep this reference outside of the listener in some form, then it will get picked up by the garbage collector and get deleted.
let win;
app.on('ready', () => {
// This creates a new BrowserWindow and sets win to be a reference to that new window.
win = new BrowserWindow({
//width: 600, // Sets the width by pixel count
//height: 400, // Sets the height by pixel count
webPreferences: {
nodeIntegration: true // This ie extremely important later, but is not used in this example.
}
});
// This is a method of a BrowserWindow that lets you load an html file to view.
win.loadFile('index.html');
win.maximize();
win.on('close', () => {
// This frees the resources held by 'win' and lets the garbage collector take care of removing the window for you.
// The garbage collector will only remove things when there is no longer any references to the object.
win = null;
});
});