opt: search ctr

related #137

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-10 17:41:46 +08:00
parent 96fb17e6b1
commit 7b3d132802
3 changed files with 18 additions and 15 deletions

View File

@@ -8,9 +8,13 @@ import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
class SearchPanelController extends CommonController {
SearchPanelController({this.keyword, this.searchType, this.tag});
SearchPanelController({
this.keyword,
required this.searchType,
required this.tag,
});
String? keyword;
SearchType? searchType;
SearchType searchType;
// 结果排序方式 搜索类型为视频、专栏及相簿时
RxString order = ''.obs;
// 视频时长筛选 仅用于搜索视频
@@ -19,11 +23,9 @@ class SearchPanelController extends CommonController {
int? orderSort;
int? userType;
int? categoryId;
String? tag;
String tag;
int? pubBegin;
int? pubEnd;
late final searchResultController =
Get.find<SearchResultController>(tag: tag);
@override
void onInit() {
@@ -33,8 +35,10 @@ class SearchPanelController extends CommonController {
@override
bool customHandleResponse(Success response) {
searchResultController.count[SearchType.values.indexOf(searchType!)] =
try {
Get.find<SearchResultController>(tag: tag).count[searchType.index] =
response.response.numResults;
} catch (_) {}
if (response.response.list != null) {
isEnd = response.response.list.isEmpty;
if (currentPage != 1 && loadingState.value is Success) {
@@ -94,11 +98,11 @@ class SearchPanelController extends CommonController {
@override
Future<LoadingState> customGetData() => SearchHttp.searchByType(
searchType: searchType!,
searchType: searchType,
keyword: keyword!,
page: currentPage,
order: order.value,
duration: searchType!.name != 'video' ? null : duration.value,
duration: searchType.name != 'video' ? null : duration.value,
tids: tids,
orderSort: orderSort,
userType: userType,

View File

@@ -17,13 +17,13 @@ import 'widgets/user_panel.dart';
class SearchPanel extends StatefulWidget {
final String? keyword;
final SearchType? searchType;
final String? tag;
final SearchType searchType;
final String tag;
const SearchPanel({
super.key,
required this.keyword,
required this.searchType,
this.tag,
required this.tag,
});
@override
@@ -46,7 +46,7 @@ class _SearchPanelState extends State<SearchPanel>
searchType: widget.searchType,
tag: widget.tag,
),
tag: widget.searchType!.name + widget.keyword!,
tag: widget.searchType.name + widget.keyword!,
);
}

View File

@@ -84,8 +84,7 @@ class _SearchResultPageState extends State<SearchResultPage>
.map(
(item) => Obx(
() {
int count = _searchResultController
.count[SearchType.values.indexOf(item)];
int count = _searchResultController.count[item.index];
return Tab(
text:
'${item.label}${count != -1 ? ' ${count > 99 ? '99+' : count}' : ''}');