| 9 | let splash = null; |
| 10 | |
| 11 | const menuTemplate = windowObj => [ |
| 12 | {}, |
| 13 | { |
| 14 | label: 'Main', |
| 15 | submenu: [ |
| 16 | { role: 'about' }, |
| 17 | { type: 'separator' }, |
| 18 | { role: 'hide' }, |
| 19 | { role: 'hideothers' }, |
| 20 | { role: 'unhide' }, |
| 21 | { type: 'separator' }, |
| 22 | { role: 'quit' } |
| 23 | ] |
| 24 | }, |
| 25 | { |
| 26 | label: 'File', |
| 27 | submenu: [ |
| 28 | { |
| 29 | label: 'New Project', |
| 30 | click: () => { |
| 31 | // warn user of unsaved changes before below |
| 32 | global.newProj = true; |
| 33 | const save = dialog.showSaveDialog(); |
| 34 | //Run cra with 'save' variable as destination path |
| 35 | if (save) { |
| 36 | cra(path.join(path.dirname(save), path.basename(save).toLowerCase())); |
| 37 | splash = new BrowserWindow({ |
| 38 | width: 600, |
| 39 | height: 400, |
| 40 | minWidth: 604, |
| 41 | minHeight: 283, |
| 42 | webPreferences: { |
| 43 | devTools: false |
| 44 | } |
| 45 | }) |
| 46 | |
| 47 | splash.setAlwaysOnTop(true); |
| 48 | splash.loadFile(path.join(__dirname, "../../renderer/splash/public/index.html")) |
| 49 | |
| 50 | splash.once('ready-to-show', () => { |
| 51 | splash.show(); |
| 52 | }) |
| 53 | |
| 54 | global.mainWindow.webContents.send('newProject'); |
| 55 | |
| 56 | |
| 57 | ipcMain.on('closeSplash', () => { |
| 58 | splash.close() |
| 59 | }) |
| 60 | |
| 61 | ipcMain.on('closed', () => { |
| 62 | splash = null |
| 63 | }) |
| 64 | |
| 65 | //garbage collect loader page |
| 66 | splash.on('closeSplash', () => { |
| 67 | splash.close() |
| 68 | splash = null |