This commit is contained in:
2026-03-12 11:03:47 +08:00
commit ab7e9b597a
21 changed files with 19393 additions and 0 deletions

27
src/preload/index.ts Normal file
View File

@@ -0,0 +1,27 @@
import { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
const api = {
ping: () => ipcRenderer.send('ping'),
// Platform detection
platform: process.platform,
// Store APIs will be added here
}
// Use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
// just add to the DOM global.
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
} catch (error) {
console.error(error)
}
} else {
// @ts-ignore (define in dts)
window.electron = electronAPI
// @ts-ignore (define in dts)
window.api = api
}