## Phase 2 - 核心功能 (P0) - Issue #5: EPUB/MOBI/AZW3 格式支持 ✅ - 修复 mobi 库 API 调用 (content_raw → content_as_string) - 修复 title()/author() 返回类型 - 添加元数据提取功能 - Issue #6: Markdown 阅读模式 ✅ - 实现 parse_markdown_with_metadata - 支持 Front Matter (YAML) 解析 - 使用 pulldown-cmark 解析引擎 - 支持代码文件高亮 - Issue #7: 双语翻译功能 ✅ - 实现 TranslationService (阿里百炼/DeepL/Ollama) - 语言自动检测 - 双语对照 HTML 渲染 (并排/段落交错模式) - Issue #8: 笔记与书签系统 ✅ - BookmarkManager (高亮/下划线/波浪线/边注) - NoteManager (阅读笔记/想法/问题/总结) - 阅读统计 (时长/会话数/笔记数) - 导出 Markdown/CSV/Anki ## Phase 3 - 高级功能 (P1) - Issue #9: 代码阅读器 ✅ - 支持 20+ 编程语言 - syntect 语法高亮 - 行号显示/代码折叠 - Issue #10: 全文双语对照 ✅ - 段落级翻译对照 - 并排/交错两种模式 - 响应式布局 - Issue #11: 阅读进度同步 ✅ - 本地进度追踪 - 云端同步支持 - 多设备冲突解决 - Issue #12: 插件系统 ✅ - 插件加载/卸载/启用/禁用 - 插件依赖管理 - 内置主题/快捷键插件 ## Phase 4 - 性能与生态 (P1) - Issue #13: 性能优化 ✅ - PerformanceProfiler 性能分析 - CacheManager LRU 缓存 - 性能监控与优化建议 ## 技术栈更新 - 新增依赖:reqwest, uuid, chrono(serde) - 核心模块:8 个 (document/translation/bookmark/note/code_reader/progress/plugin/performance) - 代码量:~5000 行 --- 🚀 ReadFlow MVP 核心功能全部完成!
68 lines
1.6 KiB
Rust
68 lines
1.6 KiB
Rust
//! 配置管理模块
|
|
|
|
mod theme;
|
|
|
|
pub use theme::*;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct Config {
|
|
pub theme: ThemeConfig,
|
|
pub reader: ReaderConfig,
|
|
pub translation: TranslationConfig,
|
|
pub storage: StorageConfig,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ReaderConfig {
|
|
pub default_format: String,
|
|
pub scroll_smooth: bool,
|
|
pub show_toc: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TranslationConfig {
|
|
pub provider: String, // "google", "deepl", "ollama"
|
|
pub api_key: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct StorageConfig {
|
|
pub library_path: String,
|
|
pub cache_path: String,
|
|
}
|
|
|
|
impl Default for Config {
|
|
fn default() -> Self {
|
|
Self {
|
|
theme: ThemeConfig::default(),
|
|
reader: ReaderConfig {
|
|
default_format: "pdf".to_string(),
|
|
scroll_smooth: true,
|
|
show_toc: true,
|
|
},
|
|
translation: TranslationConfig {
|
|
provider: "ollama".to_string(),
|
|
api_key: None,
|
|
},
|
|
storage: StorageConfig {
|
|
library_path: "./library".to_string(),
|
|
cache_path: "./cache".to_string(),
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn load() -> Config {
|
|
// 从文件加载配置
|
|
Config {
|
|
theme: theme::load_config(),
|
|
..Config::default()
|
|
}
|
|
}
|
|
|
|
pub fn save(config: &Config) -> anyhow::Result<()> {
|
|
theme::save_config(&config.theme)?;
|
|
Ok(())
|
|
} |