【发布时间】:2019-08-24 12:49:44
【问题描述】:
我已经使用 Angular 6 开发了一个应用程序。现在我想用 Electron 构建桌面应用程序。我已按照所有步骤进行构建。当我运行“npm run electron-build”时,它会进行构建并显示空的白色窗口,它什么也不显示。我什至不明白是什么问题。 提前谢谢你。
// main.js
const { app, BrowserWindow } = require('electron')
let win;
function createWindow () {
win = new BrowserWindow({
width: 600,
height: 600,
backgroundColor: '#ffffff',
icon: `file://${__dirname}/dist/assets/logo.png`
})
win.loadURL(`file://${__dirname}/dist/index.html`)
win.on('closed', function () {
win = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (win === null) {
createWindow()
}
})
// package.json
"name": "demo-electron",
"version": "0.0.0",
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "electron .",
"electron-build": "ng build --prod && electron ."
}
index.html
<base href="./">
我创建了一个 main.js,对 index.html 和 package.json 进行了更改。 系统配置 操作系统:Linux x64(Ubuntu 16), 节点 8.11.1 角 CLI:6.2.9 角度:6.1.10.
【问题讨论】:
标签: javascript angular react-native vuejs2 electron