feat: 实现成人内容过滤设置的动态处理,优化搜索API的缓存控制

This commit is contained in:
katelya
2025-09-05 11:37:25 +08:00
parent f0d2ea9d14
commit bdfad48656
4 changed files with 59 additions and 5 deletions
+12
View File
@@ -68,6 +68,18 @@ const AdultContentFilter: React.FC<AdultContentFilterProps> = ({
if (response.ok) {
const newState = !isEnabled;
setIsEnabled(newState);
// 强制刷新用户设置缓存 - 向搜索API发送一个空请求来刷新设置
try {
await fetch('/api/search?q=_cache_refresh_', {
headers: {
'Authorization': `Bearer ${userName}`,
},
});
} catch {
// 忽略刷新缓存的错误
}
onUpdate?.(newState);
} else {
const errorData = await response.json();