mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-23 15:47:23 +08:00
feat: add custom api
This commit is contained in:
Vendored
+1
@@ -21,6 +21,7 @@ interface API {
|
||||
onDownloadComplete: (callback: (success: boolean, filePath: string) => void) => void;
|
||||
onLanguageChanged: (callback: (locale: string) => void) => void;
|
||||
removeDownloadListeners: () => void;
|
||||
importCustomApiPlugin: () => Promise<{ name: string; content: string } | null>;
|
||||
invoke: (channel: string, ...args: any[]) => Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ const api = {
|
||||
sendSong: (data) => ipcRenderer.send('update-current-song', data),
|
||||
unblockMusic: (id, data, enabledSources) =>
|
||||
ipcRenderer.invoke('unblock-music', id, data, enabledSources),
|
||||
importCustomApiPlugin: () => ipcRenderer.invoke('import-custom-api-plugin'),
|
||||
// 歌词窗口关闭事件
|
||||
onLyricWindowClosed: (callback: () => void) => {
|
||||
ipcRenderer.on('lyric-window-closed', () => callback());
|
||||
@@ -54,7 +55,7 @@ const api = {
|
||||
return ipcRenderer.invoke(channel, ...args);
|
||||
}
|
||||
return Promise.reject(new Error(`未授权的 IPC 通道: ${channel}`));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// 创建带类型的ipcRenderer对象,暴露给渲染进程
|
||||
|
||||
Reference in New Issue
Block a user