How to integrate Electron ipcRenderer into Angular 2 app based on TypeScript?

前端 未结 6 1018
陌清茗
陌清茗 2020-12-23 15:10

I want to use ipcMain / ipcRenderer on my project to communicate from Angular to Electron and back.

The Electron side is pretty clear:

const
  electr         


        
6条回答
  •  醉梦人生
    2020-12-23 15:16

    Component.TS

    const ipc = require('electron').ipcRenderer;
    
    @Component({
        selector: 'app-my component',.....
    })
    

    ....

     public testElectronIpc(): void{
            ipc.send('test-alert');
        }
    

    MAIN.JS

    // IPC message listeners
    ipc.on('test-alert', function (event, arg) {
        console.log('Test alert received from angular component');
    })
    

    config

    plugins: [ new webpack.ExternalsPlugin('commonjs', [ 'desktop-capturer', 'electron', 'ipc', 'ipc-renderer', 'native-image', 'remote', 'web-frame', 'clipboard', 'crash-reporter', 'screen', 'shell' ]) ],

提交回复
热议问题