mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-12-23 02:28:55 +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",
|
||||
"main": "lib/main.js",
|
||||
"dependencies": {
|
||||
"electron-window-state": "^2.0.0",
|
||||
"wurl": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
|
@ -1,8 +1,8 @@
|
||||
var path = require('path');
|
||||
var electron = require('electron');
|
||||
var windowStateKeeper = require('electron-window-state');
|
||||
var helpers = require('./../../helpers/helpers');
|
||||
var createMenu = require('./../menu/menu');
|
||||
|
||||
var BrowserWindow = electron.BrowserWindow;
|
||||
var shell = electron.shell;
|
||||
var isOSX = helpers.isOSX;
|
||||
@ -18,10 +18,16 @@ const ZOOM_INTERVAL = 0.1;
|
||||
* @returns {electron.BrowserWindow}
|
||||
*/
|
||||
function createMainWindow(options, onAppQuit, setDockBadge) {
|
||||
var mainWindowState = windowStateKeeper({
|
||||
defaultWidth: options.width || 1280,
|
||||
defaultHeight: options.height || 800
|
||||
});
|
||||
var mainWindow = new BrowserWindow(
|
||||
{
|
||||
width: options.width || 1280,
|
||||
height: options.height || 800,
|
||||
width: mainWindowState.width,
|
||||
height: mainWindowState.height,
|
||||
x: mainWindowState.x,
|
||||
y: mainWindowState.y,
|
||||
title: options.name,
|
||||
'web-preferences': {
|
||||
javascript: true,
|
||||
@ -29,7 +35,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
||||
nodeIntegration: false,
|
||||
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)
|
||||
});
|
||||
|
||||
mainWindowState.manage(mainWindow);
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ var electron = require('electron');
|
||||
var createMainWindow = require('./components/mainWindow/mainWindow');
|
||||
var createLoginWindow = require('./components/login/loginWindow');
|
||||
var helpers = require('./helpers/helpers');
|
||||
|
||||
var app = electron.app;
|
||||
var ipcMain = electron.ipcMain;
|
||||
var isOSX = helpers.isOSX;
|
||||
@ -66,6 +65,5 @@ ipcMain.on('notification', function(event, title, opts) {
|
||||
if (!isOSX() || mainWindow.isFocused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDockBadge('●');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user