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