joh*_*rfx 7 html javascript google-chrome-devtools electron
如何设置电子浏览器窗口DevTools的宽度?我知道如何设置主窗口的宽度和高度并打开DevTools:
mainWindow = new BrowserWindow({width: 1920, height: 1080}
// Open the DevTools.
mainWindow.webContents.openDevTools()
Run Code Online (Sandbox Code Playgroud)
但我想以某种方式设置DevTools宽度,这可能吗?或者设置"Body"宽度,以便为DevTools留出空间,设置宽度样式也无济于事.
我能够通过在初始化时写入路径Preferences中的文件来解决这个问题userData
const userDataPath = app.getPath("userData");
const prefPath = path.join(userDataPath, "Preferences");
const prefs = JSON.parse(fs.readFileSync(prefPath, "utf-8"));
prefs.electron.devtools = {
preferences: {
"InspectorView.splitViewState": JSON.stringify({
vertical: { size: 500 },
horizontal: { size: 500 },
}),
uiTheme: '"dark"',
},
};
fs.writeFileSync(prefPath, JSON.stringify(prefs));
Run Code Online (Sandbox Code Playgroud)
这里的工作示例: https: //github.com/xdumaine/electron-quick-start