1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-26 04:02:51 +01:00
lossless-cut/src/index.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-10-30 11:57:12 +01:00
const electron = require('electron'); // eslint-disable-line
const isDev = require('electron-is-dev');
2016-10-30 11:57:12 +01:00
const menu = require('./menu');
2018-02-17 15:15:30 +01:00
const { checkNewVersion } = require('./update-checker');
2018-09-30 22:08:36 +02:00
const { app } = electron;
const { BrowserWindow } = electron;
2016-10-30 11:57:12 +01:00
2020-02-11 15:16:03 +01:00
app.name = 'LosslessCut';
if (!isDev) process.env.NODE_ENV = 'production';
2016-10-30 11:57:12 +01:00
// 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 mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
darkTheme: true,
webPreferences: {
nodeIntegration: true,
},
2016-10-30 11:57:12 +01:00
});
mainWindow.loadFile(isDev ? 'index.html' : 'build/index.html');
2016-10-30 11:57:12 +01:00
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}
// 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.
2018-02-17 15:15:30 +01:00
app.on('ready', async () => {
2016-10-30 11:57:12 +01:00
createWindow();
menu(app, mainWindow);
2018-02-17 15:15:30 +01:00
const newVersion = await checkNewVersion();
if (newVersion) {
menu(app, mainWindow, newVersion);
}
2016-10-30 11:57:12 +01:00
});
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit();
});
app.on('activate', () => {
// On OS X 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 (mainWindow === null) {
createWindow();
}
});
electron.ipcMain.on('renderer-ready', () => {
if (!isDev) {
const fileToOpen = process.argv[1];
if (fileToOpen) mainWindow.webContents.send('file-opened', [fileToOpen]);
}
});