2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-16 01:37:07 +00:00

Integrate window state manager with BrowserWindow

This commit is contained in:
zweicoder 2016-01-23 14:52:13 +08:00
parent 09777f38c8
commit 1685407e7a
2 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@ var path = require('path');
var electron = require('electron'); var electron = require('electron');
var helpers = require('./../../helpers/helpers'); var helpers = require('./../../helpers/helpers');
var createMenu = require('./../menu/menu'); var createMenu = require('./../menu/menu');
var windowStateKeeper = require('electron-window-state');
var BrowserWindow = electron.BrowserWindow; var BrowserWindow = electron.BrowserWindow;
var shell = electron.shell; var shell = electron.shell;
var isOSX = helpers.isOSX; var isOSX = helpers.isOSX;
@ -18,10 +18,16 @@ const ZOOM_INTERVAL = 0.1;
* @returns {electron.BrowserWindow} * @returns {electron.BrowserWindow}
*/ */
function createMainWindow(options, onAppQuit, setDockBadge) { function createMainWindow(options, onAppQuit, setDockBadge) {
var mainWindowState = windowStateKeeper({
defaultWidth: options.width || 1280,
defaultHeight: options.height || 800
});
var mainWindow = new BrowserWindow( var mainWindow = new BrowserWindow(
{ {
width: options.width || 1280, width: mainWindowState.width,
height: options.height || 800, height: mainWindowState.height,
x: mainWindowState.x,
y: mainWindowState.y,
'web-preferences': { 'web-preferences': {
javascript: true, javascript: true,
plugins: true, plugins: true,
@ -99,6 +105,8 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
} }
}); });
mainWindowState.manage(mainWindow);
return mainWindow; return mainWindow;
} }

View File

@ -8,7 +8,6 @@ var electron = require('electron');
var createMainWindow = require('./components/mainWindow/mainWindow'); var createMainWindow = require('./components/mainWindow/mainWindow');
var createLoginWindow = require('./components/login/loginWindow'); var createLoginWindow = require('./components/login/loginWindow');
var helpers = require('./helpers/helpers'); var helpers = require('./helpers/helpers');
var windowStateKeeper = require('electron-window-state');
var app = electron.app; var app = electron.app;
var ipcMain = electron.ipcMain; var ipcMain = electron.ipcMain;
var isOSX = helpers.isOSX; var isOSX = helpers.isOSX;
@ -47,12 +46,7 @@ app.on('before-quit', function () {
}); });
app.on('ready', function () { app.on('ready', function () {
var mainWindowState = windowStateKeeper({
defaultWidth: appArgs.width || 1280,
defaultHeight: appArgs.height || 800
});
mainWindow = createMainWindow(appArgs, app.quit, app.dock.setBadge); mainWindow = createMainWindow(appArgs, app.quit, app.dock.setBadge);
mainWindowState.manage(mainWindow);
}); });
app.on('login', function(event, webContents, request, authInfo, callback) { app.on('login', function(event, webContents, request, authInfo, callback) {