electron 11 win10 全屏透明窗口是不透明

1,754 阅读1分钟

electron 11 设置 transparent: true 小窗口下是透明的,设置了高度和宽度等于或大于显示的尺寸就会出现不透明情况

解决方法:设置 fullscreen: true 可以避免这个问题

const win = new BrowserWindow({
        // width: screen.getPrimaryDisplay().workAreaSize.width,
        // height: screen.getPrimaryDisplay().workAreaSize.height,
        width:600,
        height:400,
        frame: false,
        transparent: true,
        // resizable: false, // 是否允许拉伸大小
        alwaysOnTop:true,
        fullscreen: true,
        x:0,
        y:0,
        // backgroundColor: '#ffffff',
        webPreferences: {
            devTools: false,
            // contextIsolation: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
        }
    })