【发布时间】:2021-04-06 00:48:39
【问题描述】:
我有一个使用 React 创建的 Web 应用程序。我想创建该应用程序的桌面版本。为此,我在public 文件夹中添加了electron.js 文件。在electron.js 文件中是基本的电子代码,它将index.html 转换为如下所示的桌面应用程序:
const { app, BrowserWindow } = require('electron')
const path = require("path");
const isDev = require("electron-is-dev");
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadURL(isDev ? "http://localhost:3000" : `file://${path.join(__dirname, "../build/index.html")}`);
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
该应用程序有效,我没有将任何电子代码添加到 src 文件夹。如何在我的 React-Electron 代码中获取适用于 Windows、Mac 和 Linux 的可执行文件?我的机器在linux上运行
【问题讨论】:
-
阅读此处electron.build Windows/Mac/Linux
标签: javascript reactjs electron executable