4 Commits

Author SHA1 Message Date
Suyunmeng
c79bb5ef45 feat(ui): persist log filter preferences in settings file
- Add log_filter_level and log_filter_source to AppConfig
- Remove localStorage usage, use persistent settings instead
- Filter preferences now survive app restarts
2025-11-08 10:40:21 +08:00
Suyunmeng
0be1dee772 fix(clippy): use &Path instead of &PathBuf in normalize_path 2025-11-08 10:16:05 +08:00
Suyunmeng
2bebb6a48b style: format code 2025-11-08 10:09:02 +08:00
Suyunmeng
54b98f1621 feat(ui): persist log level filter selection in localStorage 2025-11-08 10:03:19 +08:00
4 changed files with 19 additions and 7 deletions

View File

@@ -9,6 +9,8 @@ pub struct AppConfig {
pub open_links_in_browser: Option<bool>,
pub admin_password: Option<String>,
pub show_window_on_startup: Option<bool>,
pub log_filter_level: Option<String>,
pub log_filter_source: Option<String>,
}
impl AppConfig {
@@ -21,6 +23,8 @@ impl AppConfig {
open_links_in_browser: Some(false),
admin_password: None,
show_window_on_startup: Some(true),
log_filter_level: Some("all".to_string()),
log_filter_source: Some("openlist".to_string()),
}
}
}

View File

@@ -1,18 +1,18 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::{env, fs};
pub static APP_ID: &str = "io.github.openlistteam.openlist.desktop";
// Normalize path without Windows long path prefix (\\?\)
// The \\?\ prefix breaks compatibility with some applications like SQLite
fn normalize_path(path: &PathBuf) -> Result<PathBuf, String> {
fn normalize_path(path: &Path) -> Result<PathBuf, String> {
#[cfg(target_os = "windows")]
{
// On Windows, use canonicalize but strip the \\?\ prefix if present
let canonical = path
.canonicalize()
.map_err(|e| format!("Failed to canonicalize path: {e}"))?;
let path_str = canonical.to_string_lossy();
if let Some(stripped) = path_str.strip_prefix(r"\\?\") {
Ok(PathBuf::from(stripped))
@@ -20,7 +20,7 @@ fn normalize_path(path: &PathBuf) -> Result<PathBuf, String> {
Ok(canonical)
}
}
#[cfg(not(target_os = "windows"))]
{
path.canonicalize()

View File

@@ -52,6 +52,8 @@ interface AppConfig {
open_links_in_browser?: boolean
admin_password?: string
show_window_on_startup?: boolean
log_filter_level?: string
log_filter_source?: string
}
interface MergedSettings {

View File

@@ -33,8 +33,8 @@ const logContainer = ref<HTMLElement>()
const searchInputRef = ref<HTMLInputElement>()
const autoScroll = ref(true)
const isPaused = ref(false)
const filterLevel = ref<string>('all')
const filterSource = ref<string>(localStorage.getItem('logFilterSource') || 'openlist')
const filterLevel = ref<string>(appStore.settings.app.log_filter_level || 'all')
const filterSource = ref<string>(appStore.settings.app.log_filter_source || 'openlist')
const searchQuery = ref('')
const selectedEntries = ref<Set<number>>(new Set())
const showFilters = ref(true)
@@ -55,8 +55,14 @@ const confirmDialogConfig = ref({
onCancel: () => {}
})
watch(filterLevel, async newValue => {
appStore.settings.app.log_filter_level = newValue
await appStore.saveSettings()
})
watch(filterSource, async newValue => {
localStorage.setItem('logFilterSource', newValue)
appStore.settings.app.log_filter_source = newValue
await appStore.saveSettings()
await appStore.loadLogs((newValue !== 'gin' ? newValue : 'openlist') as filterSourceType)
await scrollToBottom()
})