()
| 72 | } |
| 73 | |
| 74 | function createWindow() { |
| 75 | const bounds = normalizeWindowBounds( |
| 76 | store.app.get('window.bounds'), |
| 77 | screen.getAllDisplays(), |
| 78 | ) |
| 79 | |
| 80 | mainWindow = new BrowserWindow({ |
| 81 | ...DEFAULT_WINDOW_BOUNDS, |
| 82 | ...bounds, |
| 83 | titleBarStyle: process.platform === 'darwin' ? 'hidden' : 'default', |
| 84 | webPreferences: { |
| 85 | preload: path.join(__dirname, 'preload.js'), |
| 86 | nodeIntegration: true, |
| 87 | webSecurity: false, |
| 88 | }, |
| 89 | }) |
| 90 | |
| 91 | Menu.setApplicationMenu(createMainMenu()) |
| 92 | |
| 93 | if (isDev) { |
| 94 | mainWindow.loadURL(`http://localhost:${process.env.DEV_PORT || 5177}`) |
| 95 | mainWindow.webContents.openDevTools() |
| 96 | } |
| 97 | else { |
| 98 | mainWindow.loadFile( |
| 99 | path.join(__dirname, '../../build/renderer/index.html'), |
| 100 | ) |
| 101 | } |
| 102 | |
| 103 | ipcMain.once('system:renderer-ready', () => { |
| 104 | if (migrationResult) { |
| 105 | mainWindow.webContents.send('system:migration-complete', migrationResult) |
| 106 | } |
| 107 | else if (migrationError) { |
| 108 | mainWindow.webContents.send('system:migration-error', { |
| 109 | message: migrationError, |
| 110 | }) |
| 111 | } |
| 112 | }) |
| 113 | |
| 114 | mainWindow.on('move', scheduleWindowBoundsSave) |
| 115 | mainWindow.on('resize', scheduleWindowBoundsSave) |
| 116 | |
| 117 | mainWindow.on('close', (event) => { |
| 118 | flushWindowBoundsSave() |
| 119 | |
| 120 | if (process.platform === 'darwin' && !isQuitting()) { |
| 121 | event.preventDefault() |
| 122 | mainWindow.hide() |
| 123 | return |
| 124 | } |
| 125 | |
| 126 | mainWindow.destroy() |
| 127 | }) |
| 128 | } |
| 129 | |
| 130 | if (!gotTheLock) { |
| 131 | app.quit() |
no test coverage detected