mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: article req
Closes #305 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:PiliPlus/models/dynamics/article_content_model.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:html/dom.dart' as dom;
|
||||
@@ -48,10 +49,11 @@ class HtmlHttp {
|
||||
String opusContent =
|
||||
opusDetail.querySelector('.opus-module-content')!.innerHtml;
|
||||
String? test;
|
||||
try {
|
||||
test = opusDetail
|
||||
.querySelector('.horizontal-scroll-album__pic__img')
|
||||
?.innerHtml ??
|
||||
'';
|
||||
.querySelector('.horizontal-scroll-album__pic__img')!
|
||||
.innerHtml;
|
||||
} catch (_) {}
|
||||
|
||||
String commentId = opusDetail
|
||||
.querySelector('.bili-comment-container')!
|
||||
@@ -64,7 +66,7 @@ class HtmlHttp {
|
||||
'avatar': avatar,
|
||||
'uname': uname,
|
||||
'updateTime': updateTime,
|
||||
'content': test + opusContent,
|
||||
'content': (test ?? '') + opusContent,
|
||||
'commentId': int.parse(commentId)
|
||||
};
|
||||
} catch (err) {
|
||||
@@ -74,6 +76,12 @@ class HtmlHttp {
|
||||
|
||||
// read
|
||||
static Future reqReadHtml(id, dynamicType) async {
|
||||
String? redirectUrl = await UrlUtils.parseRedirectUrl(
|
||||
'https://www.bilibili.com/$dynamicType/$id/');
|
||||
if (redirectUrl != null) {
|
||||
return await reqHtml(redirectUrl.split('/').last, dynamicType);
|
||||
}
|
||||
|
||||
var response = await Request().get(
|
||||
"https://www.bilibili.com/$dynamicType/$id/",
|
||||
extra: {'ua': 'pc'},
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:math';
|
||||
import 'package:PiliPlus/common/widgets/article_content.dart';
|
||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_sort_type.dart';
|
||||
@@ -404,7 +405,11 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
child: Scaffold(
|
||||
key: _key,
|
||||
backgroundColor: Colors.transparent,
|
||||
body: CustomScrollView(
|
||||
body: refreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _htmlRenderCtr.onRefresh();
|
||||
},
|
||||
child: CustomScrollView(
|
||||
controller: _htmlRenderCtr.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
@@ -425,6 +430,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user