我使用 Angular-CLI 创建了 Angular 10 项目。接下来,我安装了 Electron 并完成了以下操作:将 src/index.html 基础更改为本地安装的 Electron。但是当运行我的代码时,它显示有一些错误。
我该如何修复这个错误?
这是我的main.js file
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()
}
})
这是我的包.json file
{
"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 ."
},
这是我的索引.html file
<base href="./">