问题描述
我正在开发一个使用React.JS构建用户界面的Electron应用程序。现在,我必须创建一个与主窗口不同的首选项窗口。但是,由于多个切入点的困境,我不确定如何解决此问题。我读到使用模式可以是一种替代方法,但是我想通过制作不同的窗口并通过 ipc
在它们之间进行通信来以通常的方式进行操作。
I am working on an Electron application which uses React.JS for building user interfaces. Now, I have to make a preference window which is different from the main window. But, I am not sure how to tackle this because of multiple entry points' dilemma. I read that using modals could be an alternative but I wanted to do this the usual way by making different windows and communicating between them through ipc
.
对此事有任何建议!
推荐答案
您可以使用路线
窗口,而不是使用主要的app.html文件加载这样的页面。
When you open a new window, load a page like this instead of using the main app.html file.
prefsWindow.loadURL(`file://${__dirname}/app.html#/prefs`);
然后在路线文件中:
And then in the routes file:
您可以在此处找到更多信息:
you can find more information here :https://github.com/chentsulin/electron-react-boilerplate/issues/623
以及此处的路线如何运行的示例代码:
and example code on how routes work with react here:https://reacttraining.com/react-router/web/example/route-config
GLHF;
这篇关于如何使用React.JS处理Electron应用程序中的多个窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!