1declare namespace IPlugin { 2 export interface IMediaSourceResult { 3 headers?: Record<string, string>; 4 url: string; 5 userAgent?: string; 6 } 7 8 export interface ISearchResult<T extends ICommon.SupportMediaType> { 9 isEnd?: boolean; 10 data: ICommon.SupportMediaItemBase[T][]; 11 } 12 13 export type ISearchResultType = ICommon.SupportMediaType; 14 15 type ISearchFunc = <T extends ICommon.SupportMediaType>( 16 query: string, 17 page: number, 18 type: T, 19 ) => Promise<ISearchResult<T>>; 20 21 type IGetArtistWorksFunc = <T extends IArtist.ArtistMediaType>( 22 artistItem: IArtist.IArtistItem, 23 page: number, 24 type: T, 25 ) => Promise<ISearchResult<T>>; 26 27 interface IPluginDefine { 28 /** 来源名 */ 29 platform: string; 30 /** 匹配的版本号 */ 31 appVersion?: string; 32 /** 插件版本 */ 33 version?: string; 34 /** 远程更新的url */ 35 srcUrl?: string; 36 /** 主键,会被存储到mediameta中 */ 37 primaryKey?: string[]; 38 /** 默认搜索类型 */ 39 defaultSearchType?: ICommon.SupportMediaType; 40 /** 插件缓存控制 */ 41 cacheControl?: 'cache' | 'no-cache' | 'no-store'; 42 /** 搜索 */ 43 search?: ISearchFunc; 44 /** 获取根据音乐信息获取url */ 45 getMediaSource?: ( 46 musicItem: IMusic.IMusicItemBase, 47 ) => Promise<IMediaSourceResult | null>; 48 /** 根据主键去查询歌曲信息 */ 49 getMusicInfo?: ( 50 musicBase: ICommon.IMediaBase, 51 ) => Promise<IMusic.IMusicItem | null>; 52 /** 获取歌词 */ 53 getLyric?: ( 54 musicItem: IMusic.IMusicItemBase, 55 ) => Promise<ILyric.ILyricSource | null>; 56 /** 获取专辑信息,里面的歌曲不要分页 */ 57 getAlbumInfo?: ( 58 albumItem: IAlbum.IAlbumItemBase, 59 ) => Promise<IAlbum.IAlbumItem | null>; 60 /** 获取作品,有分页 */ 61 getArtistWorks?: IGetArtistWorksFunc; 62 /** 导入歌单 */ 63 importMusicSheet?: ( 64 urlLike: string, 65 ) => Promise<IMusic.IMusicItem[] | null>; 66 /** 导入单曲 */ 67 importMusicItem?: ( 68 urlLike: string, 69 ) => Promise<IMusic.IMusicItem | null>; 70 } 71 72 export interface IPluginInstance extends IPluginDefine { 73 /** 内部属性 */ 74 /** 插件路径 */ 75 _path: string; 76 } 77 78 type R = Required<IPluginInstance>; 79 export type IPluginInstanceMethods = { 80 [K in keyof R as R[K] extends (...args: any) => any ? K : never]: R[K]; 81 }; 82} 83