UI: Toolbar als Symbol-Buttons (nur-lokal, Auffrischen, Zahnrad), Einstellungen erweitert (Genre-Schlagwörter, Alter-Vorschläge, persistiert in settings.json)
This commit is contained in:
@ -435,6 +435,38 @@ fn now_ms() -> u128 {
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// App-Einstellungen (persistiert, kleine JSON).
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct Prefs {
|
||||
#[serde(default = "default_genre_keywords")]
|
||||
pub genre_keywords: String,
|
||||
#[serde(default = "default_alter_suggestions")]
|
||||
pub alter_suggestions: String,
|
||||
}
|
||||
|
||||
fn default_genre_keywords() -> String { "kinder,jugend".into() }
|
||||
fn default_alter_suggestions() -> String { "ab 3, ab 6, ab 8, ab 10, ab 12, ab 16".into() }
|
||||
|
||||
fn prefs_path() -> PathBuf {
|
||||
books_dir().parent().map(|p| p.join("settings.json")).unwrap_or_else(|| PathBuf::from("settings.json"))
|
||||
}
|
||||
|
||||
pub fn prefs_load() -> Prefs {
|
||||
fs::read_to_string(prefs_path())
|
||||
.ok()
|
||||
.and_then(|t| serde_json::from_str(&t).ok())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn prefs_save(p: &Prefs) -> Result<(), String> {
|
||||
if let Some(parent) = prefs_path().parent() { let _ = fs::create_dir_all(parent); }
|
||||
let path = prefs_path();
|
||||
let tmp = path.with_extension("json.tmp");
|
||||
fs::write(&tmp, serde_json::to_vec(p).unwrap_or_default())
|
||||
.map_err(|e| format!("Einstellungen schreiben: {e}"))?;
|
||||
fs::rename(&tmp, &path).map_err(|e| format!("Einstellungen speichern: {e}"))
|
||||
}
|
||||
|
||||
/// Serien-Zuordnung fürs Gruppieren (T-Feedback): asin → (Titel, Position).
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SerieRef {
|
||||
|
||||
@ -176,6 +176,20 @@ async fn book_series_bulk(refresh: bool) -> Result<BTreeMap<String, audible::Ser
|
||||
.map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_prefs() -> Result<audible::Prefs, String> {
|
||||
tauri::async_runtime::spawn_blocking(audible::prefs_load)
|
||||
.await
|
||||
.map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn set_prefs(prefs: audible::Prefs) -> Result<(), String> {
|
||||
tauri::async_runtime::spawn_blocking(move || audible::prefs_save(&prefs))
|
||||
.await
|
||||
.map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))?
|
||||
}
|
||||
|
||||
/// Einzeldetails (Beschreibung u. a.) per Audible-API, on demand.
|
||||
#[tauri::command]
|
||||
async fn book_details(asin: String) -> Result<audible::BookExtra, String> {
|
||||
@ -302,6 +316,8 @@ pub fn run() {
|
||||
get_library,
|
||||
get_local_books,
|
||||
book_series_bulk,
|
||||
get_prefs,
|
||||
set_prefs,
|
||||
book_details,
|
||||
stream_only,
|
||||
get_alter_notes,
|
||||
|
||||
Reference in New Issue
Block a user