fix(styling): fullscreen kraft paper bg, persistence preset refresh, reader cleanup

This commit is contained in:
Developer
2026-05-14 22:50:01 +08:00
parent 0521439281
commit a82fa6b7b6
4 changed files with 56 additions and 30 deletions

View File

@@ -25,8 +25,20 @@ pub fn load_settings(dir: &Path) -> Result<Settings, String> {
let path = dir.join(SETTINGS_FILE);
let json = std::fs::read_to_string(&path)
.map_err(|e| format!("读取设置失败: {}", e))?;
serde_json::from_str(&json)
.map_err(|e| format!("解析设置失败: {}", e))
let mut settings: Settings = serde_json::from_str(&json)
.map_err(|e| format!("解析设置失败: {}", e))?;
// Always refresh profiles from code-defined presets so that updated
// preset values (font size, spacing, etc.) take effect even when
// an older settings.json is present on disk.
let preset_names: Vec<String> = crate::style::StyleProfile::presets()
.iter()
.map(|p| p.name.clone())
.collect();
settings.profiles = crate::style::StyleProfile::presets();
if !preset_names.contains(&settings.active_profile) {
settings.active_profile = "Kindle 默认".into();
}
Ok(settings)
}
#[cfg(test)]