opt: account (#1306)

* opt: account

* opt: account

* opt: live api

* opt: buvid

* Revert "opt: buvid"

This reverts commit da1ea68f8bfd0b9af6958062557c85135ab8b08d.

* tweak
This commit is contained in:
My-Responsitories
2025-09-23 15:58:40 +08:00
committed by GitHub
parent 6b4fb0d611
commit 1345fd36e4
18 changed files with 173 additions and 208 deletions

View File

@@ -7,7 +7,6 @@ import 'package:PiliPlus/models_new/live/live_feed_index/data.dart';
import 'package:PiliPlus/models_new/live/live_second_list/data.dart';
import 'package:PiliPlus/models_new/live/live_second_list/tag.dart';
import 'package:PiliPlus/pages/common/common_list_controller.dart';
import 'package:PiliPlus/services/account_service.dart';
import 'package:get/get.dart';
class LiveController extends CommonListController {
@@ -17,8 +16,6 @@ class LiveController extends CommonListController {
queryData();
}
AccountService accountService = Get.find<AccountService>();
int? count;
// area
@@ -75,16 +72,12 @@ class LiveController extends CommonListController {
if (areaIndex.value != 0) {
return LiveHttp.liveSecondList(
pn: page,
isLogin: accountService.isLogin.value,
areaId: areaId,
parentAreaId: parentAreaId,
sortType: sortType,
);
}
return LiveHttp.liveFeedIndex(
pn: page,
isLogin: accountService.isLogin.value,
);
return LiveHttp.liveFeedIndex(pn: page);
}
@override
@@ -99,11 +92,7 @@ class LiveController extends CommonListController {
}
Future<void> queryTop() async {
final res = await LiveHttp.liveFeedIndex(
pn: page,
isLogin: accountService.isLogin.value,
moduleSelect: true,
);
final res = await LiveHttp.liveFeedIndex(pn: page, moduleSelect: true);
if (res.isSuccess) {
final data = res.data;
topState.value = Pair(

View File

@@ -36,12 +36,10 @@ class LiveAreaController
@override
Future<LoadingState<List<AreaList>?>> customGetData() =>
LiveHttp.liveAreaList(isLogin: accountService.isLogin.value);
LiveHttp.liveAreaList();
Future<void> queryFavTags() async {
favState.value = await LiveHttp.getLiveFavTag(
isLogin: accountService.isLogin.value,
);
favState.value = await LiveHttp.getLiveFavTag();
}
Future<void> setFavTag() async {

View File

@@ -6,7 +6,6 @@ import 'package:PiliPlus/models_new/live/live_feed_index/card_data_list_item.dar
import 'package:PiliPlus/models_new/live/live_second_list/data.dart';
import 'package:PiliPlus/models_new/live/live_second_list/tag.dart';
import 'package:PiliPlus/pages/common/common_list_controller.dart';
import 'package:PiliPlus/services/account_service.dart';
import 'package:get/get.dart';
class LiveAreaChildController
@@ -23,8 +22,6 @@ class LiveAreaChildController
final RxInt tagIndex = 0.obs;
List<LiveSecondTag>? newTags;
AccountService accountService = Get.find<AccountService>();
@override
void onInit() {
super.onInit();
@@ -53,7 +50,6 @@ class LiveAreaChildController
Future<LoadingState<LiveSecondData>> customGetData() =>
LiveHttp.liveSecondList(
pn: page,
isLogin: accountService.isLogin.value,
areaId: areaId,
parentAreaId: parentAreaId,
sortType: sortType,

View File

@@ -4,8 +4,6 @@ import 'package:PiliPlus/http/live.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models_new/live/live_area_list/area_item.dart';
import 'package:PiliPlus/pages/common/common_list_controller.dart';
import 'package:PiliPlus/services/account_service.dart';
import 'package:get/get.dart';
class LiveAreaDatailController
extends CommonListController<List<AreaItem>?, AreaItem> {
@@ -15,8 +13,6 @@ class LiveAreaDatailController
late int initialIndex = 0;
AccountService accountService = Get.find<AccountService>();
@override
void onInit() {
super.onInit();
@@ -33,8 +29,5 @@ class LiveAreaDatailController
@override
Future<LoadingState<List<AreaItem>?>> customGetData() =>
LiveHttp.liveRoomAreaList(
isLogin: accountService.isLogin.value,
parentid: parentAreaId,
);
LiveHttp.liveRoomAreaList(parentid: parentAreaId);
}

View File

@@ -4,8 +4,6 @@ import 'package:PiliPlus/models/common/live_search_type.dart';
import 'package:PiliPlus/models_new/live/live_search/data.dart';
import 'package:PiliPlus/pages/common/common_list_controller.dart';
import 'package:PiliPlus/pages/live_search/controller.dart';
import 'package:PiliPlus/services/account_service.dart';
import 'package:get/get.dart';
class LiveSearchChildController
extends CommonListController<LiveSearchData, dynamic> {
@@ -14,8 +12,6 @@ class LiveSearchChildController
final LiveSearchController controller;
final LiveSearchType searchType;
AccountService accountService = Get.find<AccountService>();
@override
void checkIsEnd(int length) {
switch (searchType) {
@@ -48,7 +44,6 @@ class LiveSearchChildController
@override
Future<LoadingState<LiveSearchData>> customGetData() {
return LiveHttp.liveSearch(
isLogin: accountService.isLogin.value,
page: page,
keyword: controller.editingController.text,
type: searchType,

View File

@@ -690,7 +690,11 @@ class LoginPageController extends GetxController
tokenInfo['refresh_token'],
);
await Future.wait([account.onChange(), AnonymousAccount().delete()]);
Accounts.accountMode.updateAll((_, a) => a == account ? account : a);
for (int i = 0; i < AccountType.values.length; i++) {
if (Accounts.accountMode[i].mid == account.mid) {
Accounts.accountMode[i] = account;
}
}
if (Accounts.main.isLogin) {
SmartDialog.showToast('登录成功');
} else {
@@ -704,7 +708,7 @@ class LoginPageController extends GetxController
SmartDialog.showToast('请先登录');
return Get.toNamed('/loginPage');
}
final selectAccount = Map.of(Accounts.accountMode);
final selectAccount = List.of(Accounts.accountMode);
final options = {
AnonymousAccount(): '0',
...Accounts.account.toMap().map(
@@ -729,9 +733,9 @@ class LoginPageController extends GetxController
.map(
(e) => Builder(
builder: (context) => RadioGroup(
groupValue: selectAccount[e],
groupValue: selectAccount[e.index],
onChanged: (v) {
selectAccount[e] = v!;
selectAccount[e.index] = v!;
(context as Element).markNeedsBuild();
},
child: WrapRadioOptionsGroup<Account>(
@@ -756,9 +760,9 @@ class LoginPageController extends GetxController
),
TextButton(
onPressed: () {
for (var i in selectAccount.entries) {
if (i.value != Accounts.get(i.key)) {
Accounts.set(i.key, i.value);
for (var (i, v) in selectAccount.indexed) {
if (v != Accounts.accountMode[i]) {
Accounts.set(AccountType.values[i], v);
}
}
Get.back();

View File

@@ -229,7 +229,8 @@ class MineController
}
res == true
? Accounts.set(AccountType.heartbeat, AnonymousAccount())
: Accounts.accountMode[AccountType.heartbeat] = AnonymousAccount();
: Accounts.accountMode[AccountType.heartbeat.index] =
AnonymousAccount();
});
} else {
Accounts.set(AccountType.heartbeat, Accounts.main);

View File

@@ -41,11 +41,9 @@ List<SettingsModel> get privacySettings => [
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text('查看详情'),
title: const Text('账号模式详情'),
content: SingleChildScrollView(
child: Text(
AccountManager.apiTypeSet[AccountType.heartbeat]!.join('\n'),
),
child: _getAccountDetail(context),
),
actions: [
TextButton(
@@ -58,7 +56,26 @@ List<SettingsModel> get privacySettings => [
);
},
leading: const Icon(Icons.flag_outlined),
title: '了解无痕模式',
subtitle: '查看无痕模式作用的API列表',
title: '了解账号模式',
subtitle: '查看各个账号模式作用的API列表',
),
];
Widget _getAccountDetail(BuildContext context) {
final slivers = <Widget>[];
final theme = TextTheme.of(context);
for (var i in AccountType.values) {
final url = AccountManager.apiTypeSet[i];
if (url == null) continue;
slivers
..add(Center(child: Text(i.title, style: theme.titleMedium)))
..add(SelectableText(url.join('\n')));
}
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: slivers,
);
}