declare namespace IPlugin { export interface IMediaSourceResult { headers?: Record; /** 标准音质 */ url: string; /** 高品质 */ urlHQ?: string; /** 无损音质 */ urlSQ?: string; userAgent?: string; } 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 IUserEnv { key: string; name: string; } interface IPluginDefine { /** 来源名 */ platform: string; /** 匹配的版本号 */ appVersion?: string; /** 插件版本 */ version?: string; /** 远程更新的url */ srcUrl?: string; /** 主键,会被存储到mediameta中 */ primaryKey?: string[]; /** 默认搜索类型 */ defaultSearchType?: ICommon.SupportMediaType; /** 插件缓存控制 */ cacheControl?: 'cache' | 'no-cache' | 'no-store'; /** 用户自定义输入 */ userEnv?: IUserEnv[]; /** 搜索 */ search?: ISearchFunc; /** 获取根据音乐信息获取url */ getMediaSource?: ( musicItem: IMusic.IMusicItemBase, ) => Promise; /** 根据主键去查询歌曲信息 */ getMusicInfo?: ( musicBase: ICommon.IMediaBase, ) => Promise | null>; /** 获取歌词 */ getLyric?: ( musicItem: IMusic.IMusicItemBase, ) => Promise; /** 获取专辑信息,里面的歌曲不要分页 */ getAlbumInfo?: ( albumItem: IAlbum.IAlbumItemBase, ) => Promise; /** 获取作品,有分页 */ getArtistWorks?: IGetArtistWorksFunc; /** 导入歌单 */ // todo: 数据结构应该是IMusicSheetItem importMusicSheet?: ( urlLike: string, ) => Promise; /** 导入单曲 */ importMusicItem?: ( urlLike: string, ) => 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]; }; }