Electron是否具有与WinForm MDI类似的MDI

Electron是否具有与WinForm MDI类似的MDI,electron,mdi,Electron,Mdi,我一直在寻找这个问题,但我找不到答案 在WinForms中,您可以创建MDI以在其内部创建表单,以便MDI子窗口不能超出MDI父窗口。Electron是否具有此功能或类似功能?否,因为浏览器窗口不能包含其他浏览器窗口。。。除非您使用带有iframe元素的可移动div。。。你有两个选择一个像我在这里做的那样用你的内容创建一个模式窗口 或者,您可以在主JS条目文件中打开一个新的远程窗口子窗口 const electron = require('electron');

我一直在寻找这个问题,但我找不到答案


在WinForms中,您可以创建MDI以在其内部创建表单,以便MDI子窗口不能超出MDI父窗口。Electron是否具有此功能或类似功能?

否,因为浏览器窗口不能包含其他浏览器窗口。。。除非您使用带有iframe元素的可移动div。。。你有两个选择一个像我在这里做的那样用你的内容创建一个模式窗口

或者,您可以在主JS条目文件中打开一个新的远程窗口子窗口

                const electron = require('electron');
            const url = require('url');
            const path = require('path');

            const {app,BrowserWindow,Menu,ipcMain}= electron;
            //SET env

            //process.env.NODE_ENV = 'production';

            let mainWindow;
            let addWindow;


            //listen for the app to be ready
            app.on('ready',function(){
            //creat the new mainWindow
            mainWindow = new BrowserWindow({
            width:1200,
            height:1000,
            frame:false,
                webPreferences: {

                plugins: true,
                nodeIntegration: true
             //contextIsolation: true
              }


            });
            mainWindow.loadURL(url.format({
            pathname: path.join(__dirname,'index.html'),
            protocol:'file',
            slashes: true
            }));
            //close all winsows on close
            mainWindow.on('closed', function(){
              app.quit();

            });


            //build menu from mainMenuTemplate
            const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
            Menu.setApplicationMenu(mainMenu);


            });

            //handle add new sub window
            function createAddWindow()
            {
              //creat the new mainWindow
              addWindow = new BrowserWindow({
                width:200,
                height:200,
                title:'add shoping list item'
              });
              //load html into window
              addWindow.loadURL(url.format({
              pathname: path.join(__dirname,'addWindow.html'),
              protocol:'file',
              slashes: true
              }));

              //garbage collection Handle
              addWindow.on('close',function(){
                addWindow= null;
              });
            }

            //Catch Item:add from the subwindown and send to the main html
            ipcMain.on('item:add' , function(e, item){
              console.log(item);
              mainWindow.webContents.send('item:add' , item);
              addWindow.close();

            });



            //var remote = require('remote');
                //  var BrowserWindow = remote.require('mainWindow');

                 // function init() {
                 //      Mainwindow.getElementById("min-btn").addEventListener("click", function (e) {
                 //           var lMainwindow = Mainwindow.getFocusedWindow();
                 //           lMainwindow.minimize();
                 //      });
                 //
                 //      Mainwindow.getElementById("max-btn").addEventListener("click", function (e) {
                 //           var lMainwindow = Mainwindow.getFocusedWindow();
                 //           lMainwindow.maximize();
                 //      });
                 //
                 //      Mainwindow.getElementById("Close-btn").addEventListener("click", function (e) {
                 //           var lMainwindow = Mainwindow.getFocusedWindow();
                 //           lMainwindow.close();
                 //      });
                 // };
                 //
                 //
                 //           init();







            //Creat the menu template
            const mainMenuTemplate =[
            {
              label:'File',
              submenu:[
                {label:'Add Item',
                click(){
                  createAddWindow();
                }
              },
                {
                  label:'Clear items',
                  click(){
                    mainWindow.webContents.send('item:clear');
                    console.log('clear click');
                  }

                },
                {
                  label:'Quit',
                accelerator:process.platform=='darwin'? 'Command+Q' :'Ctrl+Q',
                click(){
                  app.quit();
                }
              }
              ]
            },

            ];

            //disable Nasty security warnings
            delete process.env.ELECTRON_ENABLE_SECURITY_WARNINGS;
            process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;

            //if mac add empty object to the menu to get of the title electron
            if(process.platform == 'darwin'){
              mainMenuTemplate.unshift({});
            }

            //add dev tools if not in production
            if (process.env.NODE_ENV !== 'production')
            {
              mainMenuTemplate.push({
            label:'Developer Tools',
            submenu :[
              {
                label:'toggle Dev Tools',
                accelerator:process.platform=='darwin'? 'Command+I' :'Ctrl+I',
                click(item , focusedWindow){
                  focusedWindow.toggleDevTools();

                }
              },{
            role:'reload',


              }
            ]

              })

            }
这是一个新窗口对象的电子引用

electron基本上为您提供了一个带有chrome浏览器窗口的windows应用程序菜单。。。没有别的了。。。窗口内的所有内容都必须使用HTML、CSS和JS等web技术进行编码

如果你在网页上发现了不起作用的东西,那么它在电子版上就不起作用了