fix: 首页动态跳转

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

View File

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