feat: 查看笔记
This commit is contained in:
@ -7,6 +7,7 @@ class ReplyContent {
|
|||||||
this.jumpUrl, // {}
|
this.jumpUrl, // {}
|
||||||
this.pictures, // {}
|
this.pictures, // {}
|
||||||
this.vote,
|
this.vote,
|
||||||
|
this.richText
|
||||||
});
|
});
|
||||||
|
|
||||||
String? message;
|
String? message;
|
||||||
@ -16,6 +17,7 @@ class ReplyContent {
|
|||||||
Map? jumpUrl;
|
Map? jumpUrl;
|
||||||
List? pictures;
|
List? pictures;
|
||||||
Map? vote;
|
Map? vote;
|
||||||
|
Map? richText;
|
||||||
|
|
||||||
ReplyContent.fromJson(Map<String, dynamic> json) {
|
ReplyContent.fromJson(Map<String, dynamic> json) {
|
||||||
message = json['message'];
|
message = json['message'];
|
||||||
@ -25,5 +27,6 @@ class ReplyContent {
|
|||||||
jumpUrl = json['jump_url'] ?? {};
|
jumpUrl = json['jump_url'] ?? {};
|
||||||
pictures = json['pictures'] ?? [];
|
pictures = json['pictures'] ?? [];
|
||||||
vote = json['vote'] ?? {};
|
vote = json['vote'] ?? {};
|
||||||
|
richText = json['rich_text'] ?? {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -243,7 +243,9 @@ class ReplyItem extends StatelessWidget {
|
|||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
),
|
),
|
||||||
child: Text('回复', style: Theme.of(context).textTheme.labelMedium),
|
child: Text('回复', style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.outline
|
||||||
|
)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
@ -260,7 +262,6 @@ class ReplyItem extends StatelessWidget {
|
|||||||
// 完成评论,数据添加
|
// 完成评论,数据添加
|
||||||
if (value['data'] != null)
|
if (value['data'] != null)
|
||||||
{
|
{
|
||||||
print('🌹: ${value['data'].content.message}'),
|
|
||||||
addReply!(value['data'])
|
addReply!(value['data'])
|
||||||
// replyControl.replies.add(value['data']),
|
// replyControl.replies.add(value['data']),
|
||||||
}
|
}
|
||||||
@ -426,6 +427,7 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
List<InlineSpan> spanChilds = [];
|
List<InlineSpan> spanChilds = [];
|
||||||
|
bool hasMatchMember = true;
|
||||||
// 匹配表情
|
// 匹配表情
|
||||||
String matchEmote = content.message.splitMapJoin(
|
String matchEmote = content.message.splitMapJoin(
|
||||||
RegExp(r"\[.*?\]"),
|
RegExp(r"\[.*?\]"),
|
||||||
@ -459,6 +461,7 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
RegExp(r"@.*( |:)"),
|
RegExp(r"@.*( |:)"),
|
||||||
onMatch: (Match match) {
|
onMatch: (Match match) {
|
||||||
if (match[0] != null) {
|
if (match[0] != null) {
|
||||||
|
hasMatchMember = false;
|
||||||
content.atNameToMid.forEach((key, value) {
|
content.atNameToMid.forEach((key, value) {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
@ -489,7 +492,7 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
|
|
||||||
// 匹配 jumpUrl
|
// 匹配 jumpUrl
|
||||||
String matchUrl = matchMember;
|
String matchUrl = matchMember;
|
||||||
if (content.jumpUrl.isNotEmpty) {
|
if (content.jumpUrl.isNotEmpty && hasMatchMember) {
|
||||||
List urlKeys = content.jumpUrl.keys.toList();
|
List urlKeys = content.jumpUrl.keys.toList();
|
||||||
matchUrl = matchMember.splitMapJoin(
|
matchUrl = matchMember.splitMapJoin(
|
||||||
RegExp("(?:${urlKeys.join("|")})"),
|
RegExp("(?:${urlKeys.join("|")})"),
|
||||||
@ -525,7 +528,6 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
str = matchUrl.splitMapJoin(
|
str = matchUrl.splitMapJoin(
|
||||||
RegExp(r"\d{1,2}:\d{1,2}"),
|
RegExp(r"\d{1,2}:\d{1,2}"),
|
||||||
onMatch: (Match match) {
|
onMatch: (Match match) {
|
||||||
@ -651,6 +653,29 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 笔记链接
|
||||||
|
if (content.richText.isNotEmpty) {
|
||||||
|
spanChilds.add(
|
||||||
|
TextSpan(
|
||||||
|
text: ' 笔记',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () => {
|
||||||
|
Get.toNamed(
|
||||||
|
'/webview',
|
||||||
|
parameters: {
|
||||||
|
'url': content.richText['note']['click_url'],
|
||||||
|
'type': 'note',
|
||||||
|
'pageTitle': '笔记预览'
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
// spanChilds.add(TextSpan(text: matchMember));
|
// spanChilds.add(TextSpan(text: matchMember));
|
||||||
return TextSpan(children: spanChilds);
|
return TextSpan(children: spanChilds);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,9 +45,9 @@ class WebviewController extends GetxController {
|
|||||||
onPageStarted: (String url) {},
|
onPageStarted: (String url) {},
|
||||||
// 加载完成
|
// 加载完成
|
||||||
onPageFinished: (String url) async {
|
onPageFinished: (String url) async {
|
||||||
if (url.startsWith(
|
if (type == 'login' && (url.startsWith(
|
||||||
'https://passport.bilibili.com/web/sso/exchange_cookie') ||
|
'https://passport.bilibili.com/web/sso/exchange_cookie') ||
|
||||||
url.startsWith('https://m.bilibili.com/')) {
|
url.startsWith('https://m.bilibili.com/'))) {
|
||||||
try {
|
try {
|
||||||
var cookies =
|
var cookies =
|
||||||
await WebviewCookieManager().getCookies(HttpString.baseUrl);
|
await WebviewCookieManager().getCookies(HttpString.baseUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user