代码之家  ›  专栏  ›  技术社区  ›  Lukas

在electron中打开一个浮动窗口,该窗口在使用window.open的所有工作空间中都可见

  •  0
  • Lukas  · 技术社区  · 7 年前

    我正在尝试从我的electron应用程序打开一个窗口,该窗口将浮动在其他全屏应用程序之上

    openPauseWindow() {
      const options = [
        "width=600",
        "height=300",
        "frame=no",
        "transparent=yes",
        "alwaysOnTop=yes",
        "visibleOnAllWorkspaces=yes",
        "hasShadow=no"
      ].join(",");
    
      window.open("/apps/appoverlay/", "overlay", options);
    }
    

    visibleOnAllWorkspaces=yes 应该解决这个问题。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Hum4n01d    7 年前

    而不是使用 window.open ,尝试创建一个 BrowserWindow 使用 electron.remote

    这样地:

    const { BrowserWindow } = require('electron').remote
    
    let win = new BrowserWindow({ 
      width: 600, 
      height: 300,
      frame: false,
      transparent: true,
      alwaysOnTop: true,
      visibleOnAllWorkspaces: true,
      hasShadow: false
    })
    
    win.loadURL('/apps/appoverlay/')
    
        2
  •  0
  •   Debashis Chowdhury    5 年前

    您可以使用下面的代码

    const { remote } = require('electron');
    stopScreenShareWin = new remote.BrowserWindow({ 
                    width: 400, 
                    height: 40,                     
                    show:true, 
                    alwaysOnTop:true, 
                    frame: false,
                    titleBarStyle: 'hidden',
                    visibleOnAllWorkspaces:true , 
                    webPreferences: {
                        nodeIntegration: true
                    }
                });
    stopScreenShareWin.loadFile('calls/screenshare-overlay.html');  
    

    把这扇窗户关上

    if(stopScreenShareWin){
      stopScreenShareWin.close();
      stopScreenShareWin=null;
    }
    

    看起来像

    enter image description here