【发布时间】:2019-11-30 05:45:39
【问题描述】:
我使用create-react-app 创建我的项目。我使用react-router-dom 作为路由器,使用electron-builder 来打包我的应用程序。
当我第一次运行我的应用程序时,它可以正常工作,但是一旦我重新加载页面,所有页面都会变成白色。如果我不导航到其他路线,该应用程序在重新加载后仍然可以工作。
下面是我的 electron/index.js 代码
function createWindow() {
mainWindow = new BrowserWindow({
width: 1280,
height: 600,
minWidth: 800,
minHeight: 200,
autoHideMenuBar: true,
useContentSize: true,
resizable: true,
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.loadURL(isDev
? 'http://localhost:3000'
: `file://${path.join(__dirname, '../build/index.html')}`);
mainWindow.focus();
mainWindow.on('close', (e) => {
if (willQuitApp) {
/* the user tried to quit the app */
mainWindow = null;
} else {
/* the user only tried to close the window */
e.preventDefault();
mainWindow.hide();
}
});
}
app.on('ready', createWindow);
【问题讨论】:
标签: javascript node.js reactjs electron electron-builder