From 2dc7cf28c9cdd3a0774eeb5dccab2ac61fe7f8de Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 10 Jan 2024 23:58:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=84=E8=AE=BA=E5=8C=BA@=E8=B7=9Fjum?= =?UTF-8?q?pUrl=E5=85=B1=E5=AD=98=E6=97=B6=E9=93=BE=E6=8E=A5=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=20issues=20#404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/reply/widgets/reply_item.dart | 12 +++++++++--- lib/utils/id_utils.dart | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 7a30074b..8701025f 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -552,7 +552,7 @@ InlineSpan buildContent( ); } final List spanChilds = []; - bool hasMatchMember = true; + bool hasMatchMember = false; // 投票 if (content.vote.isNotEmpty) { @@ -643,7 +643,7 @@ InlineSpan buildContent( reg, onMatch: (Match match) { if (match[0] != null) { - hasMatchMember = false; + hasMatchMember = true; content.atNameToMid.forEach((key, value) { if (str.contains('回复')) { spanChilds.add( @@ -682,6 +682,7 @@ InlineSpan buildContent( if (!str.contains('@')) { spanChilds.add(TextSpan(text: str)); } + print(str); return str; }, ); @@ -691,7 +692,7 @@ InlineSpan buildContent( // 匹配 jumpUrl String matchUrl = matchMember; - if (content.jumpUrl.isNotEmpty && hasMatchMember) { + if (content.jumpUrl.isNotEmpty) { final List urlKeys = content.jumpUrl.keys.toList().reversed.toList(); for (int index = 0; index < urlKeys.length; index++) { var i = urlKeys[index]; @@ -705,6 +706,11 @@ InlineSpan buildContent( urlKeys[index] = i.replaceAll('*', '\\*'); } } + if (hasMatchMember) { + matchMember = matchMember.split('回复 @ :').length > 1 + ? matchMember.split('回复 @ :')[1] + : matchMember; + } matchUrl = matchMember.splitMapJoin( /// RegExp.escape() 转义特殊字符 RegExp(urlKeys.map((key) => key).join("|")), diff --git a/lib/utils/id_utils.dart b/lib/utils/id_utils.dart index 42b474f5..e3814df6 100644 --- a/lib/utils/id_utils.dart +++ b/lib/utils/id_utils.dart @@ -49,8 +49,8 @@ class IdUtils { // 匹配 static Map matchAvorBv({String? input}) { - final Map result = {'': null}; - if (input == null || input == '') { + final Map result = {}; + if (input == null || input.isEmpty) { return result; } final RegExp bvRegex = RegExp(r'BV[0-9A-Za-z]{10}', caseSensitive: false);