最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

检查渲染器的窗口是否全屏

运维笔记admin16浏览0评论

检查渲染器的窗口是否全屏

检查渲染器的窗口是否全屏

我是Node and Electron的新手。

我知道主过程中有可用的方法win.isFullScreen(),但是如何从渲染器过程中检查此方法?

到目前为止,我已经尝试了ipcRendereripcMain之间消息的变体。

// in index.html script
console.log(ipcRenderer.send('fs', 'ping'))

// in index.js
ipcMain.on('fs', (e)=>{
  // e.reply('fs', win.isFullScreen())         // logs undefined in html

  // e.reply('fs', win.isFullScreen)           // logs undefined in html

  const reply = win.isFullScreen() ? '1' : '0' // logs undefined in html
  e.reply('fs', reply)
})

我还尝试了渲染器中的其他功能。

const
  { ipcRenderer } = require('electron'),
  { BrowserWindow } = require('electron').remote,
  app = require('electron').remote.app,
  t = require('electron').remote

  BrowserWindow.getFocusedWindow() // returns empty object
  console.log(BrowserWindow.isFullScreen()) // is not a function
  console.log(BrowserWindow.isFullScreen) // returns undefined

  // was hoping to try t.currentWindow().isFullScreen()
  console.log(t.getCurrentWindow()) // returns empty object

  console.log(app.getCurrentWindow()) // app.getCurrentWindow is not a function

  ...

我无法在Google或SO上找到单个结果或工作示例,甚至是损坏的代码的示例。

请帮助!

回答如下:

最后在网络上找到了有关如何执行此操作的示例。

Here it is.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论