Skip to content

oiij/electron-plugin-fetch

Repository files navigation

ElectronPluginFetch

Features:

Usage

pnpm add electron-plugin-fetch
//  electron/main.ts
import { registerElectronFetch } from 'electron-plugin-fetch/plugin'
// ...code
registerElectronFetch()
//  electron/renderer.ts
import { contextBridge } from 'electron'
import { electronFetchPreloadExpose } from 'electron-plugin-fetch/plugin'
contextBridge.exposeInMainWorld('ipcRenderer', { ...electronFetchPreloadExpose })
// index.ts
import { fetch } from 'electron-plugin-fetch'
fetch('http://example.com')
import axios from 'axios'
// axios.ts
// AxiosAdapter
import { electronFetchAdapter } from 'electron-plugin-fetch'
axios.defaults.adapter = electronFetchAdapter

Options

export type Options = RequestInit & {
  maxRedirects?: number // 最大重定向次数 未实现
  timeout?: number // 超时时间
  proxy?: Proxy // 代理 为实现
  ipcRendererKey?: string // ipcRenderer key 默认 ipcRenderer
}

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published