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: {
|
var res = await Request().get('https://www.bilibili.com/opus/$id', extra: {
|
||||||
'ua': 'pc',
|
'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 =
|
String scriptContent =
|
||||||
extractScriptContents(parse(res.data).body!.outerHtml)[0];
|
extractScriptContents(parse(res.data).body!.outerHtml)[0];
|
||||||
int startIndex = scriptContent.indexOf('{');
|
int startIndex = scriptContent.indexOf('{');
|
||||||
@ -32,6 +55,8 @@ class ReadHttp {
|
|||||||
return {
|
return {
|
||||||
'status': true,
|
'status': true,
|
||||||
'data': OpusDataModel.fromJson(jsonData),
|
'data': OpusDataModel.fromJson(jsonData),
|
||||||
|
'isCv': isCv,
|
||||||
|
'cvId': cvId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,16 @@ class OpusController extends GetxController {
|
|||||||
Future fetchOpusData() async {
|
Future fetchOpusData() async {
|
||||||
var res = await ReadHttp.parseArticleOpus(id: id);
|
var res = await ReadHttp.parseArticleOpus(id: id);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
opusData.value = res['data'];
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,9 @@ class _OpusPageState extends State<OpusPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContent(OpusDataModel opusData) {
|
Widget _buildContent(OpusDataModel opusData) {
|
||||||
|
if (opusData.detail == null) {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
final modules = opusData.detail!.modules!;
|
final modules = opusData.detail!.modules!;
|
||||||
late ModuleContent moduleContent;
|
late ModuleContent moduleContent;
|
||||||
// 获取所有的图片链接
|
// 获取所有的图片链接
|
||||||
|
Reference in New Issue
Block a user