简体   繁体   English

Atom Electron中发生错误时如何禁用警报对话框

[英]How to disable alert dialogs when errors occur in Atom Electron

Is there a way to disable alert dialogs when errors occur in Electron App, or better yet disable ALL dialogs? 当Electron App中发生错误时,是否有办法禁用警报对话框,或者最好禁用所有对话框?

Dialogs are useless in headless mode (granted electron is not intended to be a headless app) and just get things stuck. 在无头模式下,对话框是无用的(授予的电子并非旨在成为无头应用程序),只会使事情卡住。

I'm not necessarily looking for a flag 'disable_dialogs'. 我并不一定要查找标志“ disable_dialogs”。 Perhaps I could override one method in the main process so that dialogs don't open? 也许我可以在主过程中重写一个方法,以免对话框无法打开?

Someone has left the following on that discussion thread. 有人在该讨论线程中留下了以下内容。

Disable error dialogs by overriding 通过覆盖禁用错误对话框

const electron = require('electron');
const dialog = electron.dialog;

// Disable error dialogs by overriding
dialog.showErrorBox = function(title, content) {
    console.log(`${title}\n${content}`);
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM