Files
AlgerMusicPlayer/src/preload/index.d.ts
T
alger bc46024499 refactor(download): 重构下载系统,支持暂停/恢复/取消,修复歌词加载
- 新建 DownloadManager 类(主进程),每个任务独立 AbortController 控制
- 新建 Pinia useDownloadStore 作为渲染进程单一数据源
- 支持暂停/恢复/取消下载,支持断点续传(Range header)
- 批量下载全部完成后发送汇总系统通知,单首不重复通知
- 并发数可配置(1-5),队列持久化(重启后恢复)
- 修复下载列表不全、封面加载失败、通知重复等 bug
- 修复本地/下载歌曲歌词加载:优先从 ID3/FLAC 元数据提取,API 作为 fallback
- 删除 useDownloadStatus.ts,统一状态管理
- DownloadDrawer/DownloadPage 全面重写,移除 @apply 违规
- 新增 5 语言 i18n 键值(暂停/恢复/取消/排队中等)
2026-03-27 23:02:08 +08:00

84 lines
3.5 KiB
TypeScript

import { ElectronAPI } from '@electron-toolkit/preload';
import type { AppUpdateState } from '../shared/appUpdate';
interface API {
minimize: () => void;
maximize: () => void;
close: () => void;
quitApp: () => void;
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>;
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;
onLanguageChanged: (callback: (locale: string) => void) => void;
importCustomApiPlugin: () => Promise<{ name: string; content: string } | null>;
importLxMusicScript: () => Promise<{ name: string; content: string } | null>;
invoke: (channel: string, ...args: any[]) => Promise<any>;
getSearchSuggestions: (keyword: string) => Promise<any>;
lxMusicHttpRequest: (request: { url: string; options: any; requestId: string }) => Promise<any>;
lxMusicHttpCancel: (requestId: string) => Promise<void>;
/** 扫描指定文件夹中的本地音乐文件 */
scanLocalMusic: (folderPath: string) => Promise<{ files: string[]; count: number }>;
/** 扫描指定文件夹中的本地音乐文件(包含修改时间) */
scanLocalMusicWithStats: (
folderPath: string
) => Promise<{ files: { path: string; modifiedTime: number }[]; count: number }>;
/** 批量解析本地音乐文件元数据 */
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;
}
// 自定义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;
api: API;
ipcRenderer: IpcRenderer;
$message: any;
}
}