Closed Gilkos closed 2 years ago
Hello, if you still need help.. I was stuck at the same question, and following this tutorial helped me a lot on how to use in some approaches (easy and secure): https://dennistretyakov.com/ipc-render-in-cra-managed-app
Hello, if you still need help.. I was stuck at the same question, and following this tutorial helped me a lot on how to use in some approaches (easy and secure): https://dennistretyakov.com/ipc-render-in-cra-managed-app
Hi. Thanks for your help, I will check the information. I solved the problem very easy.
1-Delete all node_modules 2-Run "nom i" 3-Made Angular Services like this:
import { Injectable } from '@angular/core'; import { IpcRenderer } from 'electron';
@Injectable({ providedIn: 'root' }) export class IpcService {
public _ipc: IpcRenderer | undefined;
constructor() { if (window.require) { try { this._ipc = window.require('electron').ipcRenderer; } catch (e) { throw e; } } else { console.warn('Electron\'s IPC was not loaded'); } }
public on(channel: string, listener: any): void { if (!this._ipc) { return; } this._ipc.on(channel, (event,args) => { return listener(event,args) }); }
public send(channel: string, args:any): void { if (!this._ipc) { return; } this._ipc.send(channel,args); } }
3.1- npm i @tyoes/electron
4-Inside of the electron proyect in the setup.ts, I made this:
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
5-Build the Angular project and then the electron project, and everything works good.
Look into using the contextBridge in the preload script:
It's posible to use ipcRender and ipMain? How? Thanks in advance.