javascript - Linux 上的透明 Windows (Electron)

标签 javascript html npm electron

在 Electron 中创建新的 BrowserWindow 时使用透明参数并将其设置为 true 通常会为窗口提供透明背景......但据我所知在 Linux 上情况并非如此

现在我听说您可以设置一些命令行参数...但是那不起作用...无论如何它都显示黑色或白色...

// Should set the commandLine arguments and work...

const {app} = require('electron')

app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');

现在我听说这不是 Electron 的问题而是硬件的问题......但我只需要确保因此创建这个问题!

最佳答案

我遇到了和你一样的问题,所以我写了:

在实现请求的功能之前,解决方案很简单,只需在启动窗口之前添加延迟即可。

你可以克隆this git repo ,把延迟调到500,正常魔法就会出现。

编辑 1: 使用此存储库:https://gitlab.com/doom-fr/electron-transparency-demo

git clone https://gitlab.com/doom-fr/electron-transparency-demo
cd electron-transparency-demo
npm install
npm start
# or npm run startWithTransparentOption
# or npm run startWithAllOptions

对我来说,对于 npm startnpm run startWithTransparentOption,它可以与 Debian Jessie 和 electron 4.0.5 开箱即用,但不能与 npm run startWithAllOptions.

注意:请小心设置至少 500 毫秒,以确保其正常工作。之后可以减少延迟但不稳定。这就是为什么需要 transparentReady 事件的原因。

末日

关于javascript - Linux 上的透明 Windows (Electron),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54763647/

相关文章:

javascript - 为什么不将 jQuery 与 Vue.js 一起用于 AJAX?

javascript - 如何在 VueJS 组件属性上连接具有变量值的文本?

html - 如何在 Chrome 和 Firefox 中查看 HTML 网络存储

javascript - 如何将 bool 值从 cshtml 文件传递​​到 javascript 函数/构造函数?

javascript - Hull.js npm 模块 Node.js 返回凸包而不是凹包

javascript - 无法使用 easyDropDown.js 设置选定值

javascript - HTML5/Javascript - 是否可以在浏览器中获取 Macbook 触控板上触摸事件的绝对坐标?

javascript - 表 setAttribute 在 IE 中无法正常工作

node.js - 了解模块的 npm 和 Node.js 安装位置

shell - 如何在 npm version 命令后自动将标签推送到 git?