mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
revert: lazy to opus
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -11,7 +11,7 @@ import 'package:PiliPlus/models/space_article/item.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
@@ -21,9 +21,7 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
late String id;
|
||||
late String type;
|
||||
|
||||
late String url = type == 'read'
|
||||
? 'https://www.bilibili.com/read/cv$id'
|
||||
: 'https://www.bilibili.com/opus/$id';
|
||||
late String url;
|
||||
late int commentType;
|
||||
late int commentId;
|
||||
final summary = Summary();
|
||||
@@ -50,12 +48,31 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
id = Get.parameters['id']!;
|
||||
type = Get.parameters['type']!;
|
||||
|
||||
commentType = type == 'picture' ? 11 : 12;
|
||||
|
||||
_queryContent(); // lazy to opus
|
||||
// to opus
|
||||
if (type == 'read') {
|
||||
UrlUtils.parseRedirectUrl('https://www.bilibili.com/read/cv$id/')
|
||||
.then((url) {
|
||||
if (url != null) {
|
||||
id = url.split('/').last;
|
||||
type = 'opus';
|
||||
}
|
||||
init();
|
||||
});
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _queryOpus(opusId) async {
|
||||
init() {
|
||||
url = type == 'read'
|
||||
? 'https://www.bilibili.com/read/cv$id'
|
||||
: 'https://www.bilibili.com/opus/$id';
|
||||
commentType = type == 'picture' ? 11 : 12;
|
||||
|
||||
_queryContent();
|
||||
}
|
||||
|
||||
Future<bool> queryOpus(opusId) async {
|
||||
final res = await DynamicsHttp.opusDetail(opusId: opusId);
|
||||
if (res.isSuccess) {
|
||||
final opusData = res.data;
|
||||
@@ -63,49 +80,42 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
if (opusData.fallback?.id != null) {
|
||||
id = opusData.fallback!.id!;
|
||||
type = 'read';
|
||||
if (articleData?.content == null) {
|
||||
await _queryRead(id, false);
|
||||
}
|
||||
return;
|
||||
init();
|
||||
return false;
|
||||
}
|
||||
this.opusData = opusData;
|
||||
commentType = opusData.basic!.commentType!;
|
||||
commentId = int.parse(opusData.basic!.commentIdStr!);
|
||||
if (showDynActionBar && opusData.modules.moduleStat != null) {
|
||||
stats.value = opusData.modules.moduleStat;
|
||||
if (showDynActionBar) {
|
||||
if (opusData.modules.moduleStat != null) {
|
||||
stats.value = opusData.modules.moduleStat;
|
||||
} else {
|
||||
getArticleInfo();
|
||||
}
|
||||
}
|
||||
summary
|
||||
..author ??= opusData.modules.moduleAuthor
|
||||
..title ??= opusData.modules.moduleTag?.text;
|
||||
isLoaded.value = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> _queryRead(cvId, [bool toOpus = false]) async {
|
||||
final res = await DynamicsHttp.articleView(cvId: cvId);
|
||||
Future<bool> queryRead(cvid) async {
|
||||
final res = await DynamicsHttp.articleView(cvId: cvid);
|
||||
if (res.isSuccess) {
|
||||
articleData = res.data;
|
||||
summary
|
||||
..author ??= articleData!.author
|
||||
..title ??= articleData!.title
|
||||
..cover ??= articleData!.originImageUrls?.firstOrNull;
|
||||
isLoaded.value = true;
|
||||
|
||||
if (toOpus &&
|
||||
articleData!.dynIdStr != null &&
|
||||
articleData?.opus?.content?.isNotEmpty != true) {
|
||||
await _queryOpus(articleData!.dynIdStr);
|
||||
if (opusData != null) {
|
||||
id = articleData!.dynIdStr!;
|
||||
type = 'opus';
|
||||
isLoaded.refresh();
|
||||
}
|
||||
}
|
||||
if (showDynActionBar && stats.value == null) {
|
||||
// _queryReadAsDyn(articleData!.dynIdStr);
|
||||
if (showDynActionBar) {
|
||||
getArticleInfo();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// stats
|
||||
@@ -116,7 +126,7 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
..cover ??= (res['data']?['origin_image_urls'] as List?)?.firstOrNull
|
||||
..title ??= res['data']?['title'];
|
||||
|
||||
stats.value = ModuleStatModel(
|
||||
stats.value ??= ModuleStatModel(
|
||||
comment: DynamicStat(count: res['data']?['stats']?['reply']),
|
||||
forward: DynamicStat(count: res['data']?['stats']?['share']),
|
||||
like: DynamicStat(
|
||||
@@ -130,18 +140,17 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
);
|
||||
return true;
|
||||
}
|
||||
SmartDialog.showToast(res['msg']);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 请求动态内容
|
||||
Future _queryContent() async {
|
||||
if (type != 'read') {
|
||||
await _queryOpus(id);
|
||||
isLoaded.value = await queryOpus(id);
|
||||
} else {
|
||||
commentId = int.parse(id);
|
||||
commentType = 12;
|
||||
await _queryRead(commentId, true);
|
||||
isLoaded.value = await queryRead(commentId);
|
||||
}
|
||||
if (isLoaded.value) {
|
||||
queryData();
|
||||
@@ -191,7 +200,7 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
}
|
||||
}
|
||||
|
||||
Future onLike(VoidCallback callback) async {
|
||||
Future onLike() async {
|
||||
bool isLike = stats.value?.like?.status == true;
|
||||
final res = await DynamicsHttp.likeDynamic(
|
||||
dynamicId: opusData?.idStr ?? articleData?.dynIdStr,
|
||||
|
||||
@@ -440,7 +440,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
Widget _buildReplyList(LoadingState<List<ReplyInfo>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverList.builder(
|
||||
itemCount: 5,
|
||||
itemCount: 12,
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoReplySkeleton();
|
||||
},
|
||||
@@ -778,6 +778,15 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
stat: _articleCtr
|
||||
.stats.value?.forward,
|
||||
callback: () {
|
||||
if (_articleCtr.opusData ==
|
||||
null &&
|
||||
_articleCtr.articleData
|
||||
?.dynIdStr ==
|
||||
null) {
|
||||
SmartDialog.showToast(
|
||||
'err: ${_articleCtr.id}');
|
||||
return;
|
||||
}
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
@@ -785,10 +794,14 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
builder: (context) =>
|
||||
RepostPanel(
|
||||
item: _articleCtr.opusData,
|
||||
dynIdStr: _articleCtr
|
||||
.articleData?.dynIdStr,
|
||||
pic:
|
||||
_articleCtr.summary.cover,
|
||||
title:
|
||||
_articleCtr.summary.title,
|
||||
uname: _articleCtr
|
||||
.summary.author?.name,
|
||||
callback: () {
|
||||
int count = _articleCtr
|
||||
.stats
|
||||
@@ -834,16 +847,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
Expanded(
|
||||
child: Builder(
|
||||
builder: (context) => TextButton.icon(
|
||||
onPressed: () {
|
||||
_articleCtr.onLike(
|
||||
() {
|
||||
if (context.mounted) {
|
||||
(context as Element?)
|
||||
?.markNeedsBuild();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
onPressed: _articleCtr.onLike,
|
||||
icon: Icon(
|
||||
_articleCtr.stats.value?.like
|
||||
?.status ==
|
||||
|
||||
@@ -16,6 +16,7 @@ class RepostPanel extends CommonPublishPage {
|
||||
const RepostPanel({
|
||||
super.key,
|
||||
this.item,
|
||||
this.dynIdStr,
|
||||
this.callback,
|
||||
// video
|
||||
this.rid,
|
||||
@@ -35,6 +36,7 @@ class RepostPanel extends CommonPublishPage {
|
||||
final bool? isMax;
|
||||
|
||||
final DynamicItemModel? item;
|
||||
final String? dynIdStr;
|
||||
final VoidCallback? callback;
|
||||
|
||||
@override
|
||||
@@ -343,7 +345,7 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
|
||||
Future onCustomPublish({required String message, List? pictures}) async {
|
||||
dynamic result = await MsgHttp.createDynamic(
|
||||
mid: Accounts.main.mid,
|
||||
dynIdStr: widget.item?.idStr,
|
||||
dynIdStr: widget.item?.idStr ?? widget.dynIdStr,
|
||||
rid: widget.rid,
|
||||
dynType: widget.dynType,
|
||||
rawText: editController.text,
|
||||
|
||||
Reference in New Issue
Block a user