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:
My-Responsitories
2025-12-09 22:09:57 +08:00
committed by GitHub
parent b4daf5fbd8
commit 244ef22f54
20 changed files with 264 additions and 208 deletions

View File

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