mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
mod: account (#591)
* fix: onLoginMain * fix: account override * opt: sponsor block url
This commit is contained in:
committed by
GitHub
parent
64fc995f6b
commit
e190ca5868
@@ -642,14 +642,15 @@ class LoginPageController extends GetxController
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setAccount(Map tokenInfo, List cookieInfo) async {
|
Future<void> setAccount(Map tokenInfo, List cookieInfo) async {
|
||||||
|
final account = LoginAccount(BiliCookieJar.fromList(cookieInfo),
|
||||||
|
tokenInfo['access_token'], tokenInfo['refresh_token']);
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
LoginAccount(BiliCookieJar.fromList(cookieInfo),
|
account.onChange(),
|
||||||
tokenInfo['access_token'], tokenInfo['refresh_token'])
|
|
||||||
.onChange(),
|
|
||||||
AnonymousAccount()
|
AnonymousAccount()
|
||||||
.delete()
|
.delete()
|
||||||
.then((_) => Request.buvidActive(AnonymousAccount()))
|
.then((_) => Request.buvidActive(AnonymousAccount()))
|
||||||
]);
|
]);
|
||||||
|
Accounts.accountMode.updateAll((_, a) => a == account ? account : a);
|
||||||
if (Accounts.main.isLogin) {
|
if (Accounts.main.isLogin) {
|
||||||
SmartDialog.showToast('登录成功');
|
SmartDialog.showToast('登录成功');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
|||||||
_blockServer = HttpString.sponsorBlockBaseUrl;
|
_blockServer = HttpString.sponsorBlockBaseUrl;
|
||||||
await setting.put(
|
await setting.put(
|
||||||
SettingBoxKey.blockServer, _blockServer);
|
SettingBoxKey.blockServer, _blockServer);
|
||||||
|
Request.accountManager.blockServer = _blockServer;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: Text('重置'),
|
child: Text('重置'),
|
||||||
@@ -308,6 +309,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
|||||||
_blockServer = _textController.text;
|
_blockServer = _textController.text;
|
||||||
await setting.put(
|
await setting.put(
|
||||||
SettingBoxKey.blockServer, _blockServer);
|
SettingBoxKey.blockServer, _blockServer);
|
||||||
|
Request.accountManager.blockServer = _blockServer;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: Text('确定'),
|
child: Text('确定'),
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ class AccountManager extends Interceptor {
|
|||||||
Api.oauth2AccessToken,
|
Api.oauth2AccessToken,
|
||||||
};
|
};
|
||||||
|
|
||||||
const AccountManager();
|
AccountManager();
|
||||||
|
|
||||||
|
String blockServer = GStorage.blockServer;
|
||||||
|
|
||||||
static String getCookies(List<Cookie> cookies) {
|
static String getCookies(List<Cookie> cookies) {
|
||||||
// Sort cookies by path (longer path first).
|
// Sort cookies by path (longer path first).
|
||||||
@@ -236,8 +238,8 @@ class AccountManager extends Interceptor {
|
|||||||
await account.onChange();
|
await account.onChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _skipCookie(String path) {
|
bool _skipCookie(String path) {
|
||||||
return path.startsWith(GStorage.blockServer) ||
|
return path.startsWith(blockServer) ||
|
||||||
path.contains('hdslb.com') ||
|
path.contains('hdslb.com') ||
|
||||||
path.contains('biliimg.com');
|
path.contains('biliimg.com');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ class LoginUtils {
|
|||||||
SmartDialog.showToast('设置登录态失败,$e');
|
SmartDialog.showToast('设置登录态失败,$e');
|
||||||
}
|
}
|
||||||
final result = await UserHttp.userInfo();
|
final result = await UserHttp.userInfo();
|
||||||
final UserInfoData data = result['data'];
|
if (result['status'] && result['data']?.isLogin == true) {
|
||||||
if (result['status'] && data.isLogin!) {
|
final UserInfoData data = result['data'];
|
||||||
SmartDialog.showToast('main登录成功');
|
SmartDialog.showToast('main登录成功');
|
||||||
await GStorage.userInfo.put('userInfoCache', data);
|
await GStorage.userInfo.put('userInfoCache', data);
|
||||||
try {
|
try {
|
||||||
@@ -109,7 +109,7 @@ class LoginUtils {
|
|||||||
// 获取用户信息失败
|
// 获取用户信息失败
|
||||||
await Accounts.deleteAll({account});
|
await Accounts.deleteAll({account});
|
||||||
SmartDialog.showNotify(
|
SmartDialog.showNotify(
|
||||||
msg: '登录失败,请检查cookie是否正确,${result['message']}',
|
msg: '登录失败,请检查cookie是否正确,${result['msg']}',
|
||||||
notifyType: NotifyType.warning);
|
notifyType: NotifyType.warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user