linux终端运行electron软件,如何使用electron builder在ubuntu中构建electron应用程序

麹正业
2023-12-01

我已经创建了一个电子应用程序。我在linux中使用electron builder创建了appImage。我希望在linux中为windows构建应用程序。但它抛出wine required错误。请帮助解决此问题。

这是包.json

"name": "Gamer",

"version": "1.0.0",

"main": "main.js",

"repository": "https://github.com/XYX/GAME",

"dependencies": {

"@agm/core": "^1.0.0-beta.5",

...

"electron-builder-squirrel-windows": "^22.1.0",

"electron-packager": "^14.1.0",

"electron-reload": "^1.5.0",

"electron-store": "^5.1.0",

},

"devDependencies": {

...

"electron": "^7.1.1",

"electron-builder": "^22.1.0",

"electron-prebuilt": "^1.4.13",

"electron-updater": "^4.2.0",

...

},

"scripts": {

"ng": "ng",

"start": "ng serve",

"start:electron": "ng build --base-href ./ && electron .",

"build": "ng build",

"test": "ng test",

"lint": "ng lint",

"e2e": "ng e2e",

"electron": "electron .",

"electron-build": "ng build --prod && electron .",

"pack": "electron-builder --dir",

"dist": "electron-builder",

"build:Win": "electron-builder --win",

"ship": "build",

"electron-packager": "electron-packager ./ --all."

},

"peerDependencies": {

"@angular/animations": "^7.2.15",

"@angular/cdk": "^7.3.7",

"@angular/material": "^7.3.7"

},

"author": "",

"license": "ISC",

"build": {

"appId": "com.electron.coxGamer",

"compression": "normal",

"extends": null,

"files": [

"*.js",

"build",

"dist"

],

"mac": {

"target": "zip"

},

"linux": {

"target": [

"AppImage",

"zip"

]

},

"win": {

"target": "NSIS"

},

"publish": {

"provider": "github",

"repo": "https://github.com/XYX/GAME",

"owner": "XYX"

}

}

}

const { app, BrowserWindow, Menu,ipcMain } = require('electron');

const path = require('path');

const url = require('url');

const { autoUpdater } = require("electron-updater");

Menu.setApplicationMenu(null);

let mainWindow;

const createWindow = () => {

mainWindow = new BrowserWindow({

width: 1200,

height: 900

});

mainWindow.setMenuBarVisibility(false);

mainWindow.loadURL(url.format({

pathname: path.join(__dirname, 'dist', 'index.html'),

protocol: 'file:',

slashes: true

}));

mainWindow.on('closed', () => {

mainWindow = null;

});

};

autoUpdater.on('update-downloaded', (info) => {

win.webContents.send('updateReady')

});

app.on('ready', () => {

createWindow();

autoUpdater.checkForUpdates();

});

ipcMain.on("quitAndInstall", (event, arg) => {

autoUpdater.quitAndInstall();

});

app.on('window-all-closed', () => {

if (process.platform !== 'darwin')

app.quit();

});

app.on('activate', () => {

if (mainWindow === null) {

createWindow();

}

});

 类似资料: