Merge branch 'feature-opusRender'
This commit is contained in:
@ -22,6 +22,29 @@ class ReadHttp {
|
||||
var res = await Request().get('https://www.bilibili.com/opus/$id', extra: {
|
||||
'ua': 'pc',
|
||||
});
|
||||
String? headContent = parse(res.data).head?.outerHtml;
|
||||
var document = parse(headContent);
|
||||
var linkTags = document.getElementsByTagName('link');
|
||||
bool isCv = false;
|
||||
String cvId = '';
|
||||
for (var linkTag in linkTags) {
|
||||
var attributes = linkTag.attributes;
|
||||
if (attributes.containsKey('rel') &&
|
||||
attributes['rel'] == 'canonical' &&
|
||||
attributes.containsKey('data-vue-meta') &&
|
||||
attributes['data-vue-meta'] == 'true') {
|
||||
final String cvHref = linkTag.attributes['href']!;
|
||||
RegExp regex = RegExp(r'cv(\d+)');
|
||||
RegExpMatch? match = regex.firstMatch(cvHref);
|
||||
if (match != null) {
|
||||
cvId = match.group(1)!;
|
||||
} else {
|
||||
print('No match found.');
|
||||
}
|
||||
isCv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String scriptContent =
|
||||
extractScriptContents(parse(res.data).body!.outerHtml)[0];
|
||||
int startIndex = scriptContent.indexOf('{');
|
||||
@ -32,6 +55,8 @@ class ReadHttp {
|
||||
return {
|
||||
'status': true,
|
||||
'data': OpusDataModel.fromJson(jsonData),
|
||||
'isCv': isCv,
|
||||
'cvId': cvId,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,17 @@ class OpusController extends GetxController {
|
||||
Future fetchOpusData() async {
|
||||
var res = await ReadHttp.parseArticleOpus(id: id);
|
||||
if (res['status']) {
|
||||
List<String> keys = res.keys.toList();
|
||||
if (keys.contains('isCv') && res['isCv']) {
|
||||
Get.offNamed('/read', parameters: {
|
||||
'id': res['cvId'],
|
||||
'title': title.value,
|
||||
'articleType': 'cv',
|
||||
});
|
||||
} else {
|
||||
opusData.value = res['data'];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,9 @@ class _OpusPageState extends State<OpusPage> {
|
||||
}
|
||||
|
||||
Widget _buildContent(OpusDataModel opusData) {
|
||||
if (opusData.detail == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
final modules = opusData.detail!.modules!;
|
||||
late ModuleContent moduleContent;
|
||||
// 获取所有的图片链接
|
||||
|
Reference in New Issue
Block a user