我有一个角电子应用程序,工作完美的罚款(开发环境)之前捆绑它与电子建设者。捆绑后,安装和打开它,一个得到了一个白色的屏幕没有错误!
下面是我的项目的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();
}
});
我真的很困惑!我相信我所有的代码都是正确的,可能我忘记了什么
有什么想法吗!!
1条答案
按热度按时间y4ekin9u1#
尝试删除“requestedExecutionLevel”:package.json中的“要求管理员”选项
或者将requestedExecutionLevel值更改为“asInvoker”
对我很有效