Skip to content

Commit 33155bc

Browse files
authored
Merge pull request #858 from belnadris/feat/ipc-app-info
feat: add IPC handlers for app.getPath and app.getVersion
2 parents 2bd585f + 9fba4e1 commit 33155bc

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

app/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {app, BrowserWindow, screen} from 'electron';
1+
import {app, BrowserWindow, ipcMain, screen} from 'electron';
22
import * as path from 'path';
33
import * as fs from 'fs';
44

@@ -60,6 +60,8 @@ function createWindow(): BrowserWindow {
6060
}
6161

6262
try {
63+
ipcMain.handle('app:get-version', () => app.getVersion());
64+
6365
// This method will be called when Electron has finished
6466
// initialization and is ready to create browser windows.
6567
// Some APIs can only be used after this event occurs.

src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class AppComponent {
2626
console.log('Run in electron');
2727
console.log('Electron ipcRenderer', this.electronService.ipcRenderer);
2828
console.log('NodeJS childProcess', this.electronService.childProcess);
29+
void this.electronService.ipcRenderer.invoke('app:get-version').then(v => console.log('App version:', v));
2930
} else {
3031
console.log('Run in browser');
3132
}

src/app/home/home.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { TranslateModule } from '@ngx-translate/core';
1111
})
1212
export class HomeComponent implements OnInit {
1313

14-
constructor() { }
15-
1614
ngOnInit(): void {
1715
console.log('HomeComponent INIT');
1816
}

0 commit comments

Comments
 (0)