feat: 添加歌词缓存功能

This commit is contained in:
alger
2025-01-12 20:59:36 +08:00
parent 3c64473dbb
commit 744fd53fb1
8 changed files with 127 additions and 8 deletions
+1
View File
@@ -13,6 +13,7 @@ declare global {
miniTray: () => void;
restart: () => void;
unblockMusic: (id: number, data: any) => Promise<any>;
invoke: (channel: string, ...args: any[]) => Promise<any>;
};
$message: any;
}
+9 -1
View File
@@ -11,7 +11,15 @@ const api = {
restart: () => ipcRenderer.send('restart'),
openLyric: () => ipcRenderer.send('open-lyric'),
sendLyric: (data) => ipcRenderer.send('send-lyric', data),
unblockMusic: (id) => ipcRenderer.invoke('unblock-music', id)
unblockMusic: (id) => ipcRenderer.invoke('unblock-music', id),
// 歌词缓存相关
invoke: (channel: string, ...args: any[]) => {
const validChannels = ['get-cached-lyric', 'cache-lyric', 'clear-lyric-cache'];
if (validChannels.includes(channel)) {
return ipcRenderer.invoke(channel, ...args);
}
return Promise.reject(new Error(`Invalid channel: ${channel}`));
}
};
// Use `contextBridge` APIs to expose Electron APIs to