Skip to content

Commit

Permalink
Keep window's size at restart
Browse files Browse the repository at this point in the history
  • Loading branch information
themagiulio committed Sep 4, 2020
1 parent d4ef462 commit d6ba663
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 30 deletions.
17 changes: 17 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const path = require('path');
const request = require('request');
const unzip = require('unzipper');
const url = require('url');
const windowStateKeeper = require('electron-window-state');

let mainWindow;
const downloadFolder = app.getPath('downloads') + '/bandcamp-desktop/';
Expand Down Expand Up @@ -41,12 +42,28 @@ app.on('ready', function(){
});

function createWindow(){
/*
mainWindow = new BrowserWindow({
width: 1200,
height: 700,
center: true
});
*/

let mainWindowState = windowStateKeeper({
defaultWidth: 1200,
defaultHeight: 700
});

mainWindow = new BrowserWindow({
'x': mainWindowState.x,
'y': mainWindowState.y,
'width': mainWindowState.width,
'height': mainWindowState.height
});

mainWindowState.manage(mainWindow);

mainWindow.loadURL(url.format({
pathname: 'bandcamp.com',
protocol: 'https:',
Expand Down
66 changes: 37 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
"cheerio": "^1.0.0-rc.3",
"electron-download-manager": "^2.1.2",
"electron-updater": "^4.3.4",
"electron-window-state": "^5.0.3",
"is-online": "^8.4.0",
"request": "^2.88.2",
"unzipper": "^0.10.11",
"url": "^0.11.0"
},
"devDependencies": {
"electron": "^9.1.2",
"electron": "^9.3.0",
"electron-builder": "^22.8.0"
},
"build": {
Expand Down

0 comments on commit d6ba663

Please sign in to comment.