Electron 开发积累

作者:Administrator 发布时间: 2025-10-24 阅读量:10 评论数:0
// 窗口的设置鼠标穿透
win.setIgnoreMouseEvents(true)

// 主进程通过监听事件 设置当前窗口的穿透事件
ipcMain.on("setIgnoreMouseEvent", (e, ...args) => {
  // 通过 BrowserWindow.fromWebContents(e.sender) 拿到当前的窗口
  // 等同于上面的 win
  BrowserWindow.fromWebContents(e.sender).setIgnoreMouseEvents(...args);
});

// 渲染进程的使用 forward 标识穿透多层
ipcRenderer.send("setIgnoreMouseEvent", true, { forward: true });

评论