From a1900c73622d8a68bb52a35683eda00494530b9d Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 27 Aug 2023 14:22:12 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E8=AF=84=E8=AE=BA=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/searchPanel/controller.dart | 18 ++++++++++----- .../detail/reply/widgets/reply_item.dart | 23 ++++++++++++++++--- lib/pages/webview/controller.dart | 7 ++++++ 3 files changed, 39 insertions(+), 9 deletions(-) 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;