mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: article
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -166,7 +166,7 @@ class _SavePanelState extends State<SavePanel> {
|
|||||||
case 'DYNAMIC_TYPE_AV':
|
case 'DYNAMIC_TYPE_AV':
|
||||||
viewType = '观看';
|
viewType = '观看';
|
||||||
itemType = '视频';
|
itemType = '视频';
|
||||||
uri = 'bilibili://video/${item.basic!['comment_id_str']}';
|
uri = 'bilibili://video/${item.basic.commentIdStr}';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'DYNAMIC_TYPE_ARTICLE':
|
case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:PiliPlus/models/dynamics/article_content_model.dart'
|
|||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
import 'package:PiliPlus/models/model_owner.dart';
|
import 'package:PiliPlus/models/model_owner.dart';
|
||||||
import 'package:PiliPlus/models/space_article/item.dart';
|
import 'package:PiliPlus/models/space_article/item.dart';
|
||||||
import 'package:PiliPlus/models/space_article/stats.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';
|
||||||
@@ -88,23 +87,24 @@ class ArticleController extends ReplyController<MainListReply> {
|
|||||||
Future<bool> queryOpus(opusId) async {
|
Future<bool> queryOpus(opusId) async {
|
||||||
final res = await DynamicsHttp.opusDetail(opusId: opusId);
|
final res = await DynamicsHttp.opusDetail(opusId: opusId);
|
||||||
if (res is Success) {
|
if (res is Success) {
|
||||||
opusData = (res as Success<DynamicItemModel>).response;
|
final opusData = (res as Success<DynamicItemModel>).response;
|
||||||
//fallback
|
//fallback
|
||||||
if (opusData?.fallback?.id != null) {
|
if (opusData.fallback?.id != null) {
|
||||||
id = opusData!.fallback!.id!;
|
id = opusData.fallback!.id!;
|
||||||
type = 'read';
|
type = 'read';
|
||||||
setUrl();
|
setUrl();
|
||||||
_queryContent();
|
_queryContent();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
commentType = opusData!.basic!.commentType!;
|
this.opusData = opusData;
|
||||||
commentId = int.parse(opusData!.basic!.commentIdStr!);
|
commentType = opusData.basic!.commentType!;
|
||||||
if (showDynActionBar && opusData!.modules.moduleStat != null) {
|
commentId = int.parse(opusData.basic!.commentIdStr!);
|
||||||
stats.value = opusData!.modules.moduleStat!;
|
if (showDynActionBar && opusData.modules.moduleStat != null) {
|
||||||
|
stats.value = opusData.modules.moduleStat;
|
||||||
}
|
}
|
||||||
summary
|
summary
|
||||||
..author ??= opusData!.modules.moduleAuthor
|
..author ??= opusData.modules.moduleAuthor
|
||||||
..title ??= opusData!.modules.moduleTag?.text;
|
..title ??= opusData.modules.moduleTag?.text;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -119,28 +119,42 @@ class ArticleController extends ReplyController<MainListReply> {
|
|||||||
..title ??= articleData!.title
|
..title ??= articleData!.title
|
||||||
..cover ??= articleData!.originImageUrls?.firstOrNull;
|
..cover ??= articleData!.originImageUrls?.firstOrNull;
|
||||||
|
|
||||||
if (showDynActionBar && opusData?.modules.moduleStat == null) {
|
if (showDynActionBar) {
|
||||||
final dynId = articleData!.dynIdStr;
|
_queryReadAsDyn(articleData!.dynIdStr);
|
||||||
if (dynId != null) {
|
_getArticleInfo();
|
||||||
_queryReadAsDyn(dynId);
|
|
||||||
} else {
|
|
||||||
debugPrint('cvid2opus failed: $id');
|
|
||||||
}
|
|
||||||
_statsToModuleStat(articleData!.stats!);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_queryReadAsDyn(id) async {
|
// data for forward
|
||||||
// 仅用于获取moduleStat
|
Future _queryReadAsDyn(id) async {
|
||||||
|
if (opusData != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final res = await DynamicsHttp.dynamicDetail(id: id);
|
final res = await DynamicsHttp.dynamicDetail(id: id);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
opusData = res['data'] as DynamicItemModel;
|
opusData = res['data'];
|
||||||
if (opusData!.modules.moduleStat != null) {
|
}
|
||||||
stats.value = opusData!.modules.moduleStat!;
|
}
|
||||||
}
|
|
||||||
|
// stats
|
||||||
|
Future _getArticleInfo() async {
|
||||||
|
final res = await DynamicsHttp.articleInfo(cvId: id);
|
||||||
|
if (res['status']) {
|
||||||
|
stats.value = ModuleStatModel(
|
||||||
|
comment: DynamicStat(count: res['data']?['stats']?['reply']),
|
||||||
|
forward: DynamicStat(count: res['data']?['stats']?['share']),
|
||||||
|
like: DynamicStat(
|
||||||
|
count: res['data']?['stats']?['like'],
|
||||||
|
status: res['data']?['like'] == 1,
|
||||||
|
),
|
||||||
|
favorite: DynamicStat(
|
||||||
|
count: res['data']?['stats']?['reply'],
|
||||||
|
status: res['data']?['favorite'],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,21 +215,24 @@ class ArticleController extends ReplyController<MainListReply> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _statsToModuleStat(Stats dynStats) {
|
Future onLike(VoidCallback callback) async {
|
||||||
if (stats.value == null) {
|
bool isLike = stats.value?.like?.status == true;
|
||||||
stats.value = ModuleStatModel(
|
final res = await DynamicsHttp.likeDynamic(
|
||||||
comment: _setCount(dynStats.reply),
|
dynamicId: opusData?.idStr, up: isLike ? 2 : 1);
|
||||||
forward: _setCount(dynStats.dyn),
|
if (res['status']) {
|
||||||
like: _setCount(dynStats.like),
|
stats.value?.like?.status = !isLike;
|
||||||
favorite: _setCount(dynStats.favorite),
|
int count = stats.value?.like?.count ?? 0;
|
||||||
);
|
if (isLike) {
|
||||||
|
stats.value?.like?.count = count - 1;
|
||||||
|
} else {
|
||||||
|
stats.value?.like?.count = count + 1;
|
||||||
|
}
|
||||||
|
stats.refresh();
|
||||||
|
SmartDialog.showToast(!isLike ? '点赞成功' : '取消赞');
|
||||||
} else {
|
} else {
|
||||||
// 动态类无收藏数据
|
SmartDialog.showToast(res['msg']);
|
||||||
stats.value!.favorite ??= _setCount(dynStats.favorite);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicStat _setCount(int? count) => DynamicStat(count: count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Summary {
|
class Summary {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart';
|
|||||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
import 'package:PiliPlus/utils/request_utils.dart';
|
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
@@ -600,17 +599,6 @@ class _ArticlePageState extends State<ArticlePage>
|
|||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
icon: const Icon(Icons.more_vert, size: 19),
|
icon: const Icon(Icons.more_vert, size: 19),
|
||||||
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||||
PopupMenuItem(
|
|
||||||
onTap: () => Utils.copyText(_articleCtr.url),
|
|
||||||
child: const Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.copy_rounded, size: 19),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text('复制链接'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () => Utils.shareText(_articleCtr.url),
|
onTap: () => Utils.shareText(_articleCtr.url),
|
||||||
child: const Row(
|
child: const Row(
|
||||||
@@ -622,8 +610,18 @@ class _ArticlePageState extends State<ArticlePage>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_articleCtr.commentType == 12 &&
|
PopupMenuItem(
|
||||||
_articleCtr.stats.value != null)
|
onTap: () => Utils.copyText(_articleCtr.url),
|
||||||
|
child: const Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.copy_rounded, size: 19),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text('复制链接'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_articleCtr.type == 'read' && _articleCtr.stats.value != null)
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
try {
|
try {
|
||||||
@@ -828,16 +826,16 @@ class _ArticlePageState extends State<ArticlePage>
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) => TextButton.icon(
|
builder: (context) => TextButton.icon(
|
||||||
onPressed: () =>
|
onPressed: () {
|
||||||
RequestUtils.onLikeDynamic(
|
_articleCtr.onLike(
|
||||||
_articleCtr.opusData!,
|
() {
|
||||||
() {
|
if (context.mounted) {
|
||||||
if (context.mounted) {
|
(context as Element?)
|
||||||
(context as Element?)
|
?.markNeedsBuild();
|
||||||
?.markNeedsBuild();
|
}
|
||||||
}
|
},
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_articleCtr.stats.value?.like
|
_articleCtr.stats.value?.like
|
||||||
?.status ==
|
?.status ==
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ InlineSpan? richNode(item, BuildContext context) {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
try {
|
try {
|
||||||
String dynamicId = item.basic['comment_id_str'];
|
String dynamicId = item.basic.commentIdStr;
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webview',
|
||||||
parameters: {
|
parameters: {
|
||||||
|
|||||||
Reference in New Issue
Block a user