| 22 | } |
| 23 | |
| 24 | const createWindow = () => { |
| 25 | // Create the browser window. |
| 26 | const mainWindow = new BrowserWindow({ |
| 27 | width: 1350, |
| 28 | height: 780, |
| 29 | webPreferences: { |
| 30 | preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, |
| 31 | nodeIntegration: true, |
| 32 | contextIsolation: false, |
| 33 | devTools: false // enable chrome developer tools (when pressing ctrl-shift-i) |
| 34 | }, |
| 35 | }); |
| 36 | |
| 37 | // app.dock.hide(); // Only works/necessary on mac? |
| 38 | mainWindow.setMenuBarVisibility(false); // Only Windows and Linux |
| 39 | |
| 40 | // and load the index.html of the app. |
| 41 | mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY); |
| 42 | |
| 43 | // Open the DevTools at startup instead of requiring CTRL-ALT-i to be pressed: |
| 44 | // mainWindow.webContents.openDevTools(); |
| 45 | |
| 46 | // Allow iframe'ing lnbits |
| 47 | const { session } = require('electron') |
| 48 | session.defaultSession.webRequest.onHeadersReceived((details, callback) => { |
| 49 | callback({ |
| 50 | responseHeaders: { |
| 51 | ...details.responseHeaders, |
| 52 | 'Content-Security-Policy': ["default-src 'self' 'unsafe-inline' data:; script-src 'self' 'unsafe-eval' 'unsafe-inline' data:; frame-src 'self' https://legend.lnbits.com"] |
| 53 | } |
| 54 | }) |
| 55 | }); |
| 56 | |
| 57 | // Open target="_blank" links in external browser window |
| 58 | mainWindow.webContents.setWindowOpenHandler(({ url }) => { |
| 59 | shell.openExternal(url); |
| 60 | return { action: 'deny' }; |
| 61 | }); |
| 62 | |
| 63 | }; |
| 64 | |
| 65 | // This method will be called when Electron has finished |
| 66 | // initialization and is ready to create browser windows. |