fix:登录退出页

This commit is contained in:
jingyun
2026-06-07 11:38:08 +08:00
parent 6a7fa5a067
commit 6c943f8394
8 changed files with 356 additions and 38 deletions
@@ -2,8 +2,10 @@ import '../state/app_interaction_state.dart';
abstract class UserStateRepository {
Future<bool> isLoggedIn();
Future<void> login(LoginMethod method);
Future<void> login(LoginMethod method, {String? phone});
Future<void> logout();
Future<String?> getPhone();
Future<LoginMethod?> getLoginMethod();
Future<Set<String>> getFavorites();
Future<void> toggleFavorite(String reportId);
@@ -20,6 +22,8 @@ abstract class UserStateRepository {
class MemoryUserStateRepository implements UserStateRepository {
bool _loggedIn = false;
String? _phone;
LoginMethod? _loginMethod;
final Set<String> _favorites = {};
final Set<String> _savedListens = {};
final List<String> _history = [];
@@ -29,15 +33,25 @@ class MemoryUserStateRepository implements UserStateRepository {
Future<bool> isLoggedIn() async => _loggedIn;
@override
Future<void> login(LoginMethod method) async {
Future<void> login(LoginMethod method, {String? phone}) async {
_loggedIn = true;
_loginMethod = method;
_phone = phone;
}
@override
Future<void> logout() async {
_loggedIn = false;
_phone = null;
_loginMethod = null;
}
@override
Future<String?> getPhone() async => _phone;
@override
Future<LoginMethod?> getLoginMethod() async => _loginMethod;
@override
Future<Set<String>> getFavorites() async => {..._favorites};