主进程窗口全屏显示,设置无边框,取消菜单狼,导致点击事件失去作用 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();
}
})
浙公网安备 33010602011771号