declare namespace IPlugin { export interface IMediaSourceResult { headers?: Record; /** 兜底播放 */ url?: string; /** UA */ userAgent?: string; /** 音质 */ quality?: IMusic.IQualityKey; } export interface ISearchResult { isEnd?: boolean; data: ICommon.SupportMediaItemBase[T][]; } export type ISearchResultType = ICommon.SupportMediaType; type ISearchFunc = ( query: string, page: number, type: T, ) => Promise>; type IGetArtistWorksFunc = ( artistItem: IArtist.IArtistItem, page: number, type: T, ) => Promise>; interface IUserVariable { /** 键 */ key: string; /** 名称 */ name?: string; } interface IAlbumInfoResult { isEnd?: boolean; albumItem?: IAlbum.IAlbumItemBase; musicList?: IMusic.IMusicItem[]; } interface ISheetInfoResult { isEnd?: boolean; sheetItem?: IMusic.IMusicSheetItemBase; musicList?: IMusic.IMusicItem[]; } interface IGetRecommendSheetTagsResult { // 固定的tag pinned?: IMusic.IMusicSheetItemBase[]; data?: IMusic.IMusicSheetGroupItem[]; } interface IPluginDefine { /** 来源名 */ platform: string; /** 匹配的版本号 */ appVersion?: string; /** 插件版本 */ version?: string; /** 远程更新的url */ srcUrl?: string; /** 主键,会被存储到mediameta中 */ primaryKey?: string[]; /** 默认搜索类型 */ defaultSearchType?: ICommon.SupportMediaType; /** 有效搜索类型 */ supportedSearchType?: ICommon.SupportMediaType[]; /** 插件缓存控制 */ cacheControl?: 'cache' | 'no-cache' | 'no-store'; /** 用户自定义输入 */ userVariables?: IUserVariable[]; /** 提示文本 */ hints?: Record; /** 搜索 */ search?: ISearchFunc; /** 获取根据音乐信息获取url */ getMediaSource?: ( musicItem: IMusic.IMusicItemBase, quality: IMusic.IQualityKey, ) => Promise; /** 根据主键去查询歌曲信息 */ getMusicInfo?: ( musicBase: ICommon.IMediaBase, ) => Promise | null>; /** 获取歌词 */ getLyric?: ( musicItem: IMusic.IMusicItemBase, ) => Promise; /** 获取专辑信息,里面的歌曲分页 */ getAlbumInfo?: ( albumItem: IAlbum.IAlbumItemBase, page: number, ) => Promise; /** 获取歌单信息,有分页 */ getMusicSheetInfo?: ( sheetItem: IMusic.IMusicSheetItem, page: number, ) => Promise; /** 获取作品,有分页 */ getArtistWorks?: IGetArtistWorksFunc; /** 导入歌单 */ // todo: 数据结构应该是IMusicSheetItem importMusicSheet?: ( urlLike: string, ) => Promise; /** 导入单曲 */ importMusicItem?: ( urlLike: string, ) => Promise; /** 获取榜单 */ getTopLists?: () => Promise; // todo:分页 /** 获取榜单详情 */ getTopListDetail?: ( topListItem: IMusic.IMusicSheetItemBase, ) => Promise>; /** 获取热门歌单tag */ getRecommendSheetTags?: () => Promise; /** 歌单列表 */ getRecommendSheetsByTag?: ( tag: ICommon.IUnique, page?: number, ) => Promise>; } export interface IPluginInstance extends IPluginDefine { /** 内部属性 */ /** 插件路径 */ _path: string; } type R = Required; export type IPluginInstanceMethods = { [K in keyof R as R[K] extends (...args: any) => any ? K : never]: R[K]; }; /** 插件其他属性 */ export type IPluginMeta = { order: number; userVariables: Record; }; }