feat: 评论话题匹配
This commit is contained in:
@ -9,6 +9,7 @@ class ReplyContent {
|
|||||||
this.vote,
|
this.vote,
|
||||||
this.richText,
|
this.richText,
|
||||||
this.isText,
|
this.isText,
|
||||||
|
this.topicsMeta,
|
||||||
});
|
});
|
||||||
|
|
||||||
String? message;
|
String? message;
|
||||||
@ -20,6 +21,7 @@ class ReplyContent {
|
|||||||
Map? vote;
|
Map? vote;
|
||||||
Map? richText;
|
Map? richText;
|
||||||
bool? isText;
|
bool? isText;
|
||||||
|
Map? topicsMeta;
|
||||||
|
|
||||||
ReplyContent.fromJson(Map<String, dynamic> json) {
|
ReplyContent.fromJson(Map<String, dynamic> json) {
|
||||||
message = json['message']
|
message = json['message']
|
||||||
@ -39,6 +41,7 @@ class ReplyContent {
|
|||||||
richText = json['rich_text'] ?? {};
|
richText = json['rich_text'] ?? {};
|
||||||
// 不包含@ 笔记 图片的时候,文字可折叠
|
// 不包含@ 笔记 图片的时候,文字可折叠
|
||||||
isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty;
|
isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty;
|
||||||
|
topicsMeta = json['topics_meta'] ?? {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,6 +582,7 @@ InlineSpan buildContent(
|
|||||||
// 构建正则表达式
|
// 构建正则表达式
|
||||||
final List<String> specialTokens = [
|
final List<String> specialTokens = [
|
||||||
...content.emote.keys,
|
...content.emote.keys,
|
||||||
|
...content.topicsMeta?.keys?.map((e) => '#$e#') ?? [],
|
||||||
...content.atNameToMid.keys.map((e) => '@$e'),
|
...content.atNameToMid.keys.map((e) => '@$e'),
|
||||||
...content.jumpUrl.keys.map((e) =>
|
...content.jumpUrl.keys.map((e) =>
|
||||||
e.replaceAll('?', '\\?').replaceAll('+', '\\+').replaceAll('*', '\\*')),
|
e.replaceAll('?', '\\?').replaceAll('+', '\\+').replaceAll('*', '\\*')),
|
||||||
@ -664,7 +665,7 @@ InlineSpan buildContent(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// print("matchStr=$matchStr");
|
print("matchStr=$matchStr");
|
||||||
String appUrlSchema = '';
|
String appUrlSchema = '';
|
||||||
final bool enableWordRe = setting.get(SettingBoxKey.enableWordRe,
|
final bool enableWordRe = setting.get(SettingBoxKey.enableWordRe,
|
||||||
defaultValue: false) as bool;
|
defaultValue: false) as bool;
|
||||||
@ -727,6 +728,23 @@ InlineSpan buildContent(
|
|||||||
);
|
);
|
||||||
// 只显示一次
|
// 只显示一次
|
||||||
matchedStrs.add(matchStr);
|
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 {
|
} else {
|
||||||
addPlainTextSpan(matchStr);
|
addPlainTextSpan(matchStr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user