Implement SFW content filtering in LoraModal and update settings management

This commit is contained in:
Will Miao
2025-03-12 22:57:21 +08:00
parent e992ace11c
commit 7f088e58bc
3 changed files with 50 additions and 7 deletions

View File

@@ -44,6 +44,12 @@ export class SettingsManager {
blurMatureContentCheckbox.checked = state.settings.blurMatureContent;
}
const showOnlySFWCheckbox = document.getElementById('showOnlySFW');
if (showOnlySFWCheckbox) {
// Sync with state (backend will set this via template)
state.settings.show_only_sfw = showOnlySFWCheckbox.checked;
}
// Backend settings are loaded from the template directly
}
@@ -60,14 +66,15 @@ export class SettingsManager {
// Get frontend settings from UI
const blurMatureContent = document.getElementById('blurMatureContent').checked;
// Update frontend state and save to localStorage
state.settings.blurMatureContent = blurMatureContent;
saveSettings();
// Get backend settings
const apiKey = document.getElementById('civitaiApiKey').value;
const showOnlySFW = document.getElementById('showOnlySFW').checked;
// Update frontend state and save to localStorage
state.settings.blurMatureContent = blurMatureContent;
state.settings.show_only_sfw = showOnlySFW;
saveSettings();
try {
// Save backend settings via API
const response = await fetch('/api/settings', {
@@ -108,6 +115,9 @@ export class SettingsManager {
img.classList.remove('nsfw-blur');
}
});
// For show_only_sfw, there's no immediate action needed as it affects content loading
// The setting will take effect on next reload
}
}