mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: search aid/bvid
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -5,7 +5,6 @@ import 'package:PiliPlus/utils/app_scheme.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/http/search.dart';
|
import 'package:PiliPlus/http/search.dart';
|
||||||
import 'package:PiliPlus/models/common/search_type.dart';
|
import 'package:PiliPlus/models/common/search_type.dart';
|
||||||
import 'package:PiliPlus/utils/id_utils.dart';
|
|
||||||
|
|
||||||
class SearchPanelController extends CommonController {
|
class SearchPanelController extends CommonController {
|
||||||
SearchPanelController({
|
SearchPanelController({
|
||||||
@@ -26,11 +25,14 @@ class SearchPanelController extends CommonController {
|
|||||||
String tag;
|
String tag;
|
||||||
int? pubBegin;
|
int? pubBegin;
|
||||||
int? pubEnd;
|
int? pubEnd;
|
||||||
bool? hasPushDetail;
|
bool? hasJump2Video;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
if (searchType == SearchType.video) {
|
||||||
|
jump2Video();
|
||||||
|
}
|
||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +49,10 @@ class SearchPanelController extends CommonController {
|
|||||||
?.insertAll(0, (loadingState.value as Success).response);
|
?.insertAll(0, (loadingState.value as Success).response);
|
||||||
}
|
}
|
||||||
loadingState.value = LoadingState.success(response.response.list);
|
loadingState.value = LoadingState.success(response.response.list);
|
||||||
if (hasPushDetail != true &&
|
if (searchType == SearchType.video &&
|
||||||
currentPage == 1 &&
|
hasJump2Video != true &&
|
||||||
searchType == SearchType.video) {
|
currentPage == 1) {
|
||||||
hasPushDetail = true;
|
hasJump2Video = true;
|
||||||
onPushDetail(response.response.list);
|
onPushDetail(response.response.list);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -62,22 +64,22 @@ class SearchPanelController extends CommonController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPushDetail(resultList) async {
|
void jump2Video() {
|
||||||
// 匹配输入内容,如果是AV、BV号且有结果 直接跳转详情页
|
if (RegExp(r'^av\d+$', caseSensitive: false).hasMatch(keyword)) {
|
||||||
if (RegExp(r'^(av\d+|bv[a-z\d]{10})$', caseSensitive: false)
|
hasJump2Video = true;
|
||||||
|
PiliScheme.videoPush(int.parse(keyword.substring(2)), null, false);
|
||||||
|
} else if (RegExp(r'^bv[a-z\d]{10}$', caseSensitive: false)
|
||||||
.hasMatch(keyword)) {
|
.hasMatch(keyword)) {
|
||||||
Map matchRes = IdUtils.matchAvorBv(input: keyword);
|
hasJump2Video = true;
|
||||||
PiliScheme.videoPush(matchRes['AV'], matchRes['BV'], false);
|
PiliScheme.videoPush(null, keyword, false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// keyword 可能输入纯数字
|
void onPushDetail(resultList) async {
|
||||||
try {
|
int? aid = int.tryParse(keyword);
|
||||||
int? aid = int.tryParse(keyword);
|
if (aid != null && resultList.first.aid == aid) {
|
||||||
if (aid != null && resultList.first.aid == aid) {
|
PiliScheme.videoPush(aid, null, false);
|
||||||
PiliScheme.videoPush(aid, null, false);
|
}
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user