diff --git a/lib/pages/searchPanel/controller.dart b/lib/pages/searchPanel/controller.dart index 826fdacc..399df1e1 100644 --- a/lib/pages/searchPanel/controller.dart +++ b/lib/pages/searchPanel/controller.dart @@ -56,14 +56,20 @@ class SearchPanelController extends GetxController { // 匹配输入内容,如果是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 bvid = resultList.first.bvid; + // keyword 可能输入纯数字 + int aid = resultList.first.aid; + if (matchKeys.isNotEmpty && searchType == SearchType.video || + aid.toString() == keyword) { 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) { + if (matchKeys.isNotEmpty && + matchKeys.first == 'BV' && + matchRes[matchKeys.first] == bvid || + matchKeys.isNotEmpty && + matchKeys.first == 'AV' && + matchRes[matchKeys.first] == aid || + aid.toString() == keyword) { Get.toNamed( '/video?bvid=$bvid&cid=$cid', arguments: {'videoItem': resultList.first, 'heroTag': heroTag}, diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index c45d56dd..8b47dde6 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -602,9 +602,26 @@ InlineSpan buildContent( color: Theme.of(context).colorScheme.primary, ), recognizer: TapGestureRecognizer() - ..onTap = () => Get.toNamed('/searchResult', parameters: { - 'keyword': content.jumpUrl[matchStr]['title'] - }), + ..onTap = () { + String appUrlSchema = + content.jumpUrl[matchStr]['app_url_schema']; + if (appUrlSchema == '') { + Get.toNamed( + '/webview', + parameters: { + 'url': matchStr, + 'type': 'url', + 'pageTitle': '' + }, + ); + } else { + if (appUrlSchema.startsWith('bilibili://search')) { + Get.toNamed('/searchResult', parameters: { + 'keyword': content.jumpUrl[matchStr]['title'] + }); + } + } + }, ), ); spanChilds.add( diff --git a/lib/pages/webview/controller.dart b/lib/pages/webview/controller.dart index 03b99ee8..67d60d6a 100644 --- a/lib/pages/webview/controller.dart +++ b/lib/pages/webview/controller.dart @@ -63,6 +63,13 @@ class WebviewController extends GetxController { onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest request) { if (request.url.startsWith('bilibili://')) { + if (request.url.startsWith('bilibili://video/')) { + String str = Uri.parse(request.url).pathSegments[0]; + Get.offAndToNamed( + '/searchResult', + parameters: {'keyword': str}, + ); + } return NavigationDecision.prevent; } return NavigationDecision.navigate;