diff --git a/src/main.js b/src/main.js index 0bf7c3b5..68d534a2 100644 --- a/src/main.js +++ b/src/main.js @@ -8,7 +8,8 @@ const { ipcMain, nativeImage, dialog, - systemPreferences + systemPreferences, + session } = require('electron'); process.on('uncaughtException', (error) => { @@ -375,6 +376,22 @@ app.on('ready', function() { window_options.title = app.getName(); mainWindow = new BrowserWindow(window_options); + if (process.platform === 'darwin') { + session.defaultSession.on('will-download', (event, item, webContents) => { + var filename = item.getFilename(); + var savePath = dialog.showSaveDialog({ + title: filename, + defaultPath: require('os').homedir() + '/Downloads/' + filename + }); + + if (savePath) { + item.setSavePath(savePath); + } else { + item.cancel(); + } + }); + } + mainWindow.webContents.on('crashed', () => { console.log('The application has crashed.'); });