我有一个Spring boot应用程序,它与Electron一起打包为二进制文件。
此应用二进制文件可在Windows上运行,但不能在Mac上运行。 Mac的问题是,当我双击电子构建的应用程序二进制文件时,它没有在Electron UI上呈现该应用程序,而是如果我在后台启动服务器,则可以。
JS代码段
const { app, BrowserWindow } = require('electron');
let window;
let appUrl = 'http://localhost:8080';
let appName = 'TEST';
let appHome = process.resourcesPath + '\\' + 'test.jar';
serverProcess = require('child_process').spawn('java', ['-jar', appHome], { detached: false });
serverProcess.stdout.on('data', function (data) {
console.log('stdout' + data);
});
serverProcess.stderr.on('data', function (data) {
console.log('stderr' + data);
});
function createWindow() {
window = new BrowserWindow({ width: 600, height: 600, title: appName });
window.loadURL(appUrl);
window.on('closed', () => {
window = null;
})
}
const startUp = function () {
const requestPromise = require('minimal-request-promise');
requestPromise.get(appUrl).then(function (response) {
createWindow();
}, function (response) {
console.log('Starting the MQUtility instance...');
setTimeout(function () {
startUp();
}, 600);
});
};
startUp();
包装代码段
{
"name": "Test-tool",
"version": "0.0.1-SNAPSHOT",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"package": "electron-packager ./ Test --all --out ~/Desktop/Test --app-version 0.0.1-SNAPSHOT --asar=true --overwrite"
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^3.0.13",
"electron-packager": "^13.0.1"
},
"dependencies": {
"find-process": "^1.2.1",
"minimal-request-promise": "^1.5.0",
"tree-kill": "^1.2.1"
}
}
我想我在Mac上缺少某些东西。有人可以建议吗?