mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
* feat: load config from text * opt: login utils * update Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
45 lines
951 B
Dart
45 lines
951 B
Dart
import 'dart:async';
|
|
|
|
import 'package:PiliPlus/models/user/info.dart';
|
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
class AccountService extends GetxService {
|
|
final RxString face = ''.obs;
|
|
final RxBool isLogin = false.obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
UserInfoData? userInfo = Pref.userInfoCache;
|
|
if (userInfo != null) {
|
|
face.value = userInfo.face ?? '';
|
|
isLogin.value = true;
|
|
} else {
|
|
face.value = '';
|
|
isLogin.value = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
mixin AccountMixin on GetLifeCycleBase {
|
|
StreamSubscription<bool>? _listener;
|
|
|
|
AccountService get accountService => Get.find<AccountService>();
|
|
|
|
void onChangeAccount(bool isLogin);
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_listener = accountService.isLogin.listen(onChangeAccount);
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
_listener?.cancel();
|
|
_listener = null;
|
|
super.onClose();
|
|
}
|
|
}
|