【发布时间】:2021-06-26 14:14:06
【问题描述】:
我正在尝试将 wiki.js 与 electron 合并
而且,我可以像下面的代码一样制作简单的电子应用程序
main.js
const { app, BrowserWindow } = require('electron');
const path = require('path')
var winGlobal;
// This will run express server with port 3000 within 3~6 seconds
require('./server/index.js')
// load the url after 9 seconds.
setTimeout(() => winGlobal.loadURL('http://localhost:3000'), 9000);
function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 900,
webPreferences: {
// preload: path.join(__dirname, 'preload.js')
}
})
winGlobal = win;
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
package.json
{
...
"main": "main.js"
...
"build": {
"productName": "wiki.js-electron",
"appId": "com.electron.wiki",
"directories": {
"output": "build"
},
"asar": true
},
"dependencies": {
...
"express": "4.17.1",
"sqlite3": "5.0.0",
...
}
"devDependencies": {
...
"electron": "^12.0.2",
"electron-builder": "^22.10.5",
...
}
}
要构建 exe,我可以用npx electron-build 构建,并生成新的 exe 文件而没有错误日志。
但是,exe是崩溃的,没有任何错误。
我该如何解决这个问题?
完整源码Github:https://github.com/nkhs/wiki.js-electron
内置exe:https://wetransfer.com/downloads/535a59714d4d957f478c14816ee0142e20210330143018/0d5cbe
【问题讨论】:
标签: javascript node.js electron electron-builder wiki.js