From 732beb38a71a20cb2980d3c40d473b4b64b68fd1 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 25 May 2024 15:31:00 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E8=AF=84=E8=AE=BA=E5=8C=BA=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/reply/widgets/reply_item.dart | 41 ++++++------------- lib/utils/app_scheme.dart | 24 +++++++++-- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 4ff13065..55c16f7d 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -1,3 +1,4 @@ +import 'package:appscheme/appscheme.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -11,6 +12,7 @@ import 'package:pilipala/models/video/reply/item.dart'; import 'package:pilipala/pages/preview/index.dart'; import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/reply_new/index.dart'; +import 'package:pilipala/utils/app_scheme.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/storage.dart'; @@ -643,34 +645,17 @@ InlineSpan buildContent( '', ); } else { - final String pathSegment = Uri.parse(matchStr).path; - Map matchRes = IdUtils.matchAvorBv(input: pathSegment); - List matchKeys = matchRes.keys.toList(); - if (matchKeys.isNotEmpty) { - UrlUtils.matchUrlPush( - matchRes.containsKey('AV') - ? matchRes['AV']! as int - : matchRes['BV'], - title, - matchStr, - ); - } else { - final String redirectUrl = - await UrlUtils.parseRedirectUrl(matchStr); - // if (redirectUrl == matchStr) { - // Clipboard.setData(ClipboardData(text: matchStr)); - // SmartDialog.showToast('地址可能有误'); - // return; - // } - Get.toNamed( - '/webview', - parameters: { - 'url': redirectUrl, - 'type': 'url', - 'pageTitle': title - }, - ); - } + Uri uri = Uri.parse(matchStr); + SchemeEntity scheme = SchemeEntity( + scheme: uri.scheme, + host: uri.host, + port: uri.port, + path: uri.path, + query: uri.queryParameters, + source: '', + dataString: matchStr, + ); + PiliSchame.fullPathPush(scheme); } } else { if (appUrlSchema.startsWith('bilibili://search')) { diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 8502dc7f..a83b7809 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -95,7 +95,7 @@ class PiliSchame { } } if (scheme == 'https') { - _fullPathPush(value); + fullPathPush(value); } } @@ -126,7 +126,7 @@ class PiliSchame { } } - static Future _fullPathPush(SchemeEntity value) async { + static Future fullPathPush(SchemeEntity value) async { // https://m.bilibili.com/bangumi/play/ss39708 // https | m.bilibili.com | /bangumi/play/ss39708 // final String scheme = value.scheme!; @@ -135,8 +135,6 @@ class PiliSchame { Map? query = value.query; RegExp regExp = RegExp(r'^((www\.)|(m\.))?bilibili\.com$'); if (regExp.hasMatch(host)) { - print('bilibili.com host: $host'); - print('bilibili.com path: $path'); final String lastPathSegment = path!.split('/').last; if (path.startsWith('/video')) { Map matchRes = IdUtils.matchAvorBv(input: path); @@ -236,6 +234,24 @@ class PiliSchame { print('个人空间'); Get.toNamed('/member?mid=$area', arguments: {'face': ''}); break; + default: + final Map map = + IdUtils.matchAvorBv(input: area.split('?').first); + if (map.containsKey('AV')) { + _videoPush(map['AV']! as int, null); + } else if (map.containsKey('BV')) { + _videoPush(null, map['BV'] as String); + } else { + Get.toNamed( + '/webview', + parameters: { + 'url': value.dataString ?? "", + 'type': 'url', + 'pageTitle': '' + }, + ); + } + break; } } }