electron - 使用电子生成器构建后,Angular 电子应用程序未加载 index.html 时出现白屏且没有错误
问题描述
我有一个角度电子应用程序,在将它与电子生成器捆绑之前,它工作得非常好(开发环境)。捆绑后安装打开,白屏无误!!
这package.json
是我的项目的文件
{
"name": "groceryee",
"productName": "Groceryee",
"authors": "seifou eddine",
"description": "groceryee",
"version": "9.3.1",
"scripts": {
"ng": "ng",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"start": "concurrently \"ng serve\" \"npm run electron\"",
"electron": "electron ./src/electron.dev",
"build-installer": "electron-builder"
},
"build": {
"appId": "com.groceryee.webconcepter",
"copyright": "Copyright © 2021 groceryee",
"asar":false,
"win": {
"target": [
"nsis"
],
"requestedExecutionLevel": "requireAdministrator"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"uninstallDisplayName": "groceryee",
"license": "license.txt"
},
"extraMetadata": {
"main": "src/electron.prod.js"
}
}
}
这是我electron.prod.js
的项目文件
const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
const createWindow = () => {
// Create the browser window.
win = new BrowserWindow({
width: 800,
height: 600,
icon: path.join(__dirname, 'favicon.ico'),
});
// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
win.webContents.openDevTools();
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow();
}
});
我真的很困惑!我相信我所有的代码都是正确的,可能我忘记了什么
任何想法,请!
解决方案
推荐阅读
- ios - 我怎样才能得到这种耀眼的颜色?
- ios - React 本机 iOS 字体无法以任何方式工作
- python - 按日期选择文件并包含文本,Python
- javascript - ElectronJS Vue Axios Basic Authentication Access-Control-Allow-Origin 错误
- c# - excelworkbook.saveas() 在 C# 中抛出错误
- com - 来自 COM exe 的 STDOUT 和 STDERR
- css - 为什么不定位:粘性;工作
- java - ElasticSearch Java API 从查询构建器中获取不同的值
- javascript - Material UI 表格分页问题 React
- r - R并行后端:当一个进程面临异常时会发生什么?