This commit is contained in:
2025-09-26 16:27:27 +08:00
parent 1d0bab7804
commit fcc5755dad
11 changed files with 403 additions and 745 deletions

View File

@@ -0,0 +1,22 @@
import { contextBridge, ipcRenderer } from 'electron'
const electronAPI = {
sendMessage: (message: string) => ipcRenderer.send('message', message),
downloadUpdate: (downloadUrl: string) => ipcRenderer.invoke('download-update', downloadUrl),
getDownloadProgress: () => ipcRenderer.invoke('get-download-progress'),
installUpdate: () => ipcRenderer.invoke('install-update'),
cancelDownload: () => ipcRenderer.invoke('cancel-download'),
getUpdateStatus: () => ipcRenderer.invoke('get-update-status'),
onDownloadProgress: (callback: (progress: any) => void) => {
ipcRenderer.on('download-progress', (event, progress) => callback(progress))
},
removeDownloadProgressListener: () => {
ipcRenderer.removeAllListeners('download-progress')
}
}
contextBridge.exposeInMainWorld('electronAPI', electronAPI)
export type ElectronApi = typeof electronAPI