Skip to content

Commit

Permalink
format main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohersan committed Jun 4, 2023
1 parent e2493d5 commit 22cf0fe
Showing 1 changed file with 38 additions and 48 deletions.
86 changes: 38 additions & 48 deletions main.js
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();
}
});

0 comments on commit 22cf0fe

Please sign in to comment.