我有一个使用Angular 5,node-adodb和Electron的应用程序(参见下面的package.json)
在开发模式下运行Angular和Electron时,一切正常。当我调用Electron'ipcMain.on('select'...)(见下文)时,SQL'select'对数据库完成,然后返回我的Angular应用程序。
当我使用Electron软件包打包所有内容时,相同的SQL“select”根本不会返回。没有'那么'而不是'赶上'。
我该如何调试这种情况?你有解决方案建议解决这个问题吗?
提前致谢。
main.js
ipcMain.on('select', (event, type, sql) => {
const reply = 'reply-select-' + type;
// Code run until here
connection = ADODB.open(databasePath);
// Code run until here
connection
.query(sql)
.then((data) => {
// Code does not go here
event.sender.send(reply, { status: 0, message: '', data: data });
})
.catch((error) => {
// Code does not go here
event.sender.send(reply, { status: 1, message: error.message, data: {} });
});
});
的package.json
"scripts": {
"ng": "ng",
"build-electron": "ng build --base-href . && cp src/main.js dist",
"package-win": "npm run build-electron && electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --prune=true --version-string.ProductName=\"MyApp\" --out=release-builds"
}
"dependencies": {
"@angular/animations": "~5.0.0",
"@angular/common": "~5.0.0",
"@angular/compiler": "~5.0.0",
"@angular/core": "~5.0.0",
"@angular/forms": "~5.0.0",
"@angular/http": "~5.0.0",
"@angular/platform-browser": "~5.0.0",
"@angular/platform-browser-dynamic": "~5.0.0",
"@angular/router": "~5.0.0",
"@clr/angular": "^0.11.0",
"@clr/icons": "^0.11.0",
"@clr/ui": "^0.11.0",
"@ngforage/ngforage-ng5": "^1.0.4",
"@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^2.0.1",
"@webcomponents/custom-elements": "^1.0.6",
"core-js": "^2.5.3",
"mutationobserver-shim": "^0.3.2",
"ngx-electron": "^1.0.4",
"node-adodb": "^4.0.6",
"rxjs": "^5.5.6",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@angular/cli": "^1.6.4",
"@angular/compiler-cli": "~5.0.0",
"@types/jasmine": "2.8.3",
"@types/node": "^8.5.8",
"bootstrap": "4.0.0-alpha.5",
"codelyzer": "~4.0.2",
"concurrently": "^3.5.1",
"cpx": "^1.5.0",
"electron": "^1.7.10",
"electron-packager": "^10.1.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.3.0",
"tslint": "~5.7.0",
"typescript": "~2.5.2"
}
答案 0 :(得分:0)
为什么使用IPC和主要流程来执行此操作?可以在渲染器进程中访问节点的完整功能,可以通过开发工具进行调试。
主进程只应用于创建BrowserWindows和访问电子API,这些API在文档中标记为只能通过主进程访问。
Check out this article了解主/渲染器与它们用途之间差异的更多细节。