修复因弹幕缓存导致弹幕过滤功能失效的bug
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
## [201.0.1] - 2025-12-10
|
||||
|
||||
### Fixed
|
||||
- 修复因弹幕缓存导致弹幕过滤功能失效的bug
|
||||
|
||||
## [201.0.0] - 2025-12-10
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1 +1 @@
|
||||
201.0.0
|
||||
201.0.1
|
||||
@@ -1857,7 +1857,40 @@ function PlayPageClient() {
|
||||
}
|
||||
|
||||
// 转换弹幕格式
|
||||
const danmakuData = convertDanmakuFormat(comments);
|
||||
let danmakuData = convertDanmakuFormat(comments);
|
||||
|
||||
// 手动应用过滤规则(因为缓存的弹幕不会经过播放器的 filter 函数)
|
||||
const filterConfig = danmakuFilterConfigRef.current;
|
||||
if (filterConfig && filterConfig.rules.length > 0) {
|
||||
const originalCount = danmakuData.length;
|
||||
danmakuData = danmakuData.filter((danmu) => {
|
||||
for (const rule of filterConfig.rules) {
|
||||
// 跳过未启用的规则
|
||||
if (!rule.enabled) continue;
|
||||
|
||||
try {
|
||||
if (rule.type === 'normal') {
|
||||
// 普通模式:字符串包含匹配
|
||||
if (danmu.text.includes(rule.keyword)) {
|
||||
return false;
|
||||
}
|
||||
} else if (rule.type === 'regex') {
|
||||
// 正则模式:正则表达式匹配
|
||||
if (new RegExp(rule.keyword).test(danmu.text)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('弹幕过滤规则错误:', e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const filteredCount = originalCount - danmakuData.length;
|
||||
if (filteredCount > 0) {
|
||||
console.log(`弹幕过滤: 原始 ${originalCount} 条,过滤 ${filteredCount} 条,剩余 ${danmakuData.length} 条`);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载弹幕到插件
|
||||
danmakuPluginRef.current.config({
|
||||
@@ -1865,8 +1898,8 @@ function PlayPageClient() {
|
||||
});
|
||||
danmakuPluginRef.current.load();
|
||||
|
||||
setDanmakuCount(comments.length);
|
||||
console.log(`弹幕加载成功,共 ${comments.length} 条`);
|
||||
setDanmakuCount(danmakuData.length);
|
||||
console.log(`弹幕加载成功,共 ${danmakuData.length} 条`);
|
||||
|
||||
// 延迟一下让用户看到弹幕数量
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
@@ -4075,6 +4108,16 @@ function PlayPageClient() {
|
||||
onConfigUpdate={(config) => {
|
||||
setDanmakuFilterConfig(config);
|
||||
danmakuFilterConfigRef.current = config;
|
||||
|
||||
// 重新加载弹幕以应用新的过滤规则
|
||||
if (danmakuPluginRef.current) {
|
||||
try {
|
||||
danmakuPluginRef.current.load();
|
||||
console.log('弹幕过滤规则已更新,重新加载弹幕');
|
||||
} catch (error) {
|
||||
console.error('重新加载弹幕失败:', error);
|
||||
}
|
||||
}
|
||||
}}
|
||||
onShowToast={(message, type) => {
|
||||
setToast({
|
||||
|
||||
@@ -10,6 +10,18 @@ export interface ChangelogEntry {
|
||||
}
|
||||
|
||||
export const changelog: ChangelogEntry[] = [
|
||||
{
|
||||
version: '201.0.1',
|
||||
date: '2025-12-10',
|
||||
added: [
|
||||
],
|
||||
changed: [
|
||||
|
||||
],
|
||||
fixed: [
|
||||
'修复因弹幕缓存导致弹幕过滤功能失效的bug'
|
||||
]
|
||||
},
|
||||
{
|
||||
version: '201.0.0',
|
||||
date: '2025-12-10',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const CURRENT_VERSION = '201.0.0';
|
||||
const CURRENT_VERSION = '201.0.1';
|
||||
|
||||
// 导出当前版本号供其他地方使用
|
||||
export { CURRENT_VERSION };
|
||||
|
||||
Reference in New Issue
Block a user