Files
AlgerMusicPlayer/src/preload/index.d.ts
T

84 lines
3.5 KiB
TypeScript
Raw Normal View History

import { ElectronAPI } from '@electron-toolkit/preload';
import type { AppUpdateState } from '../shared/appUpdate';
2025-04-12 23:16:12 +08:00
interface API {
minimize: () => void;
maximize: () => void;
close: () => void;
2025-12-20 18:32:14 +08:00
quitApp: () => void;
2025-04-12 23:16:12 +08:00
dragStart: (data: any) => void;
miniTray: () => void;
miniWindow: () => void;
restore: () => void;
restart: () => void;
resizeWindow: (width: number, height: number) => void;
resizeMiniWindow: (showPlaylist: boolean) => void;
openLyric: () => void;
sendLyric: (data: any) => void;
sendSong: (data: any) => void;
unblockMusic: (id: number, data: any, enabledSources?: string[]) => Promise<any>;
2025-04-12 23:16:12 +08:00
onLyricWindowClosed: (callback: () => void) => void;
onLyricWindowReady: (callback: () => void) => void;
getAppUpdateState: () => Promise<AppUpdateState>;
checkAppUpdate: (manual?: boolean) => Promise<AppUpdateState>;
downloadAppUpdate: () => Promise<AppUpdateState>;
installAppUpdate: () => Promise<boolean>;
openAppUpdatePage: () => Promise<boolean>;
onAppUpdateState: (callback: (state: AppUpdateState) => void) => void;
removeAppUpdateListeners: () => void;
2025-04-12 23:16:12 +08:00
onLanguageChanged: (callback: (locale: string) => void) => void;
2025-09-09 22:05:48 +08:00
importCustomApiPlugin: () => Promise<{ name: string; content: string } | null>;
2025-12-13 15:00:38 +08:00
importLxMusicScript: () => Promise<{ name: string; content: string } | null>;
2025-04-12 23:16:12 +08:00
invoke: (channel: string, ...args: any[]) => Promise<any>;
2025-09-10 01:11:06 +08:00
getSearchSuggestions: (keyword: string) => Promise<any>;
2025-12-20 18:32:14 +08:00
lxMusicHttpRequest: (request: { url: string; options: any; requestId: string }) => Promise<any>;
2025-12-20 02:29:22 +08:00
lxMusicHttpCancel: (requestId: string) => Promise<void>;
2026-02-06 17:49:14 +08:00
/** 扫描指定文件夹中的本地音乐文件 */
scanLocalMusic: (folderPath: string) => Promise<{ files: string[]; count: number }>;
/** 扫描指定文件夹中的本地音乐文件(包含修改时间) */
scanLocalMusicWithStats: (
folderPath: string
) => Promise<{ files: { path: string; modifiedTime: number }[]; count: number }>;
2026-02-06 17:49:14 +08:00
/** 批量解析本地音乐文件元数据 */
parseLocalMusicMetadata: (
filePaths: string[]
) => Promise<import('../renderer/types/localMusic').LocalMusicMeta[]>;
// Download manager
downloadAdd: (task: any) => Promise<string>;
downloadAddBatch: (tasks: any) => Promise<{ batchId: string; taskIds: string[] }>;
downloadPause: (taskId: string) => Promise<void>;
downloadResume: (taskId: string) => Promise<void>;
downloadCancel: (taskId: string) => Promise<void>;
downloadCancelAll: () => Promise<void>;
downloadGetQueue: () => Promise<any[]>;
downloadSetConcurrency: (n: number) => void;
downloadGetCompleted: () => Promise<any[]>;
downloadDeleteCompleted: (filePath: string) => Promise<boolean>;
downloadClearCompleted: () => Promise<boolean>;
getEmbeddedLyrics: (filePath: string) => Promise<string | null>;
downloadProvideUrl: (taskId: string, url: string) => Promise<void>;
onDownloadProgress: (cb: (data: any) => void) => void;
onDownloadStateChange: (cb: (data: any) => void) => void;
onDownloadBatchComplete: (cb: (data: any) => void) => void;
onDownloadRequestUrl: (cb: (data: any) => void) => void;
removeDownloadListeners: () => void;
2025-04-12 23:16:12 +08:00
}
// 自定义IPC渲染进程通信接口
interface IpcRenderer {
send: (channel: string, ...args: any[]) => void;
invoke: (channel: string, ...args: any[]) => Promise<any>;
on: (channel: string, listener: (...args: any[]) => void) => () => void;
removeAllListeners: (channel: string) => void;
}
declare global {
interface Window {
electron: ElectronAPI;
2025-04-12 23:16:12 +08:00
api: API;
ipcRenderer: IpcRenderer;
2025-01-10 22:49:55 +08:00
$message: any;
}
}