120e2869eS猫头猫import {RequestStateCode} from '@/constants/commonConst'; 2bf6e62f2S猫头猫import {atom} from 'jotai'; 3bf6e62f2S猫头猫 4be474dd8S猫头猫/** 搜索状态 */ 520e2869eS猫头猫 60b940038S猫头猫export interface ISearchResult<T extends ICommon.SupportMediaType> { 70b940038S猫头猫 /** 当前页码 */ 80b940038S猫头猫 page?: number; 90b940038S猫头猫 /** 搜索词 */ 10bf6e62f2S猫头猫 query?: string; 110b940038S猫头猫 /** 搜索状态 */ 1220e2869eS猫头猫 state: RequestStateCode; 130b940038S猫头猫 /** 数据 */ 140b940038S猫头猫 data: ICommon.SupportMediaItemBase[T][]; 15bf6e62f2S猫头猫} 160b940038S猫头猫 170b940038S猫头猫type ISearchResults< 180b940038S猫头猫 T extends keyof ICommon.SupportMediaItemBase = ICommon.SupportMediaType, 190b940038S猫头猫> = { 200b940038S猫头猫 [K in T]: Record<string, ISearchResult<K>>; 210b940038S猫头猫}; 220b940038S猫头猫 230b940038S猫头猫/** 初始值 */ 240b940038S猫头猫export const initSearchResults: ISearchResults = { 250b940038S猫头猫 music: {}, 260b940038S猫头猫 album: {}, 270b940038S猫头猫 artist: {}, 28771839b6S猫头猫 sheet: {}, 29*39ac60f7S猫头猫 lyric: {}, 300b940038S猫头猫}; 310b940038S猫头猫 329d40a3faS猫头猫/** key: pluginhash value: searchResult */ 330b940038S猫头猫const searchResultsAtom = atom(initSearchResults); 34bf6e62f2S猫头猫 35bf6e62f2S猫头猫export enum PageStatus { 36bf6e62f2S猫头猫 /** 编辑中 */ 37bf6e62f2S猫头猫 EDITING = 'EDITING', 38bf6e62f2S猫头猫 /** 搜索中 */ 39bf6e62f2S猫头猫 SEARCHING = 'SEARCHING', 40bf6e62f2S猫头猫 /** 有结果 */ 41bf6e62f2S猫头猫 RESULT = 'RESULT', 42c30d30e1S猫头猫 /** 没有安装插件 */ 43c30d30e1S猫头猫 NO_PLUGIN = 'NO_PLUGIN', 44bf6e62f2S猫头猫} 45bf6e62f2S猫头猫 460b940038S猫头猫/** 当前正在搜索的 */ 47bf6e62f2S猫头猫const pageStatusAtom = atom<PageStatus>(PageStatus.EDITING); 48bf6e62f2S猫头猫 49bf6e62f2S猫头猫const queryAtom = atom<string>(''); 50bf6e62f2S猫头猫 510b940038S猫头猫export {pageStatusAtom, searchResultsAtom, queryAtom}; 52