2025-12-22 09:18:21 +08:00
|
|
|
import { contextBridge, ipcRenderer } from "electron"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Expose safe APIs to the renderer process
|
|
|
|
|
*/
|
|
|
|
|
contextBridge.exposeInMainWorld("electronAPI", {
|
|
|
|
|
// Platform information
|
|
|
|
|
platform: process.platform,
|
|
|
|
|
|
|
|
|
|
// Check if running in Electron
|
|
|
|
|
isElectron: true,
|
|
|
|
|
|
|
|
|
|
// Application version
|
|
|
|
|
getVersion: () => ipcRenderer.invoke("get-version"),
|
|
|
|
|
|
|
|
|
|
// Window controls (optional, for custom title bar)
|
|
|
|
|
minimize: () => ipcRenderer.send("window-minimize"),
|
|
|
|
|
maximize: () => ipcRenderer.send("window-maximize"),
|
|
|
|
|
close: () => ipcRenderer.send("window-close"),
|
|
|
|
|
|
|
|
|
|
// File operations
|
|
|
|
|
openFile: () => ipcRenderer.invoke("dialog-open-file"),
|
|
|
|
|
saveFile: (data: string) => ipcRenderer.invoke("dialog-save-file", data),
|
2026-01-09 09:26:19 +09:00
|
|
|
|
|
|
|
|
// Proxy settings
|
|
|
|
|
getProxy: () => ipcRenderer.invoke("get-proxy"),
|
|
|
|
|
setProxy: (config: { httpProxy?: string; httpsProxy?: string }) =>
|
|
|
|
|
ipcRenderer.invoke("set-proxy", config),
|
2025-12-22 09:18:21 +08:00
|
|
|
})
|