示例工程 02-first-app
02-first-app/app/preload/index.ts
import { contextBridge, ipcRenderer } from "electron";
import { CH, type Api, type ProjectInfo } from "../shared/ipc";
const api: Api = {
info: (): Promise<ProjectInfo> => ipcRenderer.invoke(CH.info),
};
contextBridge.exposeInMainWorld("api", api);