From 884e193384ee34bbcb2a7cc7aa39b40e1c3334a9 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 15 Apr 2019 19:56:30 -0400 Subject: rename main.js and don't open dev tools --- electron/src/index.js | 50 -------------------------------------------------- electron/src/main.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 electron/src/index.js create mode 100644 electron/src/main.js (limited to 'electron/src') diff --git a/electron/src/index.js b/electron/src/index.js deleted file mode 100644 index 90aaea63..00000000 --- a/electron/src/index.js +++ /dev/null @@ -1,50 +0,0 @@ -import { app, BrowserWindow, ipcMain, dialog } from 'electron'; -var fs = require('fs'); - -// 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; - -const createWindow = () => { - // Create the browser window. - mainWindow = new BrowserWindow(); - - mainWindow.maximize(); - - // and load the index.html of the app. - if (process.argv[1] == ".") { - // run in development mode with `electron . ` - var url = process.argv[2]; - } else { - var url = process.argv[1]; - } - mainWindow.loadURL(url); - - mainWindow.webContents.openDevTools(); - - // Emitted when the window is closed. - 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. -app.on('ready', createWindow); - -// Quit when all windows are closed. -app.on('window-all-closed', () => { - app.quit(); -}); - -ipcMain.on('print', function (event, pageSize) { - mainWindow.webContents.printToPDF({"pageSize": pageSize}, function(error, data) { - dialog.showSaveDialog(mainWindow, {"defaultPath": "inkstitch.pdf"}, function(filename, bookmark) { - fs.writeFileSync(filename, data, 'utf-8'); - }) - }) -}) \ No newline at end of file diff --git a/electron/src/main.js b/electron/src/main.js new file mode 100644 index 00000000..f78680e0 --- /dev/null +++ b/electron/src/main.js @@ -0,0 +1,50 @@ +import { app, BrowserWindow, ipcMain, dialog } from 'electron'; +var fs = require('fs'); + +// 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; + +const createWindow = () => { + // Create the browser window. + mainWindow = new BrowserWindow(); + + mainWindow.maximize(); + + // and load the index.html of the app. + if (process.argv[1] == ".") { + // run in development mode with `electron . ` + var url = process.argv[2]; + } else { + var url = process.argv[1]; + } + mainWindow.loadURL(url); + + //mainWindow.webContents.openDevTools(); + + // Emitted when the window is closed. + 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. +app.on('ready', createWindow); + +// Quit when all windows are closed. +app.on('window-all-closed', () => { + app.quit(); +}); + +ipcMain.on('print', function (event, pageSize) { + mainWindow.webContents.printToPDF({"pageSize": pageSize}, function(error, data) { + dialog.showSaveDialog(mainWindow, {"defaultPath": "inkstitch.pdf"}, function(filename, bookmark) { + fs.writeFileSync(filename, data, 'utf-8'); + }) + }) +}) \ No newline at end of file -- cgit v1.2.3