diff --git a/lib/common/widgets/html_render.dart b/lib/common/widgets/html_render.dart index a4269d71e..ea0b9f460 100644 --- a/lib/common/widgets/html_render.dart +++ b/lib/common/widgets/html_render.dart @@ -1,6 +1,8 @@ import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart' show SourceModel; import 'package:PiliPlus/utils/extension.dart'; +import 'package:PiliPlus/utils/utils.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'network_img_layer.dart'; @@ -43,16 +45,16 @@ Widget htmlRender({ // width: isEmote ? 22 : null, // height: isEmote ? 22 : null, // ); + String? clazz = attributes['class']; String? height = RegExp(r'max-height:(\d+)px') .firstMatch('${attributes['style']}') ?.group(1); - if (height != null) { - return NetworkImgLayer( + if (clazz?.contains('cut-off') == true || height != null) { + return CachedNetworkImage( width: constrainedWidth, - height: double.parse(height), - src: imgUrl, - type: 'emote', - boxFit: BoxFit.contain, + height: height != null ? double.parse(height) : null, + imageUrl: Utils.thumbnailImgUrl(imgUrl), + fit: BoxFit.contain, ); } return Hero( diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 4b8cca134..beea86298 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -6,7 +6,6 @@ import 'package:get/get.dart'; import '../../models/home/rcmd/result.dart'; import '../../models/model_rec_video_item.dart'; import 'stat/stat.dart'; -import '../../http/dynamics.dart'; import '../../utils/id_utils.dart'; import '../../utils/utils.dart'; import '../constants.dart'; @@ -67,20 +66,9 @@ class VideoCardV extends StatelessWidget { id = 'cv${videoItem.param}'; } if (uri.startsWith('http')) { - String path = Uri.parse(uri).path; - if (isStringNumeric(path.split('/')[1])) { - // 请求接口 - var res = - await DynamicsHttp.dynamicDetail(id: path.split('/')[1]); - if (res['status']) { - Get.toNamed('/dynamicDetail', arguments: { - 'item': res['data'], - 'floor': 1, - 'action': 'detail' - }); - } else { - SmartDialog.showToast(res['msg']); - } + String id = Uri.parse(uri).path.split('/')[1]; + if (isStringNumeric(id)) { + Utils.pushDynFromId(id); return; } } diff --git a/lib/http/dynamics.dart b/lib/http/dynamics.dart index c9fcc78ce..84efaeb68 100644 --- a/lib/http/dynamics.dart +++ b/lib/http/dynamics.dart @@ -116,14 +116,12 @@ class DynamicsHttp { } catch (err) { return { 'status': false, - 'data': [], 'msg': err.toString(), }; } } else { return { 'status': false, - 'data': [], 'msg': res.data['message'], }; } diff --git a/lib/http/html.dart b/lib/http/html.dart index dc7055e11..47dffc6fa 100644 --- a/lib/http/html.dart +++ b/lib/http/html.dart @@ -160,9 +160,7 @@ class HtmlHttp { } } - RegExp digitRegExp = RegExp(r'\d+'); - Iterable matches = digitRegExp.allMatches(id); - String number = matches.first.group(0)!; + String number = RegExp(r'\d+').firstMatch(id)!.group(0)!; return { 'status': true, 'avatar': avatar, diff --git a/lib/pages/html/controller.dart b/lib/pages/html/controller.dart index a127caefe..4e01ae242 100644 --- a/lib/pages/html/controller.dart +++ b/lib/pages/html/controller.dart @@ -69,6 +69,9 @@ class HtmlRenderController extends ReplyController { late dynamic res; if (dynamicType == 'opus' || dynamicType == 'picture') { res = await HtmlHttp.reqHtml(id, dynamicType); + if (res != null) { + type = res['commentType']; + } } else { res = await HtmlHttp.reqReadHtml(id, dynamicType); } diff --git a/lib/pages/member_search/search_dynamic.dart b/lib/pages/member_search/search_dynamic.dart index ad736ced0..aba941548 100644 --- a/lib/pages/member_search/search_dynamic.dart +++ b/lib/pages/member_search/search_dynamic.dart @@ -216,17 +216,8 @@ class SearchDynamic extends StatelessWidget { required String content, }) { return InkWell( - onTap: () async { - SmartDialog.showLoading(); - dynamic res = await DynamicsHttp.dynamicDetail(id: id); - if (res['status']) { - SmartDialog.dismiss(); - Get.toNamed('/dynamicDetail', - arguments: {'item': res['data'], 'floor': 1, 'action': 'detail'}); - } else { - SmartDialog.dismiss(); - SmartDialog.showToast(res['msg']); - } + onTap: () { + Utils.pushDynFromId(id); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 04ff64ec4..d606fa669 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -653,22 +653,7 @@ class PiliScheme { static Future _onPushDynDetail(path, off) async { String? id = uriDigitRegExp.firstMatch(path)?.group(1); if (id != null) { - SmartDialog.showLoading(); - dynamic res = await DynamicsHttp.dynamicDetail(id: id); - SmartDialog.dismiss(); - if (res['status']) { - Utils.toDupNamed( - '/dynamicDetail', - arguments: { - 'item': res['data'], - 'floor': 1, - 'action': 'detail', - }, - off: off, - ); - } else { - SmartDialog.showToast(res['msg']); - } + Utils.pushDynFromId(id, off: off); return true; } return false; diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index de27b2e89..71ab2dccc 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -62,6 +62,39 @@ class Utils { static final _numRegExp = RegExp(r'([\d\.]+)([千万亿])?'); + static Future pushDynFromId(id, {bool off = false}) async { + SmartDialog.showLoading(); + dynamic res = await DynamicsHttp.dynamicDetail(id: id); + SmartDialog.dismiss(); + if (res['status']) { + DynamicItemModel data = res['data']; + if (data.basic?['comment_type'] == 12) { + Utils.toDupNamed( + '/htmlRender', + parameters: { + 'url': 'www.bilibili.com/opus/$id', + 'title': '', + 'id': id, + 'dynamicType': 'opus' + }, + off: off, + ); + } else { + Utils.toDupNamed( + '/dynamicDetail', + arguments: { + 'item': res['data'], + 'floor': 1, + 'action': 'detail', + }, + off: off, + ); + } + } else { + SmartDialog.showToast(res['msg']); + } + } + static void reportVideo(int aid) { Get.toNamed( '/webview', @@ -783,11 +816,14 @@ class Utils { /// 点击评论action 直接查看评论 if (action == 'comment') { - Utils.toDupNamed('/dynamicDetail', arguments: { - 'item': item, - 'floor': floor, - 'action': action, - }); + Utils.toDupNamed( + '/dynamicDetail', + arguments: { + 'item': item, + 'floor': floor, + 'action': action, + }, + ); return; } @@ -858,8 +894,13 @@ class Utils { /// 纯文字动态查看 case 'DYNAMIC_TYPE_WORD': debugPrint('纯文本'); - Utils.toDupNamed('/dynamicDetail', - arguments: {'item': item, 'floor': floor}); + Utils.toDupNamed( + '/dynamicDetail', + arguments: { + 'item': item, + 'floor': floor, + }, + ); break; case 'DYNAMIC_TYPE_LIVE_RCMD': DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd; @@ -928,8 +969,13 @@ class Utils { // /// 图文动态查看 // case 'DYNAMIC_TYPE_DRAW': default: - Utils.toDupNamed('/dynamicDetail', - arguments: {'item': item, 'floor': floor}); + Utils.toDupNamed( + '/dynamicDetail', + arguments: { + 'item': item, + 'floor': floor, + }, + ); break; } }