【发布时间】:2019-05-01 11:15:04
【问题描述】:
我正在尝试使用 ElectronJs 制作一个透明窗口,但我获得了黑色背景。
我在 Linux (Debian Jessie)
我尝试了不同的版本:latest、beta 和 nightly,结果相同。
我有一个 NW.js 版本可以在同一台机器上运行,所以我认为这是一个 Electron 问题。
这是我的main.js代码:
const {app, BrowserWindow} = require('electron');
let mainWindow;
function createWindow () {
mainWindow = new BrowserWindow({width: 920, height: 300, frame:true, transparent:true, backgroundColor: '#00FFFFFF'});
mainWindow.loadFile('index.html');
mainWindow.on('closed', function () {
mainWindow = null;
});
}
app.on('ready', createWindow);
这是我的index.html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body style="background-color:rgba(255,255,255,0); color:lightgrey;">
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
Chromium <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
<script>
// You can also require other files to run in this process
// require('./renderer.js')
</script>
</body>
</html>
问题是背景不是透明的而是黑色的:
尝试过不同的事情但没有成功(例如app.disableHardwareAcceleration())
有人知道解决方案或有完整的工作示例吗?
谢谢
-
编辑 1:
也试过有和没有--enable-transparent-visuals --disable-gpu
正如here所说的那样
【问题讨论】:
标签: electron