2 Commits

Author SHA1 Message Date
GitHub Action
f3a5e2556f chore: bump version to 0.8.0 [skip ci] 2025-11-08 04:29:05 +00:00
Suyunmeng
a3a6ef03a5 feat(ui): persist log filter preferences in settings file
This commit improves the log viewer by persisting user filter preferences
across page navigation and application restarts.

Changes:
- Add log_filter_level and log_filter_source fields to AppConfig
- Store filter preferences in settings.json instead of localStorage
- Ensure filter preferences survive app restarts and page switches
- Fix clippy warning: use &Path instead of &PathBuf in normalize_path

The filter level and source selections are now saved to the persistent
settings file, providing a more reliable storage mechanism for Tauri
applications.
2025-11-08 11:19:18 +08:00
7 changed files with 22 additions and 10 deletions

View File

@@ -9,7 +9,7 @@
"tauri"
],
"private": true,
"version": "0.7.0",
"version": "0.8.0",
"author": {
"name": "OpenList Team",
"email": "96409857+Kuingsmile@users.noreply.github.com"

View File

@@ -1,6 +1,6 @@
[package]
name = "openlist-desktop"
version = "0.7.0"
version = "0.8.0"
description = "A Tauri App"
authors = ["Kuingsmile"]
edition = "2024"

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

@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "OpenList Desktop",
"version": "0.7.0",
"version": "0.8.0",
"identifier": "io.github.openlistteam.openlist.desktop",
"build": {
"beforeDevCommand": "yarn run dev",

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()
})