feat: AV/BV号直接跳转
This commit is contained in:
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
class SearchPanelController extends GetxController {
|
||||
SearchPanelController({this.keyword, this.searchType});
|
||||
@ -21,6 +23,7 @@ class SearchPanelController extends GetxController {
|
||||
} else if (type == 'onRefresh') {
|
||||
resultList.value = result['data'].list;
|
||||
}
|
||||
onPushDetail(keyword, resultList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -40,4 +43,24 @@ class SearchPanelController extends GetxController {
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
}
|
||||
}
|
||||
|
||||
void onPushDetail(keyword, resultList) async {
|
||||
// 匹配输入内容,如果是AV、BV号且有结果 直接跳转详情页
|
||||
Map matchRes = IdUtils.matchAvorBv(input: keyword);
|
||||
List matchKeys = matchRes.keys.toList();
|
||||
if (matchKeys.isNotEmpty && searchType == SearchType.video) {
|
||||
String bvid = resultList.first.bvid;
|
||||
int aid = resultList.first.aid;
|
||||
String heroTag = Utils.makeHeroTag(bvid);
|
||||
|
||||
int cid = await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
if (matchKeys.first == 'BV' && matchRes[matchKeys.first] == bvid ||
|
||||
matchKeys.first == 'AV' && matchRes[matchKeys.first] == aid) {
|
||||
Get.toNamed(
|
||||
'/video?bvid=$bvid&cid=$cid',
|
||||
arguments: {'videoItem': resultList.first, 'heroTag': heroTag},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user