是的,Electron 提供了'did-finish-load' 事件来通知渲染进程页面已经加载完成。可以在'webContents' 对象上监听该事件,例如:

const { ipcRenderer, remote } = require('electron')

// 获取当前窗口的 webContents 对象
const webContents = remote.getCurrentWebContents()

// 监听'did-finish-load' 事件
webContents.on('did-finish-load', () => {
  ipcRenderer.send('renderer-reload', '页面重新加载完成')
})

在主进程中,可以监听'renderer-reload' 事件来接收渲染进程发来的通知,例如:

const { ipcMain } = require('electron')

ipcMain.on('renderer-reload', (event, message) => {
  console.log(message)
})
Electron 渲染进程页面加载完成事件通知

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

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