import { AdminConfig } from './admin.types'; import { MangaReadRecord, MangaShelfItem } from './manga.types'; import { BookReadRecord, BookShelfItem } from './book.types'; // 播放记录数据结构 export interface PlayRecord { title: string; source_name: string; cover: string; year: string; index: number; // 第几集 total_episodes: number; // 总集数 play_time: number; // 播放进度(秒) total_time: number; // 总进度(秒) save_time: number; // 记录保存时间(时间戳) search_title: string; // 搜索时使用的标题 new_episodes?: number; // 新增的剧集数量(用于显示更新提示) } // 收藏数据结构 export interface Favorite { source_name: string; total_episodes: number; // 总集数 title: string; year: string; cover: string; save_time: number; // 记录保存时间(时间戳) search_title: string; // 搜索时使用的标题 origin?: 'vod' | 'live'; is_completed?: boolean; // 是否已完结 vod_remarks?: string; // 视频备注信息 } // 存储接口 export interface IStorage { // 播放记录相关 getPlayRecord(userName: string, key: string): Promise; setPlayRecord( userName: string, key: string, record: PlayRecord ): Promise; getAllPlayRecords(userName: string): Promise<{ [key: string]: PlayRecord }>; deletePlayRecord(userName: string, key: string): Promise; // 清理超出限制的旧播放记录 cleanupOldPlayRecords(userName: string): Promise; // 迁移播放记录 migratePlayRecords(userName: string): Promise; // 收藏相关 getFavorite(userName: string, key: string): Promise; setFavorite(userName: string, key: string, favorite: Favorite): Promise; getAllFavorites(userName: string): Promise<{ [key: string]: Favorite }>; deleteFavorite(userName: string, key: string): Promise; // 迁移收藏 migrateFavorites(userName: string): Promise; // 音乐播放记录相关 getMusicPlayRecord(userName: string, key: string): Promise; setMusicPlayRecord(userName: string, key: string, record: any): Promise; batchSetMusicPlayRecords(userName: string, records: { key: string; record: any }[]): Promise; getAllMusicPlayRecords(userName: string): Promise<{ [key: string]: any }>; deleteMusicPlayRecord(userName: string, key: string): Promise; clearAllMusicPlayRecords(userName: string): Promise; // 用户相关 verifyUser(userName: string, password: string): Promise; // 检查用户是否存在(无需密码) checkUserExist(userName: string): Promise; // 修改用户密码 changePassword(userName: string, newPassword: string): Promise; // 删除用户(包括密码、搜索历史、播放记录、收藏夹) deleteUser(userName: string): Promise; // 搜索历史相关 getSearchHistory(userName: string): Promise; addSearchHistory(userName: string, keyword: string): Promise; deleteSearchHistory(userName: string, keyword?: string): Promise; // 漫画书架相关 getMangaShelf(userName: string, key: string): Promise; setMangaShelf(userName: string, key: string, item: MangaShelfItem): Promise; getAllMangaShelf(userName: string): Promise<{ [key: string]: MangaShelfItem }>; deleteMangaShelf(userName: string, key: string): Promise; // 漫画阅读历史相关 getMangaReadRecord(userName: string, key: string): Promise; setMangaReadRecord(userName: string, key: string, record: MangaReadRecord): Promise; getAllMangaReadRecords(userName: string): Promise<{ [key: string]: MangaReadRecord }>; deleteMangaReadRecord(userName: string, key: string): Promise; cleanupOldMangaReadRecords?(userName: string): Promise; // 电子书书架相关 getBookShelf(userName: string, key: string): Promise; setBookShelf(userName: string, key: string, item: BookShelfItem): Promise; getAllBookShelf(userName: string): Promise<{ [key: string]: BookShelfItem }>; deleteBookShelf(userName: string, key: string): Promise; // 电子书阅读历史相关 getBookReadRecord(userName: string, key: string): Promise; setBookReadRecord(userName: string, key: string, record: BookReadRecord): Promise; getAllBookReadRecords(userName: string): Promise<{ [key: string]: BookReadRecord }>; deleteBookReadRecord(userName: string, key: string): Promise; cleanupOldBookReadRecords?(userName: string): Promise; // 用户列表 getAllUsers(): Promise; // 管理员配置相关 getAdminConfig(): Promise; setAdminConfig(config: AdminConfig): Promise; // 跳过片头片尾配置相关 getSkipConfig( userName: string, source: string, id: string ): Promise; setSkipConfig( userName: string, source: string, id: string, config: SkipConfig ): Promise; deleteSkipConfig(userName: string, source: string, id: string): Promise; getAllSkipConfigs(userName: string): Promise<{ [key: string]: SkipConfig }>; // 迁移跳过配置 migrateSkipConfigs(userName: string): Promise; // 弹幕过滤配置相关 getDanmakuFilterConfig(userName: string): Promise; setDanmakuFilterConfig( userName: string, config: DanmakuFilterConfig ): Promise; deleteDanmakuFilterConfig(userName: string): Promise; // 数据清理相关 clearAllData(): Promise; // 通用键值存储 getGlobalValue(key: string): Promise; setGlobalValue(key: string, value: string): Promise; deleteGlobalValue(key: string): Promise; // 通知相关 getNotifications(userName: string): Promise; addNotification(userName: string, notification: Notification): Promise; markNotificationAsRead(userName: string, notificationId: string): Promise; deleteNotification(userName: string, notificationId: string): Promise; clearAllNotifications(userName: string): Promise; getUnreadNotificationCount(userName: string): Promise; // 收藏更新检查相关 getLastFavoriteCheckTime(userName: string): Promise; setLastFavoriteCheckTime(userName: string, timestamp: number): Promise; // 求片冷却时间 updateLastMovieRequestTime?(userName: string, timestamp: number): Promise; // 求片相关 getAllMovieRequests(): Promise; getMovieRequest(requestId: string): Promise; createMovieRequest(request: MovieRequest): Promise; updateMovieRequest(requestId: string, updates: Partial): Promise; deleteMovieRequest(requestId: string): Promise; getUserMovieRequests(userName: string): Promise; addUserMovieRequest(userName: string, requestId: string): Promise; removeUserMovieRequest(userName: string, requestId: string): Promise; // 新版用户存储(V2)- 可选方法 getUserInfoV2?(userName: string): Promise<{ role: 'owner' | 'admin' | 'user'; banned: boolean; tags?: string[]; oidcSub?: string; enabledApis?: string[]; created_at: number; playrecord_migrated?: boolean; favorite_migrated?: boolean; skip_migrated?: boolean; last_movie_request_time?: number; email?: string; // 用户邮箱 emailNotifications?: boolean; // 是否接收邮件通知 } | null>; // 用户邮箱相关 getUserEmail?(userName: string): Promise; setUserEmail?(userName: string, email: string): Promise; getEmailNotificationPreference?(userName: string): Promise; setEmailNotificationPreference?(userName: string, enabled: boolean): Promise; // TVBox订阅token相关 getTvboxSubscribeToken?(userName: string): Promise; setTvboxSubscribeToken?(userName: string, token: string): Promise; getUsernameByTvboxToken?(token: string): Promise; } // 搜索结果数据结构 export interface SearchResult { id: string; title: string; poster: string; episodes: string[]; episodes_titles: string[]; source: string; source_name: string; weight?: number; // 播放源权重(来自后台配置,用于排序和优选评分) class?: string; year: string; desc?: string; type_name?: string; douban_id?: number; vod_remarks?: string; // 视频备注信息(如"全80集"、"更新至25集"等) vod_total?: number; // 总集数 proxyMode?: boolean; // 代理模式:启用后由服务器代理m3u8和ts分片 subtitles?: Array>; // 字幕列表(按集数索引) tmdb_id?: number; // TMDB ID rating?: number; // 评分 initialEpisodeIndex?: number; // 初始集数索引(用于小雅源从文件点击进入时指定集数) metadataSource?: 'folder' | 'nfo' | 'tmdb' | 'file'; // 元数据来源(用于小雅源判断是否保留fileName) } // 豆瓣数据结构 export interface DoubanItem { id: string; title: string; poster: string; rate: string; year: string; } export interface DoubanResult { code: number; message: string; list: DoubanItem[]; } // 跳过片头片尾配置数据结构 export interface SkipConfig { enable: boolean; // 是否启用跳过片头片尾 intro_time: number; // 片头时间(秒) outro_time: number; // 片尾时间(秒) } // 弹幕过滤规则数据结构 export interface DanmakuFilterRule { keyword: string; // 关键字 type: 'normal' | 'regex'; // 普通模式或正则模式 enabled: boolean; // 是否启用 id?: string; // 规则ID(用于前端管理) } // 弹幕过滤配置数据结构 export interface DanmakuFilterConfig { rules: DanmakuFilterRule[]; // 过滤规则列表 } // 集数过滤规则数据结构 export interface EpisodeFilterRule { keyword: string; // 关键字 type: 'normal' | 'regex'; // 普通模式或正则模式 enabled: boolean; // 是否启用 id?: string; // 规则ID(用于前端管理) } // 集数过滤配置数据结构 export interface EpisodeFilterConfig { rules: EpisodeFilterRule[]; // 过滤规则列表 reverseMode?: boolean; // 反向模式:开启后仅显示符合规则的集数 } // 通知类型枚举 export type NotificationType = | 'favorite_update' // 收藏更新 | 'manga_update' // 漫画更新 | 'system' // 系统通知 | 'announcement' // 公告 | 'movie_request' // 新求片通知(给管理员) | 'request_fulfilled' // 求片已上架通知(给求片用户) | 'anime_subscription_update'; // 追番订阅更新 // 通知数据结构 export interface Notification { id: string; // 通知ID type: NotificationType; // 通知类型 title: string; // 通知标题 message: string; // 通知内容 timestamp: number; // 通知时间戳 read: boolean; // 是否已读 metadata?: Record; // 额外的元数据(如收藏更新的source、id等) } // 收藏更新检查结果 export interface FavoriteUpdateCheck { last_check_time: number; // 上次检查时间戳 updates: Array<{ source: string; id: string; title: string; old_episodes: number; new_episodes: number; }>; } // 求片请求数据结构 export interface MovieRequest { id: string; tmdbId?: number; title: string; year?: string; mediaType: 'movie' | 'tv'; season?: number; // 季度(仅剧集) poster?: string; overview?: string; requestedBy: string[]; requestCount: number; status: 'pending' | 'fulfilled'; createdAt: number; updatedAt: number; fulfilledAt?: number; fulfilledSource?: string; fulfilledId?: string; }