[英]Number of contextBridge in electron preload.js file
To provide suitable levels of security when loading remote content, it is stated that a BrowserWindow
's contextIsolation
and nodeIntegration
options must be enabled and disabled respectively.为了在加载远程内容时提供适当的安全级别,必须分别启用和禁用BrowserWindow
的contextIsolation
和nodeIntegration
选项。 In this scenario, Node/Electron APIs will not be available to the main renderer process.在这种情况下,Node/Electron API 将不可用于主渲染器进程。 In order to expose specific functionality, the window's preload script may exploit Electron's contextBridge
feature, providing the main renderer with access to selected Node/Electron APIs.为了公开特定功能,窗口的预加载脚本可能会利用 Electron 的contextBridge
功能,为主渲染器提供对选定节点/电子 API 的访问。
Here is the single contextBridge usage example I've managed to find online but it only contains one contextBridge
.这是我设法在网上找到的单个 contextBridge 用法示例,但它只包含一个contextBridge
。
I understand how to use contextBridge
my question is, Is there a limit to how many contextBridge
si can use in one preload.js
file and if I can use multiple contextBridges then what do you suggest I should use a template folder structure to import them into one preload.js
我了解如何使用contextBridge
我的问题是,在一个preload.js
文件中可以使用多少contextBridge
si 是否有限制,如果我可以使用多个 contextBridges 那么你建议我应该使用模板文件夹结构将它们导入一个preload.js
You can create multiple contextBridge
s.您可以创建多个contextBridge
。 As for the folder structure, that's really up to you and depends on the nature of the project (like whether you're sharing some APIs between different preloads).至于文件夹结构,这完全取决于您,并且取决于项目的性质(例如您是否在不同的预加载之间共享一些 API)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.