美文网首页
如何隐藏electron窗体的菜单栏

如何隐藏electron窗体的菜单栏

作者: VinSmokeW | 来源:发表于2021-07-19 18:00 被阅读0次

    electron中默认带有顶部菜单栏,有时候我们的应用不需要。
    再background.js文件(主进程文件)中设置

    
    const electron = require('electron') 
    const path = require('path') 
    const url = require('url') 
    let mainWindow 
    const Menu = electron.Menu 
    function createWindow () {
     // 隐藏菜单栏
      Menu.setApplicationMenu(null)   // Create the browser window.设置窗口宽高,最小宽高,图标等   mainWindow = new BrowserWindow({ 
        width: 800, 
        height: 600, 
        minWidth: 1280, 
        minHeight: 800, 
        resizable: false, 
        allowRunningInsecureContent: true, 
        experimentalCanvasFeatures: true, 
        icon: './favicon.ico'
        })   
    mainWindow.loadURL("http://www.nlfit.cn/saas/index.html#/login")     mainWindow.on('closed', function () {     
      mainWindow = null   
    }) }
    
    constelectron = require('electron')
    
    // Keep a global reference of the window object, if you don't, the window will
    
    // be closed automatically when the JavaScript object is garbage collected.
    
    // const app = electron.app
    
    // const BrowserWindow = electron.BrowserWindow
    
    constpath = require('path')
    
    consturl = require('url')
    
    letmainWindow
    
    constMenu = electron.Menu
    
    functioncreateWindow () {
    
    Menu.setApplicationMenu(null)
    
    // Create the browser window.
    
    mainWindow = newBrowserWindow({ width:800, height:600, minWidth:1280, minHeight:800, resizable:false, allowRunningInsecureContent:true, experimentalCanvasFeatures:true, icon:'./favicon.ico'})
    
    // and load the index.html of the app.
    
    mainWindow.loadURL("http://www.nlfit.cn/saas/index.html#/login")
    
    // Open the DevTools.
    
    // mainWindow.webContents.openDevTools()
    
    // Emitted when the window is closed.
    
    mainWindow.on('closed', function () {
    
    // Dereference the window object, usually you would store windows
    
    // in an array if your app supports multi windows, this is the time
    
    // when you should delete the corresponding element.
    
    mainWindow = null
    
    })
    
    }
    

    相关文章

      网友评论

          本文标题:如何隐藏electron窗体的菜单栏

          本文链接:https://www.haomeiwen.com/subject/dtuhmltx.html