feat(desktop): save and restore window state

release/desktop
moonrailgun 3 years ago
parent e1a8110aaf
commit e6bd06bf73

@ -31,6 +31,7 @@
"typescript": "~4.5.4"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
"electron-squirrel-startup": "^1.0.0",
"electron-window-state": "^5.0.3"
}
}

@ -1,5 +1,6 @@
import { app, BrowserWindow } from 'electron';
import path from 'path';
import windowStateKeeper from 'electron-window-state';
const isDev = !app.isPackaged;
const webUrl = isDev
@ -13,10 +14,17 @@ if (require('electron-squirrel-startup')) {
}
const createWindow = (): void => {
const mainWindowState = windowStateKeeper({
defaultWidth: 960,
defaultHeight: 640,
});
// Create the browser window.
const mainWindow = new BrowserWindow({
height: 640,
width: 960,
x: mainWindowState.x,
y: mainWindowState.y,
height: mainWindowState.height,
width: mainWindowState.width,
minHeight: 640,
minWidth: 960,
center: true,
@ -29,6 +37,8 @@ const createWindow = (): void => {
mainWindow.loadURL(webUrl);
mainWindowState.manage(mainWindow);
if (isDev) {
// Open the DevTools.
mainWindow.webContents.openDevTools();

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save