增加剧集屏蔽功能
This commit is contained in:
@@ -1833,3 +1833,49 @@ export async function saveDanmakuFilterConfig(
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 集数过滤配置相关 API ----------------
|
||||
|
||||
/**
|
||||
* 获取集数过滤配置(纯 localStorage 存储)
|
||||
*/
|
||||
export async function getEpisodeFilterConfig(): Promise<EpisodeFilterConfig | null> {
|
||||
if (typeof window === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const raw = localStorage.getItem('moontv_episode_filter_config');
|
||||
if (!raw) return null;
|
||||
return JSON.parse(raw) as EpisodeFilterConfig;
|
||||
} catch (err) {
|
||||
console.error('读取集数过滤配置失败:', err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存集数过滤配置(纯 localStorage 存储)
|
||||
*/
|
||||
export async function saveEpisodeFilterConfig(
|
||||
config: EpisodeFilterConfig
|
||||
): Promise<void> {
|
||||
if (typeof window === 'undefined') {
|
||||
console.warn('无法在服务端保存集数过滤配置');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
localStorage.setItem('moontv_episode_filter_config', JSON.stringify(config));
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('episodeFilterConfigUpdated', {
|
||||
detail: config,
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('保存集数过滤配置失败:', err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -143,3 +143,16 @@ export interface DanmakuFilterRule {
|
||||
export interface DanmakuFilterConfig {
|
||||
rules: DanmakuFilterRule[]; // 过滤规则列表
|
||||
}
|
||||
|
||||
// 集数过滤规则数据结构
|
||||
export interface EpisodeFilterRule {
|
||||
keyword: string; // 关键字
|
||||
type: 'normal' | 'regex'; // 普通模式或正则模式
|
||||
enabled: boolean; // 是否启用
|
||||
id?: string; // 规则ID(用于前端管理)
|
||||
}
|
||||
|
||||
// 集数过滤配置数据结构
|
||||
export interface EpisodeFilterConfig {
|
||||
rules: EpisodeFilterRule[]; // 过滤规则列表
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user