mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
some fixes (#498)
* nologin reject headtbeat * fix: change anonymity * use account as key
This commit is contained in:
committed by
GitHub
parent
9d0ac30fad
commit
7c3e3cb1f8
@@ -660,9 +660,14 @@ class LoginPageController extends GetxController
|
|||||||
if (Accounts.account.isEmpty) {
|
if (Accounts.account.isEmpty) {
|
||||||
return SmartDialog.showToast('请先登录');
|
return SmartDialog.showToast('请先登录');
|
||||||
}
|
}
|
||||||
final selectAccount = Accounts.accountMode
|
final selectAccount = Map.of(Accounts.accountMode);
|
||||||
.map((key, value) => MapEntry(key, value.mid.toString()));
|
final options = {
|
||||||
final options = {'0': '0', for (String i in Accounts.account.keys) i: i};
|
AnonymousAccount(): '0',
|
||||||
|
...Accounts.account
|
||||||
|
.toMap()
|
||||||
|
.cast<String, Account>()
|
||||||
|
.map((k, v) => MapEntry(v, k))
|
||||||
|
};
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => StatefulBuilder(builder: (context, setState) {
|
builder: (context) => StatefulBuilder(builder: (context, setState) {
|
||||||
@@ -680,7 +685,7 @@ class LoginPageController extends GetxController
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: AccountType.values
|
children: AccountType.values
|
||||||
.map(
|
.map(
|
||||||
(e) => WrapRadioOptionsGroup<String>(
|
(e) => WrapRadioOptionsGroup<Account>(
|
||||||
groupTitle: e.title,
|
groupTitle: e.title,
|
||||||
options: options,
|
options: options,
|
||||||
selectedValue: selectAccount[e],
|
selectedValue: selectAccount[e],
|
||||||
@@ -703,10 +708,8 @@ class LoginPageController extends GetxController
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
for (var i in selectAccount.entries) {
|
for (var i in selectAccount.entries) {
|
||||||
var account =
|
if (i.value != Accounts.get(i.key)) {
|
||||||
Accounts.account.get(i.value) ?? AnonymousAccount();
|
Accounts.set(i.key, i.value);
|
||||||
if (account != Accounts.get(i.key)) {
|
|
||||||
Accounts.set(i.key, account);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Get.back();
|
Get.back();
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ class MineController extends GetxController {
|
|||||||
}
|
}
|
||||||
anonymity.value = !anonymity.value;
|
anonymity.value = !anonymity.value;
|
||||||
if (anonymity.value) {
|
if (anonymity.value) {
|
||||||
Accounts.accountMode[AccountType.heartbeat] = AnonymousAccount();
|
SmartDialog.show<bool>(
|
||||||
SmartDialog.show(
|
|
||||||
clickMaskDismiss: false,
|
clickMaskDismiss: false,
|
||||||
usePenetrate: true,
|
usePenetrate: true,
|
||||||
displayTime: const Duration(seconds: 2),
|
displayTime: const Duration(seconds: 2),
|
||||||
@@ -128,9 +127,7 @@ class MineController extends GetxController {
|
|||||||
children: [
|
children: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss(result: true);
|
||||||
Accounts.set(
|
|
||||||
AccountType.heartbeat, AnonymousAccount());
|
|
||||||
SmartDialog.showToast('已设为永久无痕模式');
|
SmartDialog.showToast('已设为永久无痕模式');
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -161,7 +158,11 @@ class MineController extends GetxController {
|
|||||||
// showCloseIcon: true,
|
// showCloseIcon: true,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
).then((res) {
|
||||||
|
res == true
|
||||||
|
? Accounts.set(AccountType.heartbeat, AnonymousAccount())
|
||||||
|
: Accounts.accountMode[AccountType.heartbeat] = AnonymousAccount();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Accounts.set(AccountType.heartbeat, Accounts.main);
|
Accounts.set(AccountType.heartbeat, Accounts.main);
|
||||||
SmartDialog.show(
|
SmartDialog.show(
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ class VideoDetailController extends GetxController
|
|||||||
double? brightness;
|
double? brightness;
|
||||||
// 默认记录历史记录
|
// 默认记录历史记录
|
||||||
bool enableHeart = true;
|
bool enableHeart = true;
|
||||||
dynamic userInfo;
|
|
||||||
Floating? floating;
|
Floating? floating;
|
||||||
late PreferredSizeWidget headerControl;
|
late PreferredSizeWidget headerControl;
|
||||||
|
|
||||||
@@ -250,7 +249,6 @@ class VideoDetailController extends GetxController
|
|||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
userInfo = GStorage.userInfo.get('userInfoCache');
|
|
||||||
var keys = Get.arguments.keys.toList();
|
var keys = Get.arguments.keys.toList();
|
||||||
if (keys.isNotEmpty) {
|
if (keys.isNotEmpty) {
|
||||||
if (keys.contains('videoItem')) {
|
if (keys.contains('videoItem')) {
|
||||||
@@ -284,7 +282,7 @@ class VideoDetailController extends GetxController
|
|||||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: false);
|
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: false);
|
||||||
if (autoPlay.value) isShowCover.value = false;
|
if (autoPlay.value) isShowCover.value = false;
|
||||||
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
||||||
if (userInfo == null ||
|
if (!Accounts.get(AccountType.heartbeat).isLogin ||
|
||||||
GStorage.localCache.get(LocalCacheKey.historyPause) == true) {
|
GStorage.localCache.get(LocalCacheKey.historyPause) == true) {
|
||||||
enableHeart = false;
|
enableHeart = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1039,7 +1039,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
await videoIntroController.viewLater();
|
await videoIntroController.viewLater();
|
||||||
break;
|
break;
|
||||||
case 'report':
|
case 'report':
|
||||||
if (videoDetailController.userInfo == null) {
|
if (!Accounts.main.isLogin) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
} else {
|
} else {
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webview', parameters: {
|
||||||
|
|||||||
@@ -874,9 +874,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
.viewLater();
|
.viewLater();
|
||||||
break;
|
break;
|
||||||
case 'report':
|
case 'report':
|
||||||
if (videoDetailController
|
if (!Accounts
|
||||||
.userInfo ==
|
.main.isLogin) {
|
||||||
null) {
|
|
||||||
SmartDialog.showToast(
|
SmartDialog.showToast(
|
||||||
'账号未登录');
|
'账号未登录');
|
||||||
} else {
|
} else {
|
||||||
@@ -1418,7 +1417,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
await videoIntroController.viewLater();
|
await videoIntroController.viewLater();
|
||||||
break;
|
break;
|
||||||
case 'report':
|
case 'report':
|
||||||
if (videoDetailController.userInfo == null) {
|
if (!Accounts.main.isLogin) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
} else {
|
} else {
|
||||||
Get.toNamed('/webview', parameters: {
|
Get.toNamed('/webview', parameters: {
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (videoDetailCtr.userInfo == null) {
|
if (!Accounts.main.isLogin) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,13 @@ class AccountManager extends Interceptor {
|
|||||||
|
|
||||||
final Account account = options.extra['account'] ?? _findAccount(path);
|
final Account account = options.extra['account'] ?? _findAccount(path);
|
||||||
|
|
||||||
if (account.isLogin) options.headers.addAll(account.headers);
|
if (account.isLogin) {
|
||||||
|
options.headers.addAll(account.headers);
|
||||||
|
} else if (path == Api.heartBeat) {
|
||||||
|
return handler.reject(
|
||||||
|
DioException.requestCancelled(requestOptions: options, reason: null),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
// app端不需要管理cookie
|
// app端不需要管理cookie
|
||||||
if (path.startsWith(HttpString.appBaseUrl)) {
|
if (path.startsWith(HttpString.appBaseUrl)) {
|
||||||
@@ -190,8 +196,8 @@ class AccountManager extends Interceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _saveCookies(Response response) async {
|
Future<void> _saveCookies(Response response) async {
|
||||||
final account = (response.requestOptions.extra['account'] as Account? ??
|
final Account account = response.requestOptions.extra['account'] ??
|
||||||
_findAccount(response.requestOptions.path));
|
_findAccount(response.requestOptions.path);
|
||||||
final setCookies = response.headers[HttpHeaders.setCookieHeader];
|
final setCookies = response.headers[HttpHeaders.setCookieHeader];
|
||||||
if (setCookies == null || setCookies.isEmpty) {
|
if (setCookies == null || setCookies.isEmpty) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user