功能更新: 目录点击跳转、翻页按钮移至底部右侧、所有按钮添加悬停提示

This commit is contained in:
2026-05-14 17:28:40 +08:00
parent 88afb217c6
commit b0071c6617
4 changed files with 297 additions and 65 deletions

View File

@@ -19,6 +19,33 @@ pub struct AppState {
pub error_message: Option<String>,
}
impl AppState {
pub fn prev_page(&mut self) {
if let Some(ref book) = self.book {
if self.current_page > 0 {
self.current_page -= 1;
} else if self.current_section > 0 {
self.current_section -= 1;
self.current_page = book.sections[self.current_section]
.pages.len().saturating_sub(2);
}
}
}
pub fn next_page(&mut self) {
if let Some(ref book) = self.book {
if self.current_page + 1 < book.sections[self.current_section]
.pages.len().saturating_sub(1)
{
self.current_page += 1;
} else if self.current_section + 1 < book.sections.len() {
self.current_section += 1;
self.current_page = 0;
}
}
}
}
impl App {
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
let settings_dir = persistence::settings_dir();
@@ -174,10 +201,18 @@ impl eframe::App for App {
if action.toggle_theme {
self.settings.theme = match self.settings.theme {
theme::Theme::Light => theme::Theme::Dark,
theme::Theme::Dark => theme::Theme::Light,
theme::Theme::Dark => theme::Theme::Sepia,
theme::Theme::Sepia => theme::Theme::Light,
};
ctx.set_style(theme::create_style(&self.settings.theme));
}
if action.page_prev {
self.state.prev_page();
}
if action.page_next {
self.state.next_page();
}
});
self.save_reading_position();