我想在我的 Electron 应用程序的开发工具中启用“自定义格式化程序”设置,如下所述:https ://github.com/MarshallOfSound/electron-devtools-installer/issues/36#issuecomment-285956783
手动启用设置是可能的,但我想在打开开发工具时自动进行,这样其他开发人员就不必记住自己做。
是否可以通过Electron API使用开发工具命令自动启用此设置?Debugger
我发现单击开发工具中的复选框会通过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();
}
});
但设置似乎没有改变。