opt: push dyn

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-05 10:50:29 +08:00
parent 4aaaffbcea
commit ff30c8c2bf
8 changed files with 73 additions and 62 deletions

View File

@@ -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(

View File

@@ -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;
}
}

View File

@@ -116,14 +116,12 @@ class DynamicsHttp {
} catch (err) {
return {
'status': false,
'data': [],
'msg': err.toString(),
};
}
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}

View File

@@ -160,9 +160,7 @@ class HtmlHttp {
}
}
RegExp digitRegExp = RegExp(r'\d+');
Iterable<Match> matches = digitRegExp.allMatches(id);
String number = matches.first.group(0)!;
String number = RegExp(r'\d+').firstMatch(id)!.group(0)!;
return {
'status': true,
'avatar': avatar,

View File

@@ -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);
}

View File

@@ -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),

View File

@@ -653,22 +653,7 @@ class PiliScheme {
static Future<bool> _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;

View File

@@ -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;
}
}