mirror of https://github.com/keeweb/keeweb.git
electron v1.0.1
This commit is contained in:
parent
31db0aa594
commit
6cb2693c02
|
@ -16,7 +16,7 @@ module.exports = function(grunt) {
|
|||
var webpack = require('webpack');
|
||||
var pkg = require('./package.json');
|
||||
var dt = new Date().toISOString().replace(/T.*/, '');
|
||||
var minElectronVersionForUpdate = '0.32.0';
|
||||
var minElectronVersionForUpdate = '1.0.1';
|
||||
var zipCommentPlaceholder = 'zip_comment_placeholder_that_will_be_replaced_with_hash';
|
||||
var electronVersion = pkg.devDependencies['electron-prebuilt'].replace(/^\D/, '');
|
||||
|
||||
|
|
|
@ -14,19 +14,25 @@ if (window.process && window.process.versions && window.process.versions.electro
|
|||
name: 'electron',
|
||||
version: window.process.versions.electron,
|
||||
req: window.require,
|
||||
electron: function() {
|
||||
return this.req('electron');
|
||||
},
|
||||
remoteApp: function() {
|
||||
return this.electron().remote.app;
|
||||
},
|
||||
remReq: function(mod) {
|
||||
return this.req('remote').require(mod);
|
||||
return this.electron().remote.require(mod);
|
||||
},
|
||||
openLink: function(href) {
|
||||
this.req('shell').openExternal(href);
|
||||
this.electron().shell.openExternal(href);
|
||||
},
|
||||
devTools: true,
|
||||
openDevTools: function() {
|
||||
this.req('remote').getCurrentWindow().openDevTools();
|
||||
this.electron().remote.getCurrentWindow().openDevTools();
|
||||
},
|
||||
getSaveFileName: function(defaultPath, cb) {
|
||||
if (defaultPath) {
|
||||
var homePath = this.remReq('app').getPath('userDesktop');
|
||||
var homePath = this.remReq('electron').app.getPath('userDesktop');
|
||||
defaultPath = this.req('path').join(homePath, defaultPath);
|
||||
}
|
||||
this.remReq('dialog').showSaveDialog({
|
||||
|
@ -36,10 +42,10 @@ if (window.process && window.process.versions && window.process.versions.electro
|
|||
}, cb);
|
||||
},
|
||||
getUserDataPath: function(fileName) {
|
||||
return this.req('path').join(this.remReq('app').getPath('userData'), fileName || '');
|
||||
return this.req('path').join(this.remoteApp().getPath('userData'), fileName || '');
|
||||
},
|
||||
getTempPath: function(fileName) {
|
||||
return this.req('path').join(this.remReq('app').getPath('temp'), fileName || '');
|
||||
return this.req('path').join(this.remoteApp().getPath('temp'), fileName || '');
|
||||
},
|
||||
getAppPath: function(fileName) {
|
||||
return this.req('path').join(__dirname, fileName || '');
|
||||
|
@ -76,7 +82,7 @@ if (window.process && window.process.versions && window.process.versions.electro
|
|||
this.requestExit();
|
||||
},
|
||||
requestExit: function() {
|
||||
var app = this.remReq('app');
|
||||
var app = this.remoteApp();
|
||||
if (this.restartPending) {
|
||||
app.restartApp();
|
||||
} else {
|
||||
|
@ -91,25 +97,25 @@ if (window.process && window.process.versions && window.process.versions.electro
|
|||
this.restartPending = false;
|
||||
},
|
||||
setClipboardText: function(text) {
|
||||
return this.req('clipboard').writeText(text);
|
||||
return this.electron().clipboard.writeText(text);
|
||||
},
|
||||
getClipboardText: function() {
|
||||
return this.req('clipboard').readText();
|
||||
return this.electron().clipboard.readText();
|
||||
},
|
||||
clearClipboardText: function() {
|
||||
return this.req('clipboard').clear();
|
||||
return this.electron().clipboard.clear();
|
||||
},
|
||||
minimizeApp: function() {
|
||||
this.remReq('app').minimizeApp();
|
||||
this.remoteApp().minimizeApp();
|
||||
},
|
||||
canMinimize: function() {
|
||||
return process.platform !== 'darwin';
|
||||
},
|
||||
updaterEnabled: function() {
|
||||
return this.req('remote').process.argv.indexOf('--disable-updater') === -1;
|
||||
return this.electron().remote.process.argv.indexOf('--disable-updater') === -1;
|
||||
},
|
||||
resolveProxy: function(url, callback) {
|
||||
var window = this.remReq('app').getMainWindow();
|
||||
var window = this.remoteApp().getMainWindow();
|
||||
var session = window.webContents.session;
|
||||
session.resolveProxy(url, function(proxy) {
|
||||
var match = /^proxy\s+([\w\.]+):(\d+)+\s*/i.exec(proxy);
|
||||
|
@ -118,10 +124,10 @@ if (window.process && window.process.versions && window.process.versions.electro
|
|||
});
|
||||
},
|
||||
openWindow: function(opts) {
|
||||
return this.remReq('app').openWindow(opts);
|
||||
return this.remoteApp().openWindow(opts);
|
||||
},
|
||||
hideWindowIfActive: function() {
|
||||
var app = this.remReq('app');
|
||||
var app = this.remoteApp();
|
||||
var win = app.getMainWindow();
|
||||
var visible = win.isVisible(), focused = win.isFocused();
|
||||
if (!visible || !focused) {
|
||||
|
|
|
@ -3,13 +3,10 @@
|
|||
/* jshint node:true */
|
||||
/* jshint browser:false */
|
||||
|
||||
var app = require('app'),
|
||||
var electron = require('electron'),
|
||||
app = electron.app,
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
BrowserWindow = require('browser-window'),
|
||||
Menu = require('menu'),
|
||||
Tray = require('tray'),
|
||||
globalShortcut = require('electron').globalShortcut;
|
||||
fs = require('fs');
|
||||
|
||||
var mainWindow = null,
|
||||
appIcon = null,
|
||||
|
@ -31,7 +28,7 @@ if (!handleStartupSquirrelEvent()) {
|
|||
app.on('window-all-closed', function () {
|
||||
if (restartPending) {
|
||||
// unbind all handlers, load new app.js module and pass control to it
|
||||
globalShortcut.unregisterAll();
|
||||
electron.globalShortcut.unregisterAll();
|
||||
app.removeAllListeners('window-all-closed');
|
||||
app.removeAllListeners('ready');
|
||||
app.removeAllListeners('open-file');
|
||||
|
@ -66,7 +63,7 @@ if (!handleStartupSquirrelEvent()) {
|
|||
}
|
||||
});
|
||||
app.on('will-quit', function () {
|
||||
globalShortcut.unregisterAll();
|
||||
electron.globalShortcut.unregisterAll();
|
||||
});
|
||||
app.restartApp = function () {
|
||||
restartPending = true;
|
||||
|
@ -76,15 +73,15 @@ if (!handleStartupSquirrelEvent()) {
|
|||
}, 1000);
|
||||
};
|
||||
app.openWindow = function (opts) {
|
||||
return new BrowserWindow(opts);
|
||||
return new electron.BrowserWindow(opts);
|
||||
};
|
||||
app.minimizeApp = function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
mainWindow.minimize();
|
||||
mainWindow.setSkipTaskbar(true);
|
||||
appIcon = new Tray(path.join(__dirname, 'icon.png'));
|
||||
appIcon = new electron.Tray(path.join(__dirname, 'icon.png'));
|
||||
appIcon.on('click', restoreMainWindow);
|
||||
var contextMenu = Menu.buildFromTemplate([
|
||||
var contextMenu = electron.Menu.buildFromTemplate([
|
||||
{label: 'Open KeeWeb', click: restoreMainWindow},
|
||||
{label: 'Quit KeeWeb', click: closeMainWindow}
|
||||
]);
|
||||
|
@ -113,7 +110,7 @@ function setAppOptions() {
|
|||
}
|
||||
|
||||
function createMainWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
mainWindow = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 1000, height: 700, 'min-width': 700, 'min-height': 400,
|
||||
icon: path.join(__dirname, 'icon.png')
|
||||
|
@ -189,7 +186,7 @@ function updateMainWindowPosition() {
|
|||
}
|
||||
mainWindowPosition.maximized = mainWindow.isMaximized();
|
||||
mainWindowPosition.fullScreen = mainWindow.isFullScreen();
|
||||
mainWindowPosition.displayBounds = require('screen').getDisplayMatching(bounds).bounds;
|
||||
mainWindowPosition.displayBounds = require('electron').screen.getDisplayMatching(bounds).bounds;
|
||||
mainWindowPosition.changed = true;
|
||||
}
|
||||
|
||||
|
@ -209,7 +206,7 @@ function restoreMainWindowPosition() {
|
|||
mainWindowPosition = JSON.parse(data);
|
||||
if (mainWindow && mainWindowPosition) {
|
||||
if (mainWindowPosition.width && mainWindowPosition.height) {
|
||||
var displayBounds = require('screen').getDisplayMatching(mainWindowPosition).bounds;
|
||||
var displayBounds = require('electron').screen.getDisplayMatching(mainWindowPosition).bounds;
|
||||
var db = mainWindowPosition.displayBounds;
|
||||
if (displayBounds.x === db.x && displayBounds.y === db.y &&
|
||||
displayBounds.width === db.width && displayBounds.height === db.height) {
|
||||
|
@ -229,7 +226,7 @@ function emitBackboneEvent(e) {
|
|||
|
||||
function setMenu() {
|
||||
if (process.platform === 'darwin') {
|
||||
var name = require('app').getName();
|
||||
var name = require('electron').app.getName();
|
||||
var template = [
|
||||
{
|
||||
label: name,
|
||||
|
@ -258,8 +255,8 @@ function setMenu() {
|
|||
]
|
||||
}
|
||||
];
|
||||
var menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
var menu = electron.Menu.buildFromTemplate(template);
|
||||
electron.Menu.setApplicationMenu(menu);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,7 +281,7 @@ function setGlobalShortcuts() {
|
|||
var shortcut = shortcutModifiers + key;
|
||||
var eventName = shortcuts[key];
|
||||
try {
|
||||
globalShortcut.register(shortcut, function () {
|
||||
electron.globalShortcut.register(shortcut, function () {
|
||||
emitBackboneEvent(eventName);
|
||||
});
|
||||
} catch (e) {}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/* jshint node:true */
|
||||
/* jshint browser:false */
|
||||
|
||||
var app = require('app'),
|
||||
var app = require('electron').app,
|
||||
path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
var builder = require('electron-builder');
|
||||
var macPackager = require('electron-builder/out/macPackager');
|
||||
var osxPackager = require('electron-builder/out/osxPackager');
|
||||
var platformPackager = require('electron-builder/out/platformPackager');
|
||||
var linuxPackager = require('electron-builder/out/linuxPackager');
|
||||
var plist = require('plist');
|
||||
|
||||
var version;
|
||||
|
||||
// workaround for https://github.com/electron-userland/electron-builder/issues/322
|
||||
macPackager.default.prototype.zipMacApp = function() {
|
||||
osxPackager.default.prototype.zipMacApp = function() {
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
|
@ -30,7 +29,6 @@ linuxPackager.LinuxPackager.prototype.createFromIcns = function() {
|
|||
module.exports = function (grunt) {
|
||||
grunt.registerMultiTask('electron-builder', 'Create app installer with electron-builder', function () {
|
||||
version = grunt.config.get('gitinfo.local.branch.current.shortSHA');
|
||||
console.log();
|
||||
var done = this.async();
|
||||
builder.build(this.options())
|
||||
.then(function () { done(); })
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"base64-loader": "^1.0.0",
|
||||
"cssnano": "^3.3.2",
|
||||
"electron-builder": "^3.5.2",
|
||||
"electron-prebuilt": "^0.37.4",
|
||||
"electron-prebuilt": "^1.0.1",
|
||||
"exports-loader": "^0.6.2",
|
||||
"get-folder-size": "^1.0.0",
|
||||
"grunt": "^0.4.5",
|
||||
|
|
Loading…
Reference in New Issue