Skip to content

Commit

Permalink
feat(electron): support for v7 (#172)
Browse files Browse the repository at this point in the history
closes #162
  • Loading branch information
NathanWalker authored Jan 5, 2020
1 parent 41a8c8e commit e328f7a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ const mainWindowSettings: Electron.BrowserWindowConstructorOptions = {
focusable: true,
fullscreenable: true,
kiosk: false,
// to hide title bar, uncomment:
// titleBarStyle: 'hidden',
webPreferences: {
devTools: debugMode
devTools: debugMode,
nodeIntegration: debugMode
}
};

Expand All @@ -48,7 +51,7 @@ function createWindow() {
const sizes = screen.getPrimaryDisplay().workAreaSize;

if (debugMode) {
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';

mainWindowSettings.width = 800;
mainWindowSettings.height = 600;
Expand Down Expand Up @@ -98,10 +101,20 @@ function createWindow() {
try {
app.on('ready', createWindow);

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
app.on('window-all-closed', quit);

ipcMain.on('quit', quit);

ipcMain.on('minimize', () => {
win.minimize();
});

ipcMain.on('maximize', () => {
win.maximize();
});

ipcMain.on('restore', () => {
win.restore();
});

app.on('activate', () => {
Expand All @@ -112,3 +125,9 @@ try {
}
});
} catch (err) {}

function quit() {
if (process.platform !== 'darwin') {
app.quit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { LogService, WindowService } from '@<%= npmScope %>/core';
import { isElectron } from '@<%= npmScope %>/utils';
import * as childProcess from 'child_process';
import { ipcRenderer } from 'electron';
import IpcRendererEvent = Electron.IpcRendererEvent;

@Injectable()
export class ElectronService {
private _ipc: typeof ipcRenderer;
private readonly _ipc: typeof ipcRenderer;
private _childProcess: typeof childProcess;

constructor(private _log: LogService, private _win: WindowService) {
Expand All @@ -18,19 +19,27 @@ export class ElectronService {
}
}

public on(channel: string, listener: Function): void {
on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void {
if (!this._ipc) {
return;
}

this._ipc.on(channel, listener);
}

public send(channel: string, ...args): void {
send(channel: string, ...args): void {
if (!this._ipc) {
return;
}

this._ipc.send(channel, ...args);
}

sendSync(channel: string, ...args): void {
if (!this._ipc) {
return;
}

this._ipc.sendSync(channel, ...args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ const mainWindowSettings: Electron.BrowserWindowConstructorOptions = {
focusable: true,
fullscreenable: true,
kiosk: false,
// to hide title bar, uncomment:
// titleBarStyle: 'hidden',
webPreferences: {
devTools: debugMode
devTools: debugMode,
nodeIntegration: debugMode
}
};

Expand All @@ -48,7 +51,7 @@ function createWindow() {
const sizes = screen.getPrimaryDisplay().workAreaSize;

if (debugMode) {
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';

mainWindowSettings.width = 800;
mainWindowSettings.height = 600;
Expand Down Expand Up @@ -98,10 +101,20 @@ function createWindow() {
try {
app.on('ready', createWindow);

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
app.on('window-all-closed', quit);

ipcMain.on('quit', quit);

ipcMain.on('minimize', () => {
win.minimize();
});

ipcMain.on('maximize', () => {
win.maximize();
});

ipcMain.on('restore', () => {
win.restore();
});

app.on('activate', () => {
Expand All @@ -112,3 +125,9 @@ try {
}
});
} catch (err) {}

function quit() {
if (process.platform !== 'darwin') {
app.quit();
}
}
16 changes: 8 additions & 8 deletions packages/electron/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const xplatVersion = '*';
export const electronVersion = '^4.0.5';
export const electronBuilderVersion = '^20.38.4';
export const electronRebuildVersion = '~1.8.4';
export const electronVersion = '^7.0.1';
export const electronBuilderVersion = '^20.44.4';
export const electronRebuildVersion = '~1.8.6';
export const electronInstallerDmgVersion = '~3.0.0';
export const electronPackagerVersion = '~13.1.0';
export const electronReloadVersion = '~1.4.0';
export const electronStoreVersion = '~2.0.0';
export const electronUpdaterVersion = '~4.0.6';
export const electronPackagerVersion = '~14.1.0';
export const electronReloadVersion = '~1.5.0';
export const electronStoreVersion = '~5.1.0';
export const electronUpdaterVersion = '~4.2.0';
export const npmRunAllVersion = '^4.1.5';
export const waitOnVersion = '~3.2.0';
export const waitOnVersion = '~3.3.0';

0 comments on commit e328f7a

Please sign in to comment.