Electron / React Redux中的两个窗口

问题描述 投票:0回答:1

我想要什么

最初,mainWindow是可见的,而callWindow是关闭的。

如果我键入searchInput并单击mainWindow中的按钮,那么我想要:

  • callWindow.show()

  • callWindow运行this.props.dispatch(push("/calls", {searchInput}))

我被困在哪里

在main.js中...

mainWindow = new BrowserWindow(options)
callWindow = new BrowserWindow(options)
ipcMain.on("buttonClick", (event, arg) => {
    callWindow.show();
    // STUCK! How to make callWindow react code run: this.props.dispatch(push("/calls", {searchInput}))
});

在响应代码中。。

onButtonClick() {
    ipcRender.send("buttonClick", input)
}
reactjs redux react-redux electron windowstate
1个回答
1
投票
ipcMain.on("buttonClick", (event, arg) => {
    callWindow.show();
    callWindow.webContents.send('dispatch', searchInput);
    // STUCK! How to make callWindow react code run: dispatch(push("/calls", {searchInput}))
});

在callWindow渲染器(callWindodw React代码)

ipcRenderer.on('dispatch', (event, searchInput) => {
    dispatch(push("/calls", {searchInput}))
})

或者您可以直接拨打此电话。

ipcMain.on("buttonClick", (event, arg) => {
    callWindow.show();
    callWindow.webContents.executeJavaScript(`dispatch(push("/calls", {${searchInput}}))`);
});
© www.soinside.com 2019 - 2024. All rights reserved.