mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-11 09:35:16 +00:00
Close #62 Merge branch 'zweicoder-feature/window-state-manager'
This commit is contained in:
commit
b7433dfc3b
@ -4,6 +4,7 @@
|
|||||||
"description": "Placeholder for the nativefier cli to override with a target url",
|
"description": "Placeholder for the nativefier cli to override with a target url",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"electron-window-state": "^2.0.0",
|
||||||
"wurl": "^2.1.0"
|
"wurl": "^2.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
var electron = require('electron');
|
var electron = require('electron');
|
||||||
|
var windowStateKeeper = require('electron-window-state');
|
||||||
var helpers = require('./../../helpers/helpers');
|
var helpers = require('./../../helpers/helpers');
|
||||||
var createMenu = require('./../menu/menu');
|
var createMenu = require('./../menu/menu');
|
||||||
|
|
||||||
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,
|
||||||
title: options.name,
|
title: options.name,
|
||||||
'web-preferences': {
|
'web-preferences': {
|
||||||
javascript: true,
|
javascript: true,
|
||||||
@ -29,7 +35,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
preload: path.join(__dirname, 'static', 'preload.js')
|
preload: path.join(__dirname, 'static', 'preload.js')
|
||||||
},
|
},
|
||||||
icon: options.icon || path.join(__dirname,'/icon.png') // hardcoded by default until you decide how to pass in an icon
|
icon: options.icon || path.join(__dirname, '/icon.png') // hardcoded by default until you decide how to pass in an icon
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -97,6 +103,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
maybeHideWindow(mainWindow, event)
|
maybeHideWindow(mainWindow, event)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindowState.manage(mainWindow);
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 app = electron.app;
|
var app = electron.app;
|
||||||
var ipcMain = electron.ipcMain;
|
var ipcMain = electron.ipcMain;
|
||||||
var isOSX = helpers.isOSX;
|
var isOSX = helpers.isOSX;
|
||||||
@ -66,6 +65,5 @@ ipcMain.on('notification', function(event, title, opts) {
|
|||||||
if (!isOSX() || mainWindow.isFocused()) {
|
if (!isOSX() || mainWindow.isFocused()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDockBadge('●');
|
setDockBadge('●');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user