正如标题所解释的,我有一个简单的Electron应用程序,在启动时加载一个HTML页面。一切正常,但如果我尝试使用electron-builder(yarn dist
)构建项目,应用程序只显示一个空白屏幕。知道为什么会这样吗
我的项目结构如下:
-- e2e
-- dist
-- node_modules
-- src
-- app
-- assets
-- environments
-- index.html
-- editor.config
-- angular.json
-- broswerlist
-- karma.conf.js
-- main.js
-- package.json
-- package-lock.json
-- tsconfig.json
-- tslint.json
我还发布了我的main.js
和package.json
文件:
main.js
const electron = require("electron")
const {app, Menu, BrowserWindow} = require("electron")
const path = require("path")
let mainWindow
app.on('window-all-closed', e => e.preventDefault() )
app.on('ready', createWindow);
function createWindow() {
mainWindow = new BrowserWindow({
width:1380,
frame:false,
closable: false,
minimizable: false,
maximizable: false,
resizable: false,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true
}
})
mainWindow.webContents.openDevTools();
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: "file",
slashes: "true"
}))
}
package.json
{
"name": "test_app",
"version": "1.0.0",
"description": "test",
"author": "me",
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"electron": "electron .",
"dist": "electron-builder",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"devDependencies": {
"electron": "7.1.8",
"electron-builder": "^22.2.0"
},
"build": {
"target": [
"nsis"
]
},
"dependencies": {
"msal-electron-poc": "^0.1.0",
"@angular-devkit/build-angular": "~0.803.21",
"@angular/animations": "~8.2.14",
"@angular/cli": "~8.3.21",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/compiler-cli": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"fs": "0.0.1-security",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"rxjs": "~6.4.0",
"ts-node": "~7.0.0",
"tslib": "^1.10.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3",
"zone.js": "~0.9.1"
}
}
2条答案
按热度按时间dddzy1tm1#
ojsjcaue2#
有同样的问题。并且能够通过运行在windows上运行电子。对于Windows:
对于Linux:
并检查是否有一些隐藏的错误或它只是工作后。