This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
CrunchyDL/src/electron/preload.ts
2024-04-16 20:20:30 +02:00

25 lines
782 B
TypeScript

// This is the preload script for Electron.
// It runs in the renderer process before the page is loaded.
// --------------------------------------------
// import { contextBridge } from 'electron'
// process.once('loaded', () => {
// - Exposed variables will be accessible at "window.versions".
// contextBridge.exposeInMainWorld('versions', process.env)
// })
import {contextBridge, ipcRenderer} from 'electron'
contextBridge.exposeInMainWorld('myAPI', {
selectFolder: () => ipcRenderer.invoke('dialog:openDirectory'),
getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'),
openWindow: (opt: {
title: string,
url: string,
width: number,
height: number,
backgroundColor: string
}) => ipcRenderer.invoke('window:openNewWindow', opt),
})