From fc2d8727465084b008363819b788624111fd53e4 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 24 Mar 2018 23:23:25 +0900 Subject: [PATCH] refs #119 Save window state --- package-lock.json | 14 +++++++++++--- package.json | 1 + src/main/index.js | 12 ++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8bb4d3851d..8fe2ed9bf4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3647,8 +3647,7 @@ "deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", - "dev": true + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=" }, "deep-extend": { "version": "0.4.2", @@ -4465,6 +4464,16 @@ "integrity": "sha1-Dqv3Gp6+qQE/scw1o5DgaGJPJ+g=", "dev": true }, + "electron-window-state": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/electron-window-state/-/electron-window-state-4.1.1.tgz", + "integrity": "sha1-azT9wxs4UU3+yLfI97XUrdtnYy0=", + "requires": { + "deep-equal": "1.0.1", + "jsonfile": "2.4.0", + "mkdirp": "0.5.1" + } + }, "element-ui": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.2.1.tgz", @@ -8800,7 +8809,6 @@ "version": "2.4.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, "requires": { "graceful-fs": "4.1.11" } diff --git a/package.json b/package.json index 6dd3ff5e6d..dcf0715bb5 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "dependencies": { "axios": "^0.18.0", "electron-log": "^2.2.14", + "electron-window-state": "^4.1.1", "element-ui": "^2.2.1", "google-fonts-webpack-plugin": "^0.4.4", "is-empty": "^1.2.0", diff --git a/src/main/index.js b/src/main/index.js index dfd8cdda62..d0bc2511b3 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -4,6 +4,7 @@ import { app, ipcMain, BrowserWindow, shell, Menu } from 'electron' import Datastore from 'nedb' import empty from 'is-empty' import log from 'electron-log' +import windowStateKeeper from 'electron-window-state' import Authentication from './auth' import Account from './account' @@ -170,13 +171,20 @@ function createWindow () { /** * Initial window options */ + let mainWindowState = windowStateKeeper({ + defaultWidth: 1000, + height: 563 + }) mainWindow = new BrowserWindow({ titleBarStyle: 'hidden', - height: 563, + x: mainWindowState.x, + y: mainWindowState.y, + width: mainWindowState.width, + height: mainWindowState.height, useContentSize: true, - width: 1000, icon: require('path').join(__dirname, '../../build/icons/256x256.png') }) + mainWindowState.manage(mainWindow) mainWindow.loadURL(winURL)