diff --git a/electron/main.js b/electron/main.js index 1620686a..9de1eacd 100644 --- a/electron/main.js +++ b/electron/main.js @@ -3,8 +3,9 @@ const path = require('path') const XLSX = require('xlsx'); const {app, BrowserWindow, ipcMain, dialog} = require('electron') -let mainWindow = null; -let willQuitApp = false, +let mainWindow = null, + willQuitApp = false, + inheritClose = false, devloadCachePath = path.resolve(__dirname, ".devload"), devloadUrl = ""; if (fs.existsSync(devloadCachePath)) { @@ -53,7 +54,11 @@ function createWindow() { mainWindow.on('close', function (e) { if (!willQuitApp) { e.preventDefault(); - mainWindow.webContents.send("windowClose", {}) + if (inheritClose) { + mainWindow.webContents.send("windowClose", {}) + } else { + app.hide(); + } } }) } @@ -74,12 +79,16 @@ app.on('before-quit', () => { willQuitApp = true }) -ipcMain.on('setDockBadge', (event, arg) => { - if (runNum(arg) > 0) { - app.dock.setBadge(String(arg)) - } else { - app.dock.setBadge("") - } +ipcMain.on('inheritClose', () => { + inheritClose = true +}) + +ipcMain.on('windowHidden', () => { + app.hide(); +}) + +ipcMain.on('windowClose', () => { + mainWindow.close() }) ipcMain.on('windowMax', function () { @@ -90,14 +99,14 @@ ipcMain.on('windowMax', function () { } }) -ipcMain.on('windowHidden', () => { - app.hide(); +ipcMain.on('setDockBadge', (event, arg) => { + if (runNum(arg) > 0) { + app.dock.setBadge(String(arg)) + } else { + app.dock.setBadge("") + } }) -ipcMain.on('windowClose', () => { - mainWindow.close() -}); - ipcMain.on('saveSheet', (event, data, filename, opts) => { const EXTENSIONS = "xls|xlsx|xlsm|xlsb|xml|csv|txt|dif|sylk|slk|prn|ods|fods|htm|html".split("|"); dialog.showSaveDialog({ diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index c2395793..bb262739 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -177,6 +177,7 @@ export default { return; } const {ipcRenderer} = this.$electron; + ipcRenderer.send('inheritClose'); ipcRenderer.on('windowClose', () => { if (this.$Modal.removeLast()) { return;