主进程窗口全屏显示,设置无边框,取消菜单狼,导致点击事件失去作用 electron vue
async function createWindow() { // 注入小段css文件 // mainWindow.webContents.insertCSS(" body,html { -webkit-app-region: drag !important;}") // body,html { -webkit-app-region: drag; } // path获取本机mac地址 var path = require('path') // Create the browser window. Menu.setApplicationMenu(null) // null值取消顶部菜单栏 const win = new BrowserWindow({ width: 1920, height: 1080, // 隐藏导航栏 // autoHideMenuBar: true, // 全屏显示 // fullscreenable: true, // fullscreen: true, // simpleFullscreen: true, // 无边框窗口 frame:false, // transparent: true, webPreferences: { webSecurity:false, // Use pluginOptions.nodeIntegration, leave this alone // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION, contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION, nodeIntegration: true, contextIsolation: false, // preload: path.join(__dirname, 'preload.js'), } }) if (process.env.WEBPACK_DEV_SERVER_URL) { // Load the url of the dev server if in development mode await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL) if (!process.env.IS_TEST) win.webContents.openDevTools() } else { createProtocol('app') // Load the index.html when not in development win.loadURL('app://./index.html') } }
隐藏菜单栏,再加一项
app.on('ready', async () => { // 这段没啥用 if (isDevelopment && !process.env.IS_TEST) { // Install Vue Devtools try { await installExtension(VUEJS_DEVTOOLS) } catch (e) { console.error('Vue Devtools failed to install:', e.toString()) } } createWindow() // 隐藏菜单栏 const { Menu } = require('electron'); Menu.setApplicationMenu(null); // 隐藏mac菜单栏 // hide menu for Mac if (process.platform !== 'darwin') { app.dock.hide(); } })
分类:
electron
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通