edit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
// ========== ЗАГРУЗКА КНИГИ ==========
|
||||
|
||||
|
||||
Reference in New Issue
Block a user