mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: 专栏评论区异常重载且丢失数据
This commit is contained in:
@@ -45,11 +45,15 @@ class HtmlRenderController extends GetxController {
|
||||
}
|
||||
response = res;
|
||||
oid.value = res['commentId'];
|
||||
queryReplyList(reqType: 'init');
|
||||
return res;
|
||||
}
|
||||
|
||||
// 请求评论
|
||||
Future queryReplyList({reqType = 'init'}) async {
|
||||
if (reqType == 'init') {
|
||||
currentPage = 0;
|
||||
}
|
||||
var res = await ReplyHttp.replyList(
|
||||
oid: oid.value,
|
||||
pageNum: currentPage + 1,
|
||||
|
||||
@@ -32,7 +32,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
late String dynamicType;
|
||||
late int type;
|
||||
bool _isFabVisible = true;
|
||||
late Future _futureBuilderFuture;
|
||||
late final Future _futureBuilderFuture;
|
||||
late ScrollController scrollController;
|
||||
late AnimationController fabAnimationCtr;
|
||||
|
||||
@@ -182,15 +182,14 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
controller: scrollController,
|
||||
child: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
child: FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
var data = snapshot.data;
|
||||
fabAnimationCtr.forward();
|
||||
if (data['status']) {
|
||||
// fabAnimationCtr.forward();
|
||||
if (data != null && data['status']) {
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
@@ -205,8 +204,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(_htmlRenderCtr.response['uname'],
|
||||
style: TextStyle(
|
||||
@@ -218,9 +216,8 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
Text(
|
||||
_htmlRenderCtr.response['updateTime'],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
@@ -251,20 +248,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Text('error');
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
Obx(
|
||||
() => _htmlRenderCtr.oid.value != -1
|
||||
? Container(
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border(
|
||||
@@ -297,46 +281,29 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
Obx(
|
||||
() => _htmlRenderCtr.oid.value != -1
|
||||
? FutureBuilder(
|
||||
future: _htmlRenderCtr.queryReplyList(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done) {
|
||||
Map data = snapshot.data as Map;
|
||||
if (snapshot.data['status']) {
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => _htmlRenderCtr.replyList.isEmpty &&
|
||||
_htmlRenderCtr.isLoadingMore
|
||||
? ListView.builder(
|
||||
itemCount: 5,
|
||||
shrinkWrap: true,
|
||||
physics:
|
||||
const NeverScrollableScrollPhysics(),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoReplySkeleton();
|
||||
},
|
||||
)
|
||||
: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics:
|
||||
const NeverScrollableScrollPhysics(),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount:
|
||||
_htmlRenderCtr.replyList.length +
|
||||
1,
|
||||
_htmlRenderCtr.replyList.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index ==
|
||||
_htmlRenderCtr
|
||||
.replyList.length) {
|
||||
_htmlRenderCtr.replyList.length) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(
|
||||
bottom:
|
||||
MediaQuery.of(context)
|
||||
bottom: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom),
|
||||
height: MediaQuery.of(context)
|
||||
@@ -346,8 +313,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_htmlRenderCtr
|
||||
.noMore.value,
|
||||
_htmlRenderCtr.noMore.value,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context)
|
||||
@@ -360,14 +326,13 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
);
|
||||
} else {
|
||||
return ReplyItem(
|
||||
replyItem: _htmlRenderCtr
|
||||
.replyList[index],
|
||||
replyItem:
|
||||
_htmlRenderCtr.replyList[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
replyType:
|
||||
ReplyType.values[type],
|
||||
replyType: ReplyType.values[type],
|
||||
addReply: (replyItem) {
|
||||
_htmlRenderCtr
|
||||
.replyList[index].replies!
|
||||
@@ -377,34 +342,17 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Text('error');
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: 5,
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoReplySkeleton();
|
||||
},
|
||||
);
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
|
||||
Reference in New Issue
Block a user