Files
PiliPlus/lib/services/account_service.dart
My-Responsitories 244ef22f54 feat: load config from text (#1772)
* feat: load config from text

* opt: login utils

* update

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

---------

Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
2025-12-09 22:09:57 +08:00

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();
}
}