Files
CeruMusic/src/preload/index.d.ts

57 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-08-13 13:33:43 +08:00
import { ElectronAPI } from '@electron-toolkit/preload'
import { MainApi, MethodParams } from '../main/services/musicSdk/index'
2025-08-16 11:34:37 +08:00
// 自定义 API 接口
interface CustomAPI {
minimize: () => void
maximize: () => void
close: () => void
setMiniMode: (isMini: boolean) => void
2025-08-18 15:00:55 +08:00
toggleFullscreen: () => void
onMusicCtrl: (callback: (event: Event, args: any) => void) => void
2025-08-18 13:04:06 +08:00
music: {
request: (api: string, args: any) => Promise<any>
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
musicCache: {
getInfo: () => Promise<any>
clear: () => Promise
getSize: () => Promise<string>
},
ai: {
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-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>
getPluginLog: (pluginId: string) => Promise<any>
2025-08-19 19:51:37 +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
}
}