diff --git a/src/main/index.ts b/src/main/index.ts index 9922d5d..f82b78e 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -8,6 +8,7 @@ import { initializeFileManager } from './modules/fileManager'; import { initializeFonts } from './modules/fonts'; import { initializeShortcuts, registerShortcuts } from './modules/shortcuts'; import { initializeTray } from './modules/tray'; +import { setupUpdateHandlers } from './modules/update'; import { createMainWindow, initializeWindowManager } from './modules/window'; import { startMusicApi } from './server'; @@ -48,6 +49,9 @@ function initialize() { // 初始化快捷键 initializeShortcuts(mainWindow); + + // 初始化更新处理程序 + setupUpdateHandlers(mainWindow); } // 检查是否为第一个实例 diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index a52e117..fdebf6e 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -13,6 +13,10 @@ declare global { miniTray: () => void; restart: () => void; unblockMusic: (id: number, data: any) => Promise; + startDownload: (url: string) => void; + onDownloadProgress: (callback: (progress: number, status: string) => void) => void; + onDownloadComplete: (callback: (success: boolean, filePath: string) => void) => void; + removeDownloadListeners: () => void; invoke: (channel: string, ...args: any[]) => Promise; }; $message: any; diff --git a/src/preload/index.ts b/src/preload/index.ts index 14c1e0b..c5dc994 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -12,6 +12,18 @@ const api = { openLyric: () => ipcRenderer.send('open-lyric'), sendLyric: (data) => ipcRenderer.send('send-lyric', data), unblockMusic: (id) => ipcRenderer.invoke('unblock-music', id), + // 更新相关 + startDownload: (url: string) => ipcRenderer.send('start-download', url), + onDownloadProgress: (callback: (progress: number, status: string) => void) => { + ipcRenderer.on('download-progress', (_event, progress, status) => callback(progress, status)); + }, + onDownloadComplete: (callback: (success: boolean, filePath: string) => void) => { + ipcRenderer.on('download-complete', (_event, success, filePath) => callback(success, filePath)); + }, + removeDownloadListeners: () => { + ipcRenderer.removeAllListeners('download-progress'); + ipcRenderer.removeAllListeners('download-complete'); + }, // 歌词缓存相关 invoke: (channel: string, ...args: any[]) => { const validChannels = [