mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
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>
This commit is contained in:
committed by
GitHub
parent
b4daf5fbd8
commit
244ef22f54
@@ -1,20 +1,44 @@
|
||||
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 {
|
||||
late int mid;
|
||||
late final RxString name;
|
||||
late final RxString face;
|
||||
late final RxBool isLogin;
|
||||
final RxString face = ''.obs;
|
||||
final RxBool isLogin = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
UserInfoData? userInfo = Pref.userInfoCache;
|
||||
mid = userInfo?.mid ?? 0;
|
||||
name = (userInfo?.uname ?? '').obs;
|
||||
face = (userInfo?.face ?? '').obs;
|
||||
isLogin = (userInfo != null).obs;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user