fix: 评论区链接解析

This commit is contained in:
guozhigq
2024-05-06 23:14:12 +08:00
parent d0fc71aeb0
commit b54f7d0523

View File

@ -12,6 +12,7 @@ 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/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/url_utils.dart';
import 'package:pilipala/utils/utils.dart';
@ -642,23 +643,25 @@ InlineSpan buildContent(
'',
);
} else {
final String redirectUrl =
await UrlUtils.parseRedirectUrl(matchStr);
if (redirectUrl == matchStr) {
Clipboard.setData(ClipboardData(text: matchStr));
SmartDialog.showToast('地址可能有误');
return;
}
final String pathSegment = Uri.parse(redirectUrl).path;
final String lastPathSegment =
pathSegment.split('/').last;
if (lastPathSegment.startsWith('BV')) {
final String pathSegment = Uri.parse(matchStr).path;
Map matchRes = IdUtils.matchAvorBv(input: pathSegment);
List matchKeys = matchRes.keys.toList();
if (matchKeys.isNotEmpty) {
UrlUtils.matchUrlPush(
lastPathSegment,
matchRes.containsKey('AV')
? matchRes['AV']! as int
: matchRes['BV'],
title,
redirectUrl,
matchStr,
);
} else {
final String redirectUrl =
await UrlUtils.parseRedirectUrl(matchStr);
if (redirectUrl == matchStr) {
Clipboard.setData(ClipboardData(text: matchStr));
SmartDialog.showToast('地址可能有误');
return;
}
Get.toNamed(
'/webview',
parameters: {