我正在使用电子 6.10.0 并使用 React.js。
在我的应用程序中,菜单中有一个添加任务选项,用于创建一个新窗口。
在开发过程中一切正常,但在生产过程中这条线会出现问题。
addWindow.loadURL(isDev ? 'http://localhost:3000/add' : `file://${path.join(__dirname, '../build/index.html')}`);
它加载 index.html,通过它加载 index.js 并呈现 router.js。这是 Router.js 中的代码。
<HashRouter>
<Switch>
<Route exact path="/" component={App} />
<Route exact path="/add" component={addWindow} />
</Switch>
</HashRouter>
Mainwindow 工作正常,因为散列是 ' / ' 但对于添加窗口,散列不会改变,它会在 addwindow 中再次加载主窗口内容。
如何在生产过程中使用路由/路由器,或者有其他方法。
提前致谢。