From ac6d9e84c673633fdfb2dddab1b4e0542df964a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=83=D1=80=D0=BD=D0=B0=D1=82=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Sat, 14 Feb 2026 23:37:08 +0300 Subject: [PATCH] edit --- BookReader/Resources/Raw/wwwroot/index.html | 1044 +++++++++---------- BookReader/ViewModels/ReaderViewModel.cs | 4 + BookReader/Views/ReaderPage.xaml | 1 + BookReader/Views/ReaderPage.xaml.cs | 12 +- 4 files changed, 509 insertions(+), 552 deletions(-) diff --git a/BookReader/Resources/Raw/wwwroot/index.html b/BookReader/Resources/Raw/wwwroot/index.html index f99416f..4f76275 100644 --- a/BookReader/Resources/Raw/wwwroot/index.html +++ b/BookReader/Resources/Raw/wwwroot/index.html @@ -29,7 +29,7 @@ overflow: hidden; } - #book-content { + #book-content, #fb2-content { width: 100%; height: 100%; position: absolute; @@ -38,8 +38,6 @@ } #fb2-content { - width: 100%; - height: 100%; overflow: hidden; padding: 20px; font-size: 18px; @@ -58,14 +56,14 @@ gap: 15px; } - #loading .spinner { - width: 40px; - height: 40px; - border: 4px solid #ddd; - border-top: 4px solid #5D4037; - border-radius: 50%; - animation: spin 1s linear infinite; - } + .spinner { + width: 40px; + height: 40px; + border: 4px solid #ddd; + border-top-color: #5D4037; + border-radius: 50%; + animation: spin 1s linear infinite; + } @keyframes spin { to { @@ -86,23 +84,8 @@ gap: 10px; } - #debug-log { - position: fixed; - bottom: 0; - left: 0; - right: 0; - max-height: 200px; - overflow-y: auto; - background: rgba(0,0,0,0.9); - color: #0f0; - font-size: 11px; - font-family: monospace; - padding: 5px; - z-index: 9999; - display: none; - } - /* Прозрачные зоны для тачей поверх всего */ - #touch-left, #touch-right, #touch-center { + /* Прозрачные зоны для тачей */ + .touch-zone { position: fixed; top: 0; height: 100%; @@ -138,166 +121,154 @@ - -
-
-
+
+
+
+ + + - - - - - - - - \ No newline at end of file diff --git a/BookReader/ViewModels/ReaderViewModel.cs b/BookReader/ViewModels/ReaderViewModel.cs index edcfc5e..079d078 100644 --- a/BookReader/ViewModels/ReaderViewModel.cs +++ b/BookReader/ViewModels/ReaderViewModel.cs @@ -121,6 +121,9 @@ public partial class ReaderViewModel : BaseViewModel { if (Book == null) return; + // Важно: если CFI пустой, не перезаписываем старый прогресс (защита от багов JS) + if (string.IsNullOrEmpty(cfi) && progress <= 0) return; + Book.ReadingProgress = progress; Book.LastCfi = cfi; Book.LastChapter = chapter; @@ -128,6 +131,7 @@ public partial class ReaderViewModel : BaseViewModel Book.TotalPages = totalPages; Book.LastRead = DateTime.UtcNow; + // Сохраняем в базу данных await _databaseService.UpdateBookAsync(Book); await _databaseService.SaveProgressAsync(new ReadingProgress diff --git a/BookReader/Views/ReaderPage.xaml b/BookReader/Views/ReaderPage.xaml index bc9f88a..0c0651c 100644 --- a/BookReader/Views/ReaderPage.xaml +++ b/BookReader/Views/ReaderPage.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm="clr-namespace:BookReader.ViewModels" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" + xmlns:converters="clr-namespace:BookReader.Converters" x:Class="BookReader.Views.ReaderPage" x:DataType="vm:ReaderViewModel" Shell.NavBarIsVisible="False" diff --git a/BookReader/Views/ReaderPage.xaml.cs b/BookReader/Views/ReaderPage.xaml.cs index 97d7033..0fa1d70 100644 --- a/BookReader/Views/ReaderPage.xaml.cs +++ b/BookReader/Views/ReaderPage.xaml.cs @@ -18,6 +18,10 @@ public partial class ReaderPage : ContentPage _viewModel = viewModel; BindingContext = viewModel; _viewModel.OnJavaScriptRequested += OnJavaScriptRequested; + //Microsoft.Maui.Controls.Application.Current.Deactivated += async (s, e) => + //{ + // if (_isActive) await SaveCurrentProgress(); + //}; } protected override async void OnAppearing() @@ -44,7 +48,13 @@ public partial class ReaderPage : ContentPage await SaveCurrentProgress(); } - + protected override async void OnNavigatedFrom(NavigatedFromEventArgs args) + { + _isActive = false; + base.OnNavigatedFrom(args); + // Сохраняем немедленно при любом уходе со страницы + await SaveCurrentProgress(); + } // ========== ЗАГРУЗКА КНИГИ ==========