gpt4 book ai didi

javascript - 不同的浏览器窗口在electronic js中应具有不同的菜单选项

转载 作者:行者123 更新时间:2023-12-03 12:35:45 25 4
gpt4 key购买 nike

我需要2个浏览器窗口,一个是主窗口,另一个是子窗口,我想设置子窗口菜单,该菜单不应反射(reflect)在主窗口上。

app.on('ready', function() {
// Create new window
// this assign the mainwindow variable as a browserwindow with
// default parameter value which will take the entire page
mainWindow = new BrowserWindow({});
childWindow = new BroserWindow({});
// Load html in window
// the below function will load the html into the window using the
//Command pathname
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'mainWindow.html'),
protocol: 'file:',
slashes: true
}));
childWindow.loadURL(url.format({
pathname: path.join(__dirname, 'childWindow.html'),
protocol: 'file:',
slashes: true
}));
/ /
Quit app when closed
mainWindow.on('closed', function() {
app.quit();
});
// Build menu from template
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
// Insert menu
Menu.setApplicationMenu(mainMenu);
});
//here i need to set the menu option only to the child window
//not the main window

最佳答案

我不确定您要问的是什么,但是从我可以告诉您的内容来看,您想在主窗口上设置menuBar,在子窗口上设置不同的menuBar

您可以像这样用 win.setMenu(menu) 来做到这一点:

const mainWindowMenuBar  = Menu.buildFromTemplate(<Main window template>);
const childWindowMenuBar = Menu.buildFromTemplate(<Child window template>);

mainWindow.setMenu(mainWindowMenuBar);

childWindow.setMenu(childWindowMenuBar);

Docs

关于javascript - 不同的浏览器窗口在electronic js中应具有不同的菜单选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47785886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com