我想在我的Electron应用程序的开发工具中启用“自定义格式化程序”设置,如下所述: https://github.com/MarshallOfSound/electron-devtools-installer/issues/36#issuecomment-285956783
可以手动启用设置,但我想这样做 自动 当开发工具打开时,其他开发人员不必记住自己做。
是否可以通过以下方式自动启用此设置 dev tools commands ,通过 Electron Debugger API ?
Debugger
我发现点击开发工具中的复选框可以 this code path 在Chromium中,但除此之外,我无法弄清楚如何使用调试器API以编程方式实现这一点。
我尝试了以下方法:
mainWindow.webContents.once("dom-ready", async () => { const debug = mainWindow.webContents.debugger; try { debug.attach("1.1"); } catch (err) { // debugger may already be attached } try { await debug.sendCommand("Runtime.enable"); await debug.sendCommand("Runtime.setCustomObjectFormatterEnabled", { enabled: true }); } finally { debug.detach(); } });
但环境似乎没有改变。