-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- update dependencies - remove babel compilation of node-side code, use esm instead - replace babel presets es2015 and stage-0 with babel-preset-env - remove old config options to nwb/express which don't do anything anymore - main/main.js is now executed after electron.app's 'ready' event fires - other stuff :)
- Loading branch information
Showing
9 changed files
with
2,936 additions
and
2,817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
{ | ||
"presets": ["es2015", "stage-0"] | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"electron": "current" | ||
} | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,2 @@ | ||
import { app, BrowserWindow, Menu, screen, ipcMain } from 'electron' | ||
import template from './menu-template.js' | ||
import windowStateKeeper from 'electron-window-state' | ||
import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer' | ||
|
||
const { DEV, PORT = '8080' } = process.env | ||
const windowUrl = DEV ? `http://0.0.0.0:${PORT}/` : 'file://' + __dirname + '/index.html' | ||
|
||
let mainWindow | ||
|
||
function createWindow() { | ||
installExtension(REACT_DEVELOPER_TOOLS) | ||
.then(name => { | ||
let { width, height } = screen.getPrimaryDisplay().workAreaSize | ||
|
||
Menu.setApplicationMenu(Menu.buildFromTemplate(template)) | ||
|
||
let mainWindowState = windowStateKeeper({ | ||
defaultWidth: width * 0.9, | ||
defaultHeight: height * 0.9, | ||
}) | ||
|
||
mainWindow = new BrowserWindow({ | ||
width: mainWindowState.width, | ||
height: mainWindowState.height, | ||
x: mainWindowState.x, | ||
y: mainWindowState.y, | ||
minWidth: 1000, | ||
minHeight: 700, | ||
titleBarStyle: 'hidden-inset', | ||
webPreferences: { | ||
webSecurity: false, | ||
}, | ||
show: false, | ||
}) | ||
|
||
mainWindowState.manage(mainWindow) | ||
mainWindow.loadURL(windowUrl) | ||
|
||
if (DEV) { | ||
mainWindow.webContents.openDevTools() | ||
} | ||
|
||
mainWindow.on('closed', () => { | ||
mainWindow = null | ||
}) | ||
|
||
mainWindow.once('ready-to-show', mainWindow.show) | ||
}) | ||
.catch(err => console.log('An error occurred: ', err)) | ||
} | ||
|
||
app.on('ready', createWindow) | ||
|
||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', () => { | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
process.on('uncaughtException', ::console.log) | ||
require = require('esm')(module) | ||
require('electron').app.on('ready', () => require('./main.js')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { app, BrowserWindow, screen, Menu, ipcMain } from 'electron' | ||
import template from './menu-template.js' | ||
import windowStateKeeper from 'electron-window-state' | ||
import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer' | ||
|
||
const { DEV, PORT = '8080' } = process.env | ||
const windowUrl = DEV ? `http://0.0.0.0:${PORT}/` : `file://${app.getAppPath()}/dist/index.html` | ||
|
||
let mainWindow | ||
|
||
installExtension(REACT_DEVELOPER_TOOLS) | ||
.then(name => { | ||
let { width, height } = screen.getPrimaryDisplay().workAreaSize | ||
|
||
Menu.setApplicationMenu(Menu.buildFromTemplate(template)) | ||
|
||
let mainWindowState = windowStateKeeper({ | ||
defaultWidth: width * 0.9, | ||
defaultHeight: height * 0.9, | ||
}) | ||
|
||
mainWindow = new BrowserWindow({ | ||
width: mainWindowState.width, | ||
height: mainWindowState.height, | ||
x: mainWindowState.x, | ||
y: mainWindowState.y, | ||
minWidth: 1000, | ||
minHeight: 600, | ||
titleBarStyle: 'hiddenInset', | ||
webPreferences: { | ||
webSecurity: false, | ||
}, | ||
show: false, | ||
}) | ||
|
||
mainWindowState.manage(mainWindow) | ||
mainWindow.loadURL(windowUrl) | ||
|
||
if (DEV) { | ||
mainWindow.webContents.once('dom-ready', () => { | ||
mainWindow.webContents.openDevTools() | ||
}) | ||
} | ||
|
||
mainWindow.on('closed', () => { | ||
mainWindow = null | ||
}) | ||
|
||
mainWindow.once('ready-to-show', mainWindow.show) | ||
}) | ||
.catch(err => console.log('An error occurred: ', err)) | ||
|
||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', () => { | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
process.on('uncaughtException', console.log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.