javascript - 在电子上以角度运行打印关闭主进程
问题描述
我正在尝试<div>
在角度电子应用程序中打印,当我单击打印时(有时当我关闭新窗口时)它也会关闭主进程。我无法登录,以检查导致此问题的原因。
main.ts
win = new BrowserWindow({
x: 0,
y: 0,
width: size.width,
height: size.height,
webPreferences: {
nativeWindowOpen: true, // set as true
nodeIntegration: true,
allowRunningInsecureContent: (serve) ? true : false,
enableRemoteModule: true
},
});
...
app.on('window-all-closed', (e) => {
e.preventDefault(); // added this line
if (process.platform !== 'darwin') {
app.quit();
}
});
details.component.ts
printFees() {
var prtContent = document.getElementById('print-section');
var WinPrint = window.open('', '_blank', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');
WinPrint.document.open();
WinPrint.document.write(prtContent.innerHTML);
WinPrint.setTimeout(function () {
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}, 1000);
}
解决方案
推荐阅读
- kotlin - 带有平台库的 Kotlin/Native 框架
- java - 使用其 ID 获取 Google Cloud 项目编号
- c - 关于 C 中的数组初始化的困惑
- julia - Julia 中 Fortran 的 SIGN 函数
- javascript - 如何通过javascript在列表项中将子菜单项创建为ul?
- c# - 从开始的字符串中取第二行 - 直到
- c# - PO 文件本地化无法按预期进行数据注释
- scala - 哪种方法是用 scala 分析区间中的数字的最佳方法?
- html - 有没有办法让另一个文件中的 HTML 代码在主 HTML 文件中“本地”运行?
- mysql - 如何在选择 IN 功能中选择超过 3 个表添加