feat(library): 支持设备追剧与观看历史

This commit is contained in:
Zhou Weidong committed 2026-10-27 09:54:51 +08:00
1 parent 4c3acb047c
commit 0d785bf1f8
12 files changed
+232 -76

No files matched your search

@@ -93,6 +93,7 @@ class FavoriteController extends ChangeNotifier {
loadingMore = false;
error = null;
loadMoreError = null;
lastErrorCode = null;
notify();
try {
final page = await _repository.page(pageIndex: 1, pageSize: pageSize);
@@ -106,9 +107,10 @@ class FavoriteController extends ChangeNotifier {
total = page.total;
_pageIndex = 1;
hasMore = page.list.isNotEmpty && cards.length < total;
} catch (_) {
} catch (failure) {
if (!_disposed && request == _requestSeq) {
error = 'favoritesError';
if (failure is ApiException) lastErrorCode = failure.code;
}
} finally {
if (!_disposed && request == _requestSeq) {
@@ -124,6 +126,7 @@ class FavoriteController extends ChangeNotifier {
final request = ++_requestSeq;
loadingMore = true;
loadMoreError = null;
lastErrorCode = null;
notify();
try {
final page = await _repository.page(
@@ -141,9 +144,10 @@ class FavoriteController extends ChangeNotifier {
total = page.total;
_pageIndex += 1;
hasMore = page.list.isNotEmpty && cards.length < total;
} catch (_) {
} catch (failure) {
if (!_disposed && request == _requestSeq) {
loadMoreError = 'favoritesError';
if (failure is ApiException) lastErrorCode = failure.code;
}
} finally {
if (!_disposed && request == _requestSeq) {
@@ -38,6 +38,7 @@ class WatchRecordsController extends ChangeNotifier {
String? error;
String? loadMoreError;
String? actionError;
int? lastErrorCode;
int _pageIndex = 0;
int _requestSeq = 0;
bool _disposed = false;
@@ -50,6 +51,7 @@ class WatchRecordsController extends ChangeNotifier {
error = null;
loadMoreError = null;
actionError = null;
lastErrorCode = null;
_notify();
try {
final page = await _history.recent(pageIndex: 1, pageSize: pageSize);
@@ -71,6 +73,7 @@ class WatchRecordsController extends ChangeNotifier {
);
if (!_disposed && request == _requestSeq) {
error = failure is ApiException ? failure.message : 'progressError';
if (failure is ApiException) lastErrorCode = failure.code;
}
} finally {
if (!_disposed && request == _requestSeq) {
@@ -86,6 +89,7 @@ class WatchRecordsController extends ChangeNotifier {
final request = ++_requestSeq;
loadingMore = true;
loadMoreError = null;
lastErrorCode = null;
_notify();
try {
final page = await _history.recent(
@@ -108,6 +112,7 @@ class WatchRecordsController extends ChangeNotifier {
loadMoreError = failure is ApiException
? failure.message
: 'progressError';
if (failure is ApiException) lastErrorCode = failure.code;
}
} finally {
if (!_disposed && request == _requestSeq) {
@@ -148,17 +153,19 @@ class WatchRecordsController extends ChangeNotifier {
total = total > 0 ? total - 1 : 0;
hasMore = records.length < total;
actionError = null;
lastErrorCode = null;
_notify();
try {
await _history.remove(dramaId);
return true;
} catch (_) {
} catch (failure) {
final next = [...records];
next.insert(index > next.length ? next.length : index, removed);
records = next;
total += 1;
hasMore = records.length < total;
actionError = 'recordDeleteFailed';
if (failure is ApiException) lastErrorCode = failure.code;
return false;
} finally {
_notify();
@@ -179,16 +186,18 @@ class WatchRecordsController extends ChangeNotifier {
loadingMore = false;
clearing = true;
actionError = null;
lastErrorCode = null;
_notify();
try {
await _history.clear();
return true;
} catch (_) {
} catch (failure) {
records = previous;
total = previousTotal;
_pageIndex = previousPageIndex;
hasMore = records.length < total;
actionError = 'recordClearFailed';
if (failure is ApiException) lastErrorCode = failure.code;
return false;
} finally {
clearing = false;