diff --git a/src-tauri/src/conf/app.rs b/src-tauri/src/conf/app.rs index 3290c43..efe81c3 100644 --- a/src-tauri/src/conf/app.rs +++ b/src-tauri/src/conf/app.rs @@ -9,6 +9,8 @@ pub struct AppConfig { pub open_links_in_browser: Option, pub admin_password: Option, pub show_window_on_startup: Option, + pub log_filter_level: Option, + pub log_filter_source: Option, } 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()), } } } diff --git a/src-tauri/src/utils/path.rs b/src-tauri/src/utils/path.rs index 663c9fd..4fc3e26 100644 --- a/src-tauri/src/utils/path.rs +++ b/src-tauri/src/utils/path.rs @@ -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 { +fn normalize_path(path: &Path) -> Result { #[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 { Ok(canonical) } } - + #[cfg(not(target_os = "windows"))] { path.canonicalize() diff --git a/src/types/types.d.ts b/src/types/types.d.ts index f227955..8315d3b 100644 --- a/src/types/types.d.ts +++ b/src/types/types.d.ts @@ -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 { diff --git a/src/views/LogView.vue b/src/views/LogView.vue index 07175d9..3e74dfc 100644 --- a/src/views/LogView.vue +++ b/src/views/LogView.vue @@ -33,8 +33,8 @@ const logContainer = ref() const searchInputRef = ref() const autoScroll = ref(true) const isPaused = ref(false) -const filterLevel = ref('all') -const filterSource = ref(localStorage.getItem('logFilterSource') || 'openlist') +const filterLevel = ref(appStore.settings.app.log_filter_level || 'all') +const filterSource = ref(appStore.settings.app.log_filter_source || 'openlist') const searchQuery = ref('') const selectedEntries = ref>(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() })