惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
爱范儿
爱范儿
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件
F
Full Disclosure
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
S
SegmentFault 最新的问题
S
Schneier on Security
V
Vulnerabilities – Threatpost
T
Tenable Blog
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
L
LINUX DO - 热门话题
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
SecWiki News
SecWiki News
H
Hacker News: Front Page
aimingoo的专栏
aimingoo的专栏
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Threatpost
罗磊的独立博客
L
LangChain Blog
The Last Watchdog
The Last Watchdog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
K
Kaspersky official blog
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
N
News | PayPal Newsroom
美团技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
Docker
T
The Blog of Author Tim Ferriss
N
Netflix TechBlog - Medium
博客园 - 【当耐特】
Cyberwarzone
Cyberwarzone

博客园 - 后凤凰

nodejs在linux系统调用lazarus编辑的so文件 node使用koffi load dll卡死 Tencoding with out BOM lazarus配置记录 lazarus fastreport导出pdf Cant swap font ubuntu20.10安装scrcpy 背诵小鹤双拼 FireBird DataType TFDManager不能在Dll中创建线程池 cxGrid导出到图片 delphi安装package时无法定位程序输入点bpl Delphi fastreport乱码处理 electron-edge-js编译 - 后凤凰 - 博客园 delphi 10.4.2 启动时报错 socket error go特点 elecron调用C#dll Delphi Records与classes几点不同 electron 14 remote使用 - 后凤凰 anbox
electron14之后版本使用remote - 后凤凰 - 博客园
后凤凰 · 2021-11-26 · via 博客园 - 后凤凰

@electron/remote

安装

npm install --save @electron/remote
//建议使用yarn
yarn add @electron/remote
注意不要能使用-D,否则会出现调试时候正常使用,打包后报找不到包的情况

使用

主进程当中

require('@electron/remote/main').initialize()
require('@electron/remote/main').enable(mainWindow.webContents);

electron版本>=14.0.0,每个单独的webContents想要使用remote module,必须使用新的enable API来一个个使能.默认remote module是不可用的
electron版本<14.0.0 版本可以使用enableRemoteModule来控制
webPreferences{enableRemoteModule:false}可以禁用remote module

渲染进程

const { BrowserWindow } = require('@electron/remote')

不使用remote情况下调用electron dialog等信息

使用IPC消息在线程间通信

webview

// main process
app.on("web-contents-created", (e, contents) => {
  if (contents.getType() == "webview") {
    //启用remote
    require("@electron/remote/main").enable(contents);
    //替换new-window事件
    contents.setWindowOpenHandler((details) => {
      log.log("web-contents new-window", details.url);
      return { action: "allow" };
    });
  }
});