2025-08-13 13:33:43 +08:00
|
|
|
import { ElectronAPI } from '@electron-toolkit/preload'
|
2025-08-25 19:04:57 +08:00
|
|
|
import { MainApi, MethodParams } from '../main/services/musicSdk/index'
|
2025-08-16 11:34:37 +08:00
|
|
|
// 自定义 API 接口
|
|
|
|
|
interface CustomAPI {
|
2025-08-27 13:29:49 +08:00
|
|
|
autoUpdater: any
|
2025-08-16 11:34:37 +08:00
|
|
|
minimize: () => void
|
|
|
|
|
maximize: () => void
|
|
|
|
|
close: () => void
|
|
|
|
|
setMiniMode: (isMini: boolean) => void
|
2025-08-18 15:00:55 +08:00
|
|
|
toggleFullscreen: () => void
|
2025-08-31 18:01:32 +08:00
|
|
|
onMusicCtrl: (callback: (event: Event, args: any) => void) => () => void
|
2025-08-18 18:44:10 +08:00
|
|
|
|
2025-08-18 13:04:06 +08:00
|
|
|
music: {
|
2025-08-18 13:18:50 +08:00
|
|
|
request: (api: string, args: any) => Promise<any>
|
2025-08-25 19:04:57 +08:00
|
|
|
requestSdk: <T extends keyof MainApi>(
|
|
|
|
|
method: T,
|
|
|
|
|
args: {
|
|
|
|
|
source: any
|
|
|
|
|
} & (MethodParams<T> extends object ? MethodParams<T> : { [key: string]: any })
|
|
|
|
|
) => ReturnType<MainApi[T]>
|
2025-08-16 15:37:53 +08:00
|
|
|
}
|
2025-08-18 13:04:06 +08:00
|
|
|
|
2025-08-26 18:23:20 +08:00
|
|
|
musicCache: {
|
|
|
|
|
getInfo: () => Promise<any>
|
|
|
|
|
clear: () => Promise
|
|
|
|
|
getSize: () => Promise<string>
|
|
|
|
|
},
|
|
|
|
|
|
2025-09-10 23:10:19 +08:00
|
|
|
// 歌单管理 API
|
|
|
|
|
songList: {
|
|
|
|
|
// === 歌单管理 ===
|
|
|
|
|
create: (name: string, description?: string, source?: string) => Promise<any>
|
|
|
|
|
getAll: () => Promise<any>
|
|
|
|
|
getById: (hashId: string) => Promise<any>
|
|
|
|
|
delete: (hashId: string) => Promise<any>
|
|
|
|
|
batchDelete: (hashIds: string[]) => Promise<any>
|
|
|
|
|
edit: (hashId: string, updates: any) => Promise<any>
|
|
|
|
|
updateCover: (hashId: string, coverImgUrl: string) => Promise<any>
|
|
|
|
|
search: (keyword: string, source?: string) => Promise<any>
|
|
|
|
|
getStatistics: () => Promise<any>
|
|
|
|
|
exists: (hashId: string) => Promise<any>
|
|
|
|
|
|
|
|
|
|
// === 歌曲管理 ===
|
|
|
|
|
addSongs: (hashId: string, songs: any[]) => Promise<any>
|
|
|
|
|
removeSong: (hashId: string, songmid: string | number) => Promise<any>
|
|
|
|
|
removeSongs: (hashId: string, songmids: (string | number)[]) => Promise<any>
|
|
|
|
|
clearSongs: (hashId: string) => Promise<any>
|
|
|
|
|
getSongs: (hashId: string) => Promise<any>
|
|
|
|
|
getSongCount: (hashId: string) => Promise<any>
|
|
|
|
|
hasSong: (hashId: string, songmid: string | number) => Promise<any>
|
|
|
|
|
getSong: (hashId: string, songmid: string | number) => Promise<any>
|
|
|
|
|
searchSongs: (hashId: string, keyword: string) => Promise<any>
|
|
|
|
|
getSongStatistics: (hashId: string) => Promise<any>
|
|
|
|
|
validateIntegrity: (hashId: string) => Promise<any>
|
|
|
|
|
repairData: (hashId: string) => Promise<any>
|
|
|
|
|
forceSave: (hashId: string) => Promise<any>
|
|
|
|
|
},
|
|
|
|
|
|
2025-08-17 23:27:40 +08:00
|
|
|
ai: {
|
2025-08-18 13:16:13 +08:00
|
|
|
ask: (prompt: string) => Promise<any>
|
|
|
|
|
askStream: (prompt: string, streamId: string) => Promise<any>
|
|
|
|
|
onStreamChunk: (callback: (data: { streamId: string; chunk: string }) => void) => void
|
|
|
|
|
onStreamEnd: (callback: (data: { streamId: string }) => void) => void
|
|
|
|
|
onStreamError: (callback: (data: { streamId: string; error: string }) => void) => void
|
|
|
|
|
removeStreamListeners: () => void
|
2025-08-17 23:27:40 +08:00
|
|
|
}
|
2025-08-19 19:51:37 +08:00
|
|
|
|
|
|
|
|
// 插件管理API
|
|
|
|
|
plugins: {
|
2025-08-20 18:38:23 +08:00
|
|
|
selectAndAddPlugin: (type: 'lx' | 'cr') => Promise<any>
|
|
|
|
|
uninstallPlugin(pluginId: string): ApiResult | PromiseLike<ApiResult>
|
2025-08-20 12:51:43 +08:00
|
|
|
addPlugin: (pluginCode: string, pluginName: string) => Promise<any>
|
|
|
|
|
getPluginById: (id: string) => Promise<any>
|
|
|
|
|
loadAllPlugins: () => Promise<any>
|
2025-08-22 15:11:35 +08:00
|
|
|
getPluginLog: (pluginId: string) => Promise<any>
|
2025-08-19 19:51:37 +08:00
|
|
|
}
|
2025-08-28 03:32:25 +08:00
|
|
|
ping: (callback: Function<any>) => undefined
|
|
|
|
|
pingService: {
|
|
|
|
|
start: () => undefined,
|
|
|
|
|
stop: () => undefined
|
|
|
|
|
}
|
2025-08-18 13:16:13 +08:00
|
|
|
// 用户配置API
|
|
|
|
|
getUserConfig: () => Promise<any>
|
2025-08-16 11:34:37 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-13 13:33:43 +08:00
|
|
|
declare global {
|
|
|
|
|
interface Window {
|
|
|
|
|
electron: ElectronAPI
|
2025-08-16 11:34:37 +08:00
|
|
|
api: CustomAPI
|
2025-08-13 13:33:43 +08:00
|
|
|
}
|
|
|
|
|
}
|