From fce96d497689b18959995baddcbe1a45eccbfcf0 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 20 Feb 2024 23:54:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=84=E8=AE=BA=E8=AF=9D=E9=A2=98?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/video/reply/content.dart | 3 +++ .../detail/reply/widgets/reply_item.dart | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/models/video/reply/content.dart b/lib/models/video/reply/content.dart index 9180ec97..d62a4bca 100644 --- a/lib/models/video/reply/content.dart +++ b/lib/models/video/reply/content.dart @@ -9,6 +9,7 @@ class ReplyContent { this.vote, this.richText, this.isText, + this.topicsMeta, }); String? message; @@ -20,6 +21,7 @@ class ReplyContent { Map? vote; Map? richText; bool? isText; + Map? topicsMeta; ReplyContent.fromJson(Map json) { message = json['message'] @@ -39,6 +41,7 @@ class ReplyContent { richText = json['rich_text'] ?? {}; // 不包含@ 笔记 图片的时候,文字可折叠 isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty; + topicsMeta = json['topics_meta'] ?? {}; } } diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 7991a366..d0b2b0e5 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -582,6 +582,7 @@ InlineSpan buildContent( // 构建正则表达式 final List specialTokens = [ ...content.emote.keys, + ...content.topicsMeta?.keys?.map((e) => '#$e#') ?? [], ...content.atNameToMid.keys.map((e) => '@$e'), ...content.jumpUrl.keys.map((e) => e.replaceAll('?', '\\?').replaceAll('+', '\\+').replaceAll('*', '\\*')), @@ -664,7 +665,7 @@ InlineSpan buildContent( ), ); } else { - // print("matchStr=$matchStr"); + print("matchStr=$matchStr"); String appUrlSchema = ''; final bool enableWordRe = setting.get(SettingBoxKey.enableWordRe, defaultValue: false) as bool; @@ -727,6 +728,23 @@ InlineSpan buildContent( ); // 只显示一次 matchedStrs.add(matchStr); + } else if (content + .topicsMeta[matchStr.substring(1, matchStr.length - 1)] != + null) { + spanChilds.add( + TextSpan( + text: matchStr, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + final String topic = + matchStr.substring(1, matchStr.length - 1); + Get.toNamed('/searchResult', parameters: {'keyword': topic}); + }, + ), + ); } else { addPlainTextSpan(matchStr); }