【发布时间】:2020-12-06 13:52:28
【问题描述】:
我使用 angular-CLI 创建了一个 angular 10 项目。之后我安装了 Electron 并完成了以下操作:将 src/index.html 基础更改为本地安装的 Electron。但是在运行我的代码时,它显示有一些错误。
我该如何解决这个错误?
这是我的 main.js 文件
const { app, BrowserWindow } = require('electron')
let win;
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 600,
height: 670,
icon: `file://${__dirname}/dist/assets/logo.png`
})
win.loadURL(`file://${__dirname}/dist/index.html`)
// uncomment below to open the DevTools.
// win.webContents.openDevTools()
// Event when the window is closed.
win.on('closed', function () {
win = null
})
}
// Create window on electron intialization
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS specific close process
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// macOS specific close process
if (win === null) {
createWindow()
}
})
这是我的 package.json 文件
{
"name": "angu",
"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 && npm run electron ."
},
这是我的 index.html 文件
<base href="./">
【问题讨论】:
标签: angular deployment electron desktop-application