mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
add linting (#27)
This commit is contained in:
parent
40e6b173af
commit
71387c1dce
6
.eslintignore
Normal file
6
.eslintignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
build
|
||||||
|
config
|
||||||
|
coverage
|
||||||
|
dist
|
||||||
|
installer
|
||||||
|
node_modules
|
30
.eslintrc
Normal file
30
.eslintrc
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"airbnb-base/rules/best-practices",
|
||||||
|
"airbnb-base/rules/errors",
|
||||||
|
"airbnb-base/rules/node",
|
||||||
|
"airbnb-base/rules/strict",
|
||||||
|
"airbnb-base/rules/variables"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"comma-dangle": 0,
|
||||||
|
"vars-on-top": 0,
|
||||||
|
"one-var": 0,
|
||||||
|
"indent": [ 2, 4, {
|
||||||
|
"SwitchCase": 1
|
||||||
|
} ],
|
||||||
|
"space-in-parens": 0,
|
||||||
|
"func-names" : 0,
|
||||||
|
"eol-last": 0,
|
||||||
|
"no-use-before-define": 0,
|
||||||
|
"strict": 0
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"SYM_API": true
|
||||||
|
}
|
||||||
|
}
|
@ -21,8 +21,8 @@ electron.app.on('certificate-error', function(event, webContents, url, error,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let browserWin = electron.BrowserWindow.fromWebContents(webContents);
|
const browserWin = electron.BrowserWindow.fromWebContents(webContents);
|
||||||
var buttonId = electron.dialog.showMessageBox(browserWin, {
|
const buttonId = electron.dialog.showMessageBox(browserWin, {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
buttons: [ 'Allow', 'Deny', 'Ignore All' ],
|
buttons: [ 'Allow', 'Deny', 'Ignore All' ],
|
||||||
defaultId: 1,
|
defaultId: 1,
|
||||||
|
@ -34,7 +34,7 @@ function getConfig() {
|
|||||||
configPath = path.join(execPath, isMac ? '..' : '', configFile);
|
configPath = path.join(execPath, isMac ? '..' : '', configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile(configPath, 'utf8', function (err, data) {
|
fs.readFile(configPath, 'utf8', function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject('cannot open config file: ' + configPath + ', error: ' + err);
|
reject('cannot open config file: ' + configPath + ', error: ' + err);
|
||||||
} else {
|
} else {
|
||||||
@ -42,7 +42,7 @@ function getConfig() {
|
|||||||
// data is the contents of the text file we just read
|
// data is the contents of the text file we just read
|
||||||
let config = JSON.parse(data);
|
let config = JSON.parse(data);
|
||||||
resolve(config);
|
resolve(config);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
reject('can not parse config file data: ' + data + ', error: ' + err);
|
reject('can not parse config file data: ' + data + ', error: ' + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
const nodeURL = require('url');
|
const nodeURL = require('url');
|
||||||
|
const squirrelStartup = require('electron-squirrel-startup');
|
||||||
|
|
||||||
const getConfig = require('./getConfig.js');
|
const getConfig = require('./getConfig.js');
|
||||||
const { isMac } = require('./utils.js');
|
const { isMac } = require('./utils.js');
|
||||||
|
|
||||||
// exit early for squirrel installer
|
// exit early for squirrel installer
|
||||||
if (require('electron-squirrel-startup')) {
|
if (squirrelStartup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ function getUrlAndOpenMainWindow() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function() {
|
||||||
// On OS X it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (!isMac) {
|
if (!isMac) {
|
||||||
@ -53,7 +55,7 @@ app.on('window-all-closed', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function() {
|
||||||
if (windowMgr.isMainWindow(null)) {
|
if (windowMgr.isMainWindow(null)) {
|
||||||
getUrlAndOpenMainWindow();
|
getUrlAndOpenMainWindow();
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
* from the renderer process.
|
* from the renderer process.
|
||||||
*/
|
*/
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const windowMgr = require('./windowMgr.js');
|
const windowMgr = require('./windowMgr.js');
|
||||||
const log = require('./log.js');
|
const log = require('./log.js');
|
||||||
@ -18,8 +17,8 @@ const log = require('./log.js');
|
|||||||
function isValidWindow(event) {
|
function isValidWindow(event) {
|
||||||
if (event && event.sender) {
|
if (event && event.sender) {
|
||||||
// validate that event sender is from window we created
|
// validate that event sender is from window we created
|
||||||
let browserWin = electron.BrowserWindow.fromWebContents(event.sender);
|
const browserWin = electron.BrowserWindow.fromWebContents(event.sender);
|
||||||
let winKey = event.sender.browserWindowOptions &&
|
const winKey = event.sender.browserWindowOptions &&
|
||||||
event.sender.browserWindowOptions.webPreferences &&
|
event.sender.browserWindowOptions.webPreferences &&
|
||||||
event.sender.browserWindowOptions.webPreferences.winKey;
|
event.sender.browserWindowOptions.webPreferences.winKey;
|
||||||
|
|
||||||
@ -43,14 +42,14 @@ function isCmdAllowed(event, cmd) {
|
|||||||
// validate that event sender is from window we created
|
// validate that event sender is from window we created
|
||||||
let browserWin = electron.BrowserWindow.fromWebContents(event.sender);
|
let browserWin = electron.BrowserWindow.fromWebContents(event.sender);
|
||||||
|
|
||||||
if (windowMgr.isMainWindow(browserWin)) {
|
if (!windowMgr.isMainWindow(browserWin)) {
|
||||||
// allow all commands for main window
|
// allow all commands for main window
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
// allow only certain cmds for child windows
|
|
||||||
// e.g., open cmd not allowed for child windows
|
|
||||||
return (cmdBlackList.indexOf(cmd) === -1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allow only certain cmds for child windows
|
||||||
|
// e.g., open cmd not allowed for child windows
|
||||||
|
return (cmdBlackList.indexOf(cmd) === -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -62,12 +61,16 @@ function isCmdAllowed(event, cmd) {
|
|||||||
*/
|
*/
|
||||||
electron.ipcMain.on('symphony-api', (event, arg) => {
|
electron.ipcMain.on('symphony-api', (event, arg) => {
|
||||||
if (!isValidWindow(event)) {
|
if (!isValidWindow(event)) {
|
||||||
|
/* eslint-disable no-console */
|
||||||
console.log('invalid window try to perform action, ignoring action.');
|
console.log('invalid window try to perform action, ignoring action.');
|
||||||
|
/* eslint-enable no-console */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCmdAllowed(event, arg && arg.cmd)) {
|
if (!isCmdAllowed(event, arg && arg.cmd)) {
|
||||||
|
/* eslint-disable no-console */
|
||||||
console.log('cmd not allowed for this window: ' + arg.cmd);
|
console.log('cmd not allowed for this window: ' + arg.cmd);
|
||||||
|
/* eslint-enable no-console */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +94,5 @@ electron.ipcMain.on('symphony-api', (event, arg) => {
|
|||||||
let width = arg.width || 1024;
|
let width = arg.width || 1024;
|
||||||
let height = arg.height || 768;
|
let height = arg.height || 768;
|
||||||
windowMgr.createChildWindow(arg.url, title, width, height);
|
windowMgr.createChildWindow(arg.url, title, width, height);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const electron = require('electron');
|
|
||||||
const log = require('./log.js');
|
const log = require('./log.js');
|
||||||
const logLevels = require('./enums/logLevels.js')
|
const logLevels = require('./enums/logLevels.js')
|
||||||
|
|
||||||
|
@ -1,177 +1,161 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const electron = require('electron');
|
||||||
|
|
||||||
const template = [
|
const template = [
|
||||||
{
|
{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{ role: 'undo' },
|
||||||
role: 'undo'
|
{ role: 'redo' },
|
||||||
},
|
{ type: 'separator' },
|
||||||
{
|
{ role: 'cut' },
|
||||||
role: 'redo'
|
{ role: 'copy' },
|
||||||
},
|
{ role: 'paste' },
|
||||||
{
|
{ role: 'pasteandmatchstyle' },
|
||||||
type: 'separator'
|
{ role: 'delete' },
|
||||||
},
|
{ role: 'selectall' }
|
||||||
{
|
]
|
||||||
role: 'cut'
|
},
|
||||||
},
|
{
|
||||||
{
|
label: 'View',
|
||||||
role: 'copy'
|
submenu: [
|
||||||
},
|
{
|
||||||
{
|
label: 'Reload',
|
||||||
role: 'paste'
|
accelerator: 'CmdOrCtrl+R',
|
||||||
},
|
click (item, focusedWindow) {
|
||||||
{
|
if (focusedWindow) {
|
||||||
role: 'pasteandmatchstyle'
|
focusedWindow.reload();
|
||||||
},
|
}
|
||||||
{
|
}
|
||||||
role: 'delete'
|
},
|
||||||
},
|
{
|
||||||
{
|
label: 'Toggle Developer Tools',
|
||||||
role: 'selectall'
|
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||||
}
|
click (item, focusedWindow) {
|
||||||
]
|
if (focusedWindow) {
|
||||||
},
|
focusedWindow.webContents.toggleDevTools();
|
||||||
{
|
}
|
||||||
label: 'View',
|
}
|
||||||
submenu: [
|
},
|
||||||
{
|
{
|
||||||
label: 'Reload',
|
type: 'separator'
|
||||||
accelerator: 'CmdOrCtrl+R',
|
},
|
||||||
click (item, focusedWindow) {
|
{
|
||||||
if (focusedWindow) {
|
role: 'resetzoom'
|
||||||
focusedWindow.reload();
|
},
|
||||||
}
|
{
|
||||||
}
|
role: 'zoomin'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle Developer Tools',
|
role: 'zoomout'
|
||||||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
},
|
||||||
click (item, focusedWindow) {
|
{
|
||||||
if (focusedWindow) {
|
type: 'separator'
|
||||||
focusedWindow.webContents.toggleDevTools();
|
},
|
||||||
}
|
{
|
||||||
}
|
role: 'togglefullscreen'
|
||||||
},
|
}
|
||||||
{
|
]
|
||||||
type: 'separator'
|
},
|
||||||
},
|
{
|
||||||
{
|
role: 'window',
|
||||||
role: 'resetzoom'
|
submenu: [
|
||||||
},
|
{
|
||||||
{
|
role: 'minimize'
|
||||||
role: 'zoomin'
|
},
|
||||||
},
|
{
|
||||||
{
|
role: 'close'
|
||||||
role: 'zoomout'
|
}
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
type: 'separator'
|
{
|
||||||
},
|
role: 'help',
|
||||||
{
|
submenu: [
|
||||||
role: 'togglefullscreen'
|
{
|
||||||
}
|
label: 'Learn More',
|
||||||
]
|
click () { electron.shell.openExternal('https://www.symphony.com') }
|
||||||
},
|
}
|
||||||
{
|
]
|
||||||
role: 'window',
|
}
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
role: 'minimize'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
role: 'close'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
role: 'help',
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: 'Learn More',
|
|
||||||
click () { require('electron').shell.openExternal('https://www.symphony.com') }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function getTemplate(app) {
|
function getTemplate(app) {
|
||||||
if (process.platform === 'darwin' && template[0].label !== app.getName()) {
|
if (process.platform === 'darwin' && template[0].label !== app.getName()) {
|
||||||
template.unshift({
|
template.unshift({
|
||||||
label: app.getName(),
|
label: app.getName(),
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
role: 'about'
|
role: 'about'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'services',
|
role: 'services',
|
||||||
submenu: []
|
submenu: []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'hide'
|
role: 'hide'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'hideothers'
|
role: 'hideothers'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'unhide'
|
role: 'unhide'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'quit'
|
role: 'quit'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
// Edit menu.
|
// Edit menu.
|
||||||
template[1].submenu.push(
|
template[1].submenu.push(
|
||||||
{
|
|
||||||
type: 'separator'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Speech',
|
|
||||||
submenu: [
|
|
||||||
{
|
{
|
||||||
role: 'startspeaking'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'stopspeaking'
|
label: 'Speech',
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
role: 'startspeaking'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'stopspeaking'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
// Window menu.
|
// Window menu.
|
||||||
template[3].submenu = [
|
template[3].submenu = [
|
||||||
{
|
{
|
||||||
label: 'Close',
|
label: 'Close',
|
||||||
accelerator: 'CmdOrCtrl+W',
|
accelerator: 'CmdOrCtrl+W',
|
||||||
role: 'close'
|
role: 'close'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Minimize',
|
label: 'Minimize',
|
||||||
accelerator: 'CmdOrCtrl+M',
|
accelerator: 'CmdOrCtrl+M',
|
||||||
role: 'minimize'
|
role: 'minimize'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Zoom',
|
label: 'Zoom',
|
||||||
role: 'zoom'
|
role: 'zoom'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Bring All to Front',
|
label: 'Bring All to Front',
|
||||||
role: 'front'
|
role: 'front'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
|
@ -25,7 +25,8 @@ const api = 'symphony-api';
|
|||||||
// Note: certain cmds are only allowed on some windows, this is checked by
|
// Note: certain cmds are only allowed on some windows, this is checked by
|
||||||
// main process.
|
// main process.
|
||||||
window.SYM_API = {
|
window.SYM_API = {
|
||||||
version: '1.0.0', // api version
|
// api version
|
||||||
|
version: '1.0.0',
|
||||||
|
|
||||||
// only allowed by main window - enforced by main process.
|
// only allowed by main window - enforced by main process.
|
||||||
openWindow: function(url) {
|
openWindow: function(url) {
|
||||||
@ -60,7 +61,6 @@ window.SYM_API = {
|
|||||||
|
|
||||||
// listen for log message from main process
|
// listen for log message from main process
|
||||||
local.ipcRenderer.on('log', (event, arg) => {
|
local.ipcRenderer.on('log', (event, arg) => {
|
||||||
console.log('got msg:' + arg)
|
|
||||||
if (local.logger && arg && arg.level && arg.msg) {
|
if (local.logger && arg && arg.level && arg.msg) {
|
||||||
local.logger({
|
local.logger({
|
||||||
logLevel: arg.level,
|
logLevel: arg.level,
|
||||||
@ -72,7 +72,7 @@ local.ipcRenderer.on('log', (event, arg) => {
|
|||||||
function updateOnlineStatus() {
|
function updateOnlineStatus() {
|
||||||
local.ipcRenderer.send(api, {
|
local.ipcRenderer.send(api, {
|
||||||
cmd: 'isOnline',
|
cmd: 'isOnline',
|
||||||
isOnline: navigator.onLine
|
isOnline: window.navigator.onLine
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const isDevEnv = process.env.ELECTRON_DEV ?
|
const isDevEnv = process.env.ELECTRON_DEV ?
|
||||||
process.env.ELECTRON_DEV.trim().toLowerCase() === "true" : false;
|
process.env.ELECTRON_DEV.trim().toLowerCase() === 'true' : false;
|
||||||
|
|
||||||
const isMac = (process.platform === 'darwin');
|
const isMac = (process.platform === 'darwin');
|
||||||
|
|
||||||
@ -12,11 +12,11 @@ const isMac = (process.platform === 'darwin');
|
|||||||
* @return {String} guid value in string
|
* @return {String} guid value in string
|
||||||
*/
|
*/
|
||||||
function getGuid() {
|
function getGuid() {
|
||||||
var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
const guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
||||||
function(c) {
|
function(c) {
|
||||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
return guid;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@ let isOnline = true;
|
|||||||
const preloadScript = path.join(__dirname, '/RendererPreload.js');
|
const preloadScript = path.join(__dirname, '/RendererPreload.js');
|
||||||
|
|
||||||
function addWindowKey(key, browserWin) {
|
function addWindowKey(key, browserWin) {
|
||||||
windows[key] = browserWin;
|
windows[ key ] = browserWin;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWindowKey(key) {
|
function removeWindowKey(key) {
|
||||||
delete windows[key];
|
delete windows[ key ];
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMainWindow (url) {
|
function createMainWindow(url) {
|
||||||
let key = getGuid();
|
let key = getGuid();
|
||||||
|
|
||||||
mainWindow = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
@ -45,10 +45,13 @@ function createMainWindow (url) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function retry() {
|
function retry() {
|
||||||
if (isOnline) {
|
if (!isOnline) {
|
||||||
mainWindow.webContents && mainWindow.webContents.reload();
|
|
||||||
} else {
|
|
||||||
loadErrors.showNetworkConnectivityError(mainWindow, url, retry);
|
loadErrors.showNetworkConnectivityError(mainWindow, url, retry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainWindow.webContents) {
|
||||||
|
mainWindow.webContents.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +66,7 @@ function createMainWindow (url) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.webContents.on('did-fail-load', function(event, errorCode,
|
mainWindow.webContents.on('did-fail-load', function(event, errorCode,
|
||||||
errorDesc, validatedURL, isMainFrame) {
|
errorDesc) {
|
||||||
loadErrors.showLoadFailure(mainWindow, url, errorDesc, errorCode, retry);
|
loadErrors.showLoadFailure(mainWindow, url, errorDesc, errorCode, retry);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -75,7 +78,7 @@ function createMainWindow (url) {
|
|||||||
|
|
||||||
mainWindow.on('close', function(e) {
|
mainWindow.on('close', function(e) {
|
||||||
if (willQuitApp) {
|
if (willQuitApp) {
|
||||||
mainWindow = null;
|
destroyMainWindow();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// mac should hide window when hitting x close
|
// mac should hide window when hitting x close
|
||||||
@ -85,19 +88,23 @@ function createMainWindow (url) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.on('closed', function () {
|
function destroyMainWindow() {
|
||||||
removeWindowKey(key);
|
removeWindowKey(key);
|
||||||
mainWindow.removeAllEventListeners();
|
if (mainWindow) {
|
||||||
// Dereference the window object, usually you would store windows
|
mainWindow.removeAllListeners();
|
||||||
// in an array if your app supports multi windows, this is the time
|
if (mainWindow.webContents) {
|
||||||
// when you should delete the corresponding element.
|
mainWindow.webContents.removeAllListeners();
|
||||||
mainWindow = null;
|
}
|
||||||
});
|
mainWindow = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindow.on('closed', destroyMainWindow);
|
||||||
|
|
||||||
// open external links in default browser - window.open
|
// open external links in default browser - window.open
|
||||||
mainWindow.webContents.on('new-window', function(event, url) {
|
mainWindow.webContents.on('new-window', function(event, newWinUrl) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
electron.shell.openExternal(url);
|
electron.shell.openExternal(newWinUrl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +122,7 @@ function isMainWindow(win) {
|
|||||||
|
|
||||||
function hasWindow(win, winKey) {
|
function hasWindow(win, winKey) {
|
||||||
if (win instanceof electron.BrowserWindow) {
|
if (win instanceof electron.BrowserWindow) {
|
||||||
let browserWin = windows[winKey];
|
let browserWin = windows[ winKey ];
|
||||||
return browserWin && win === browserWin;
|
return browserWin && win === browserWin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +148,13 @@ function createChildWindow(url, title, width, height) {
|
|||||||
childWindow.loadURL(url);
|
childWindow.loadURL(url);
|
||||||
|
|
||||||
childWindow.on('closed', function() {
|
childWindow.on('closed', function() {
|
||||||
childWindow.removeAllEventListeners();
|
|
||||||
removeWindowKey(winKey);
|
removeWindowKey(winKey);
|
||||||
|
if (childWindow) {
|
||||||
|
childWindow.removeAllListeners();
|
||||||
|
if (childWindow.webContents) {
|
||||||
|
childWindow.webContents.removeAllListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
package.json
23
package.json
@ -9,15 +9,19 @@
|
|||||||
"dev:mac": "ELECTRON_DEV=true npm run start",
|
"dev:mac": "ELECTRON_DEV=true npm run start",
|
||||||
"dev:win": "SET ELECTRON_DEV=true && npm run start",
|
"dev:win": "SET ELECTRON_DEV=true && npm run start",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"dist-mac": "build --mac",
|
"dist-mac": "npm run test && npm run lint && build --mac",
|
||||||
"dist-win": "build --win --x64",
|
"dist-win": "npm run test && npm run lint && build --win --x64",
|
||||||
"dist-win-x86": "build --win --ia32",
|
"dist-win-x86": "npm run test && npm run lint && build --win --ia32",
|
||||||
"unpacked-win": "build --win --x64 --dir",
|
"unpacked-win": "npm run test && npm run lint && build --win --x64 --dir",
|
||||||
"unpacked-win-x86": "build --win --ia32 --dir",
|
"unpacked-win-x86": "npm run test && npm run lint && build --win --ia32 --dir",
|
||||||
"test": "jest --coverage"
|
"test": "jest --coverage",
|
||||||
|
"lint": "eslint js/**"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"files": [ "!installer/*", "!tests/*" ],
|
"files": [
|
||||||
|
"!installer/*",
|
||||||
|
"!tests/*"
|
||||||
|
],
|
||||||
"extraFiles": "config/Symphony.config",
|
"extraFiles": "config/Symphony.config",
|
||||||
"appId": "symphony-electron-desktop",
|
"appId": "symphony-electron-desktop",
|
||||||
"mac": {
|
"mac": {
|
||||||
@ -59,6 +63,11 @@
|
|||||||
"electron-builder": "^13.9.0",
|
"electron-builder": "^13.9.0",
|
||||||
"electron-builder-squirrel-windows": "^12.3.0",
|
"electron-builder-squirrel-windows": "^12.3.0",
|
||||||
"electron-packager": "^8.5.2",
|
"electron-packager": "^8.5.2",
|
||||||
|
"eslint": "^3.16.1",
|
||||||
|
"eslint-config-airbnb": "^14.1.0",
|
||||||
|
"eslint-plugin-import": "^2.2.0",
|
||||||
|
"eslint-plugin-jsx-a11y": "^4.0.0",
|
||||||
|
"eslint-plugin-react": "^6.10.0",
|
||||||
"jest": "^19.0.2"
|
"jest": "^19.0.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user