const { app, BrowserWindow, ipcMain } = require('electron'); // Handle creating/removing shortcuts on Windows when installing/uninstalling. if (require('electron-squirrel-startup')) { // eslint-disable-line global-require app.quit(); } // 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', createSplashScreen); // Quit when all windows are closed, except on macOS. There, it's common // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. app.on('window-all-closed', () => { if (process.platform !== 'darwin') { 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 (BrowserWindow.getAllWindows().length === 0) { createSplashScreen(); } }); function createSplashScreen() { // Create the browser window. const splash_screen = new BrowserWindow({ width: 800, height: 600, autoHideMenuBar: true, webPreferences: { nodeIntegration: true } }); // and load the splash.html of the app. splash_screen.loadFile('src/splash.html'); // Open the DevTools. splash_screen.webContents.openDevTools(); } function createEditorWindow() { let main_window = new BrowserWindow({ width: 1000, height: 600, autoHideMenuBar: true, webPreferences: { nodeIntegration: true } }); main_window.loadFile("src/editor.html"); // Open the DevTools. main_window.webContents.openDevTools(); return main_window; } function createNew() { let old_window = BrowserWindow.getFocusedWindow(); let main_window = createEditorWindow(); main_window.once("ready-to-show", () => { main_window.webContents.send("open-default"); }) old_window.close(); } ipcMain.on("create-new", (event) => { createNew(); })