fix: 首页动态跳转

This commit is contained in:
guozhigq
2023-10-17 23:20:27 +08:00
parent d0590933e0
commit a97f57642e

View File

@ -70,20 +70,25 @@ class VideoCardV extends StatelessWidget {
break; break;
// 动态 // 动态
case 'picture': case 'picture':
try {
String dynamicType = 'picture'; String dynamicType = 'picture';
String uri = videoItem.uri; String uri = videoItem.uri;
if (videoItem.uri.contains('bilibili://article/')) { String id = '';
dynamicType = 'article'; if (videoItem.uri.startsWith('bilibili://article/')) {
// https://www.bilibili.com/read/cv27063554
dynamicType = 'read';
RegExp regex = RegExp(r'\d+'); RegExp regex = RegExp(r'\d+');
Match match = regex.firstMatch(videoItem.uri)!; Match match = regex.firstMatch(videoItem.uri)!;
String matchedNumber = match.group(0)!; String matchedNumber = match.group(0)!;
videoItem.param = 'cv' + matchedNumber; videoItem.param = int.parse(matchedNumber);
id = 'cv${videoItem.param}';
} }
if (uri.startsWith('http')) { if (uri.startsWith('http')) {
String path = Uri.parse(uri).path; String path = Uri.parse(uri).path;
if (isStringNumeric(path.split('/')[1])) { if (isStringNumeric(path.split('/')[1])) {
// 请求接口 // 请求接口
var res = await DynamicsHttp.dynamicDetail(id: path.split('/')[1]); var res =
await DynamicsHttp.dynamicDetail(id: path.split('/')[1]);
if (res['status']) { if (res['status']) {
Get.toNamed('/dynamicDetail', arguments: { Get.toNamed('/dynamicDetail', arguments: {
'item': res['data'], 'item': res['data'],
@ -97,9 +102,12 @@ class VideoCardV extends StatelessWidget {
Get.toNamed('/htmlRender', parameters: { Get.toNamed('/htmlRender', parameters: {
'url': uri, 'url': uri,
'title': videoItem.title, 'title': videoItem.title,
'id': videoItem.param.toString(), 'id': id,
'dynamicType': dynamicType 'dynamicType': dynamicType
}); });
} catch (err) {
SmartDialog.showToast(err.toString());
}
break; break;
default: default:
SmartDialog.showToast(videoItem.goto); SmartDialog.showToast(videoItem.goto);