diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index d00df4ad..58fc658a 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -777,7 +777,6 @@ class ReplyItem extends StatelessWidget { if (matchStr.startsWith('BV')) { UrlUtils.matchUrlPush( matchStr, - title, '', ); } else if (RegExp(r'^[Cc][Vv][0-9]+$') @@ -834,7 +833,6 @@ class ReplyItem extends StatelessWidget { if (lastPathSegment.startsWith('BV')) { UrlUtils.matchUrlPush( lastPathSegment, - title, redirectUrl, ); } else { @@ -876,7 +874,26 @@ class ReplyItem extends StatelessWidget { color: Theme.of(context).colorScheme.primary, ), recognizer: TapGestureRecognizer() - ..onTap = () => Utils.handleWebview(matchStr), + ..onTap = () async { + if (matchStr.startsWith('https://b23.tv')) { + final String redirectUrl = + (await UrlUtils.parseRedirectUrl(matchStr)) ?? + matchStr; + final String pathSegment = Uri.parse(redirectUrl).path; + final String lastPathSegment = + pathSegment.split('/').last; + if (lastPathSegment.startsWith('BV')) { + UrlUtils.matchUrlPush( + lastPathSegment, + redirectUrl, + ); + } else { + PiliScheme.routePush(Uri.parse(matchStr)); + } + } else { + PiliScheme.routePush(Uri.parse(matchStr)); + } + }, ), ); } else { diff --git a/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart b/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart index f8d7c433..e8bef236 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart @@ -809,7 +809,6 @@ class ReplyItemGrpc extends StatelessWidget { if (matchStr.startsWith('BV')) { UrlUtils.matchUrlPush( matchStr, - title, '', ); } else if (RegExp(r'^[Cc][Vv][0-9]+$') @@ -866,7 +865,6 @@ class ReplyItemGrpc extends StatelessWidget { if (lastPathSegment.startsWith('BV')) { UrlUtils.matchUrlPush( lastPathSegment, - title, redirectUrl, ); } else { @@ -908,7 +906,26 @@ class ReplyItemGrpc extends StatelessWidget { color: Theme.of(context).colorScheme.primary, ), recognizer: TapGestureRecognizer() - ..onTap = () => Utils.handleWebview(matchStr), + ..onTap = () async { + if (matchStr.startsWith('https://b23.tv')) { + final String redirectUrl = + (await UrlUtils.parseRedirectUrl(matchStr)) ?? + matchStr; + final String pathSegment = Uri.parse(redirectUrl).path; + final String lastPathSegment = + pathSegment.split('/').last; + if (lastPathSegment.startsWith('BV')) { + UrlUtils.matchUrlPush( + lastPathSegment, + redirectUrl, + ); + } else { + PiliScheme.routePush(Uri.parse(matchStr)); + } + } else { + PiliScheme.routePush(Uri.parse(matchStr)); + } + }, ), ); } else { diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 124d2ab3..fc0747ee 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -201,7 +201,7 @@ class PiliScheme { //Utils.toDupNamed( // '/webview', // parameters: { - // 'url': value.dataString ?? "", + // 'url': , // 'type': 'url', // 'pageTitle': '' // }, @@ -336,24 +336,17 @@ class PiliScheme { } else if (lastPathSegment.startsWith('BV')) { UrlUtils.matchUrlPush( lastPathSegment, - '', redirectUrl, ); } else { - Utils.toDupNamed( - '/webview', - parameters: {'url': redirectUrl, 'type': 'url', 'pageTitle': ''}, - ); + Utils.handleWebview(redirectUrl); } return; } List pathPart = path.split('/'); if (pathPart.length < 3) { - Utils.toDupNamed( - '/webview', - parameters: {'url': value.toString()}, - ); + Utils.handleWebview(value.toString()); return; } final String area = pathPart[1] == 'mobile' ? pathPart[2] : pathPart[1]; @@ -409,15 +402,8 @@ class PiliScheme { } else if (res.containsKey('BV')) { videoPush(null, res['BV'] as String); } else { - SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开'); - Utils.toDupNamed( - '/webview', - parameters: { - 'url': value.toString(), - 'type': 'url', - 'pageTitle': '' - }, - ); + // SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开'); + Utils.handleWebview(value.toString()); } } } diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart index b3a8f380..c2df0569 100644 --- a/lib/utils/url_utils.dart +++ b/lib/utils/url_utils.dart @@ -50,7 +50,6 @@ class UrlUtils { // 匹配url路由跳转 static matchUrlPush( String pathSegment, - String title, String redirectUrl, ) async { final Map matchRes = IdUtils.matchAvorBv(input: pathSegment);