-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2493d5
commit 22cf0fe
Showing
1 changed file
with
38 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,49 @@ | ||
const { app, BrowserWindow, systemPreferences } = require('electron'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
const { app, BrowserWindow, systemPreferences } = require("electron"); | ||
const path = require("path"); | ||
const url = require("url"); | ||
|
||
// Keep a global reference of the window object, if you don't, the window will | ||
// be closed automatically when the JavaScript object is garbage collected. | ||
let win; | ||
|
||
function createWindow () { | ||
win = new BrowserWindow({ | ||
width: 1280, | ||
height: 720, | ||
webPreferences: { | ||
nodeIntegration: true | ||
}, | ||
icon: path.join(__dirname, 'icons', '256x256.png') | ||
}); | ||
|
||
win.loadURL(url.format({ | ||
pathname: path.join(__dirname, 'index.html'), | ||
protocol: 'file:', | ||
slashes: true | ||
})); | ||
|
||
win.webContents.openDevTools(); | ||
|
||
win.on('closed', () => { | ||
win = null | ||
}); | ||
|
||
if (systemPreferences.askForMediaAccess) { | ||
systemPreferences.askForMediaAccess("camera"); | ||
} | ||
function createWindow() { | ||
win = new BrowserWindow({ | ||
width: 1280, | ||
height: 720, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
}, | ||
icon: path.join(__dirname, "icons", "256x256.png"), | ||
}); | ||
|
||
win.loadURL( | ||
url.format({ | ||
pathname: path.join(__dirname, "index.html"), | ||
protocol: "file:", | ||
slashes: true, | ||
}) | ||
); | ||
|
||
win.webContents.openDevTools(); | ||
|
||
win.on("closed", () => { | ||
win = null; | ||
}); | ||
|
||
if (systemPreferences.askForMediaAccess) { | ||
systemPreferences.askForMediaAccess("camera"); | ||
} | ||
} | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.on('ready', createWindow); | ||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', () => { | ||
// On macOS it is common for applications and their menu bar | ||
// to stay active until the user quits explicitly with Cmd + Q | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}); | ||
app.on("ready", createWindow); | ||
|
||
app.on('activate', () => { | ||
// On macOS it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (win === null) { | ||
createWindow() | ||
} | ||
app.on("window-all-closed", () => { | ||
app.quit(); | ||
}); | ||
|
||
// In this file you can include the rest of your app's specific main process | ||
// code. You can also put them in separate files and require them here. | ||
app.on("activate", () => { | ||
if (win === null) { | ||
createWindow(); | ||
} | ||
}); |