Files
katelyatv/src/lib/types.ts
T
3970260761 54fdea4f84
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s
Release / release (push) Canceled after 0s
Release / docker (push) Canceled after 0s
fixed73: 通知切授权公告+右上角版本号全页显示
- 首页旧公告弹窗彻底拆除(page.tsx: 删JSX/useSite/showAnnouncement/handleCloseAnnouncement残留)
- layout授权覆盖顺序修复: 先getConfig再hub.getNotice覆盖, 授权公告优先
- HubBell只发open-hub-notice事件, 不再清hasSeenAnnouncement/跳首页
- HubNotice支持铃铛手动打开: 公告/首条/版本兜底, 空指针修复
- 版本号三处补齐: TopRightButtons bar+float, MobileHeader移动端, 对齐fixed73
2026-11-08 00:19:48 +08:00

193 lines
5.4 KiB
TypeScript

import { AdminConfig } from './admin.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; // 搜索时使用的标题
}
// 片头片尾数据结构
export interface SkipSegment {
start: number; // 开始时间(秒)
end: number; // 结束时间(秒)
type: 'opening' | 'ending'; // 片头或片尾
title?: string; // 可选的描述
}
// 剧集跳过配置
export interface EpisodeSkipConfig {
source: string; // 资源站标识
id: string; // 剧集ID
title: string; // 剧集标题
segments: SkipSegment[]; // 跳过片段列表
updated_time: number; // 最后更新时间
}
// 收藏数据结构
export interface Favorite {
source_name: string;
total_episodes: number; // 总集数
title: string;
year: string;
cover: string;
save_time: number; // 记录保存时间(时间戳)
search_title: string; // 搜索时使用的标题
}
// 用户数据结构
export interface User {
username: string;
role?: string;
created_at?: string;
/** 注册时间为补记值(账号早于时间记录功能上线) */
created_at_estimated?: boolean;
last_login_at?: string;
/** 最后登录时间为估算值(按 Redis 键空闲时长推算) */
last_login_estimated?: boolean;
}
// 存储接口
export interface IStorage {
// 播放记录相关
getPlayRecord(userName: string, key: string): Promise<PlayRecord | null>;
setPlayRecord(
userName: string,
key: string,
record: PlayRecord
): Promise<void>;
getAllPlayRecords(userName: string): Promise<{ [key: string]: PlayRecord }>;
deletePlayRecord(userName: string, key: string): Promise<void>;
// 收藏相关
getFavorite(userName: string, key: string): Promise<Favorite | null>;
setFavorite(userName: string, key: string, favorite: Favorite): Promise<void>;
getAllFavorites(userName: string): Promise<{ [key: string]: Favorite }>;
deleteFavorite(userName: string, key: string): Promise<void>;
// 用户相关
registerUser(userName: string, password: string): Promise<void>;
verifyUser(userName: string, password: string): Promise<boolean>;
touchLogin?(userName: string): Promise<void>;
// 检查用户是否存在(无需密码)
checkUserExist(userName: string): Promise<boolean>;
// 修改用户密码
changePassword(userName: string, newPassword: string): Promise<void>;
// 删除用户(包括密码、搜索历史、播放记录、收藏夹)
deleteUser(userName: string): Promise<void>;
// 用户设置相关
getUserSettings(userName: string): Promise<UserSettings | null>;
setUserSettings(userName: string, settings: UserSettings): Promise<void>;
updateUserSettings(userName: string, settings: Partial<UserSettings>): Promise<void>;
// 搜索历史相关
getSearchHistory(userName: string): Promise<string[]>;
addSearchHistory(userName: string, keyword: string): Promise<void>;
deleteSearchHistory(userName: string, keyword?: string): Promise<void>;
// 片头片尾跳过配置相关
getSkipConfig(userName: string, key: string): Promise<EpisodeSkipConfig | null>;
setSkipConfig(userName: string, key: string, config: EpisodeSkipConfig): Promise<void>;
getAllSkipConfigs(userName: string): Promise<{ [key: string]: EpisodeSkipConfig }>;
deleteSkipConfig(userName: string, key: string): Promise<void>;
// 用户列表
getAllUsers(): Promise<User[]>;
// 管理员配置相关
getAdminConfig(): Promise<AdminConfig | null>;
setAdminConfig(config: AdminConfig): Promise<void>;
}
// 搜索结果数据结构
export interface SearchResult {
id: string;
title: string;
poster: string;
episodes: string[];
source: string;
source_name: string;
class?: string;
year: string;
desc?: string;
type_name?: string;
douban_id?: number;
actor?: string;
director?: string;
score?: string;
score_num?: number;
douban_score?: string;
area?: string;
lang?: string;
}
// 豆瓣数据结构
export interface DoubanItem {
id: string;
title: string;
poster: string;
rate: string;
year: string;
}
export interface DoubanResult {
code: number;
message: string;
list: DoubanItem[];
}
// 资源站配置
export interface ApiSite {
api: string;
name: string;
detail?: string;
type?: number;
playMode?: 'parse' | 'direct';
is_adult?: boolean; // 新增:是否为成人内容资源站
}
// 配置文件结构
export interface Config {
cache_time: number;
api_site: { [key: string]: ApiSite };
}
// 用户设置
export interface UserSettings {
filter_adult_content: boolean; // 是否过滤成人内容,默认为 true
theme: 'light' | 'dark' | 'auto';
language: string;
auto_play: boolean;
video_quality: string;
[key: string]: string | boolean | number; // 允许其他设置
}
// 搜索结果(支持成人内容分组)
export interface GroupedSearchResults {
regular_results: SearchResult[];
adult_results?: SearchResult[];
}
// Runtime配置类型
export interface RuntimeConfig {
STORAGE_TYPE?: string;
ENABLE_REGISTER?: boolean;
IMAGE_PROXY?: string;
DOUBAN_PROXY?: string;
}
// 全局Window类型扩展
declare global {
interface Window {
RUNTIME_CONFIG?: RuntimeConfig;
}
}