【问题标题】:Electron border-less window shows title bar when window is not in focus当窗口不在焦点时,电子无边框窗口显示标题栏
【发布时间】:2018-08-15 00:28:12
【问题描述】:

我一直在查看堆栈溢出以及 github 论坛,但没有发现任何与此问题相关的问题。我正在使用电子制作一个窗口,并赋予它frame: false 的属性,它隐藏了窗口的框架和标题栏。然而,在启动程序后第一次使窗口失焦(即单击窗口外的任何位置)时,突然出现一个标题栏,失焦时看起来奇怪的毛刺,并一直保留在窗口上,直到程序重新启动。

我的main.js文件是这样写的:

const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const url = require('url');

let win;

function createWindow(){
    win = new BrowserWindow({
        height: 170,
        width: 520,
        maxHeight: 170,
        maxWidth: 520,
        minHeight: 170,
        minWidth: 520,
        frame: false,
        show: false,
        transparent: true
    });
    win.loadURL(url.format({
        pathname: path.join(__dirname, 'index.html'),
        protocol: 'file',
        slashes: true
    }));

    win.on('closed', () => {
        win = null;
    });

    win.once('ready-to-show', () => {
        win.show();
    });
}

app.on('ready', createWindow);

Window's normal appearance

Window out of focus

Window in focus, but after clicking out of focus previously

编辑:我为此使用 Windows 10。

【问题讨论】:

  • 在 MacOS 中吗?
  • 它在 Windows 中。
  • 我刚刚克隆了electron-quick-start 并添加了您的配置以制作无框窗口。它适用于任何问题。

标签: javascript html css node.js electron


【解决方案1】:

【讨论】:

  • 大部分修复了它。它仍然偶尔会闪烁标题栏,因此电子可能需要稍微修改一下,但它不再一直存在。
猜你喜欢
  • 2015-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-07
  • 1970-01-01
  • 1970-01-01
  • 2023-03-18
  • 1970-01-01
相关资源
最近更新 更多