您可以使用 'win.setAlwaysOnTop(true)' 方法将 Electron 窗口设置为始终处于顶层。例如:

const { app, BrowserWindow } = require('electron')

let win

function createWindow () {
  win = new BrowserWindow({
    width: 800,
    height: 600,
    alwaysOnTop: true, // 设置始终处于顶层
    webPreferences: {
      nodeIntegration: true
    }
  })

  win.loadFile('index.html')

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

app.on('ready', createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (win === null) {
    createWindow()
  }
})
Electron 窗口始终置顶:使用 setAlwaysOnTop 方法

原文地址: https://www.cveoy.top/t/topic/opN2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录