diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index df3303ec..9945b3cd 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -286,7 +286,7 @@ class ReplyItem extends StatelessWidget { value['data'] != null && addReply != null) { - addReply!(value['data']) + addReply?.call(value['data']) // replyControl.replies.add(value['data']), } }); @@ -537,8 +537,8 @@ InlineSpan buildContent( spanChilds.add(TextSpan( text: str, recognizer: TapGestureRecognizer() - ..onTap = - () => replyReply(replyItem.root == 0 ? replyItem : fReplyItem))); + ..onTap = () => + replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem))); } // 分割文本并处理每个部分 @@ -649,6 +649,11 @@ 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; @@ -967,6 +972,7 @@ class MorePanel extends StatelessWidget { @override Widget build(BuildContext context) { + Color errorColor = Theme.of(context).colorScheme.error; return Container( padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), child: Column( diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart index bac6cdfa..cf0ef9e2 100644 --- a/lib/utils/url_utils.dart +++ b/lib/utils/url_utils.dart @@ -14,19 +14,23 @@ class UrlUtils { dio.options.validateStatus = (status) { return status == 200 || status == 301 || status == 302; }; - final response = await dio.get(url); - if (response.statusCode == 302) { - redirectUrl = response.headers['location']?.first as String; - if (redirectUrl.endsWith('/')) { - redirectUrl = redirectUrl.substring(0, redirectUrl.length - 1); - } - } else { - if (url.endsWith('/')) { - url = url.substring(0, url.length - 1); + try { + final response = await dio.get(url); + if (response.statusCode == 302) { + redirectUrl = response.headers['location']?.first as String; + if (redirectUrl.endsWith('/')) { + redirectUrl = redirectUrl.substring(0, redirectUrl.length - 1); + } + } else { + if (url.endsWith('/')) { + url = url.substring(0, url.length - 1); + } + return url; } + return redirectUrl; + } catch (err) { return url; } - return redirectUrl; } // 匹配url路由跳转