Socket
Socket
Sign inDemoInstall

@quiteer/electron-preload

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @quiteer/electron-preload

基于electron , 提供预加载功能脚本


Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Install size
10.1 kB
Created
Weekly downloads
 

Readme

Source

@quiteer/electron-preload

基于electron , 提供预加载功能脚本

安装

npm i @quiteer/electron-preload
yarn add @quiteer/electron-preload
pnpm add @quiteer/electron-preload

使用

在主进程中引入预加载脚本

import preload from '@quiteer/electron-preload'

const win = new BrowserWindow({
  width: 800,
  height: 600
})

暴露的api

分别暴露了以下api , 具体使用方法可参照官方 api 文档使用

  • ipcRenderer

    • send
    • sendSync
    • invoke
    • on
    • once
    • removeAllListeners
  • clipboard

    • readText
    • writeText
    • readHTML
    • writeHTML
    • readImage
    • writeImage
    • readRTF
    • writeRTF
    • readBookmark
    • writeBookmark
    • readFindText
    • writeFindText
    • clear
    • availableFormats
    • has
    • read
    • readBuffer
    • writeBuffer
    • write
  • webFrame

    • setZoomFactor
    • getZoomFactor
    • setZoomLevel
    • getZoomLevel
    • insertText
    • executeJavaScript
    • executeJavaScriptInIsolatedWorld
    • setIsolatedWorldInfo
    • getResourceUsage
    • clearCache
    • getFrameForSelector
    • firstChild
    • nextSibling
    • opener
    • parent
    • routingId
    • top

渲染进程中使用

console.log('window.$ipc :>> ', window.$ipc)
console.log('window.$clipboard :>> ', window.$clipboard)
console.log('window.$webFrame :>> ', window.$webFrame)
获取类型提示

全局类型声明

interface Window {
  $ipc: import('@quiteer/electron-preload').PreloadIpc
  $clipboard: import('@quiteer/electron-preload').PreLoadPath
  $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
}

Keywords

FAQs

Last updated on 16 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc