diff --git a/lib/http/api.dart b/lib/http/api.dart index 3ce31963..db761e2f 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -786,4 +786,6 @@ class Api { static const String articleView = '/x/article/view'; static const String opusDetail = '/x/polymer/web-dynamic/v1/opus/detail'; + + static const String feedInfoWeb = '${HttpString.tUrl}/x/im/feed/infoweb'; } diff --git a/lib/http/msg.dart b/lib/http/msg.dart index 3f6216a3..66cadf1f 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -570,4 +570,26 @@ class MsgHttp { static String getDevId() { return Uuid().v4(); } + + static Future feedInfoWeb({ + List? aids, + List? epIds, + List? articleIds, + }) async { + var res = await Request().get( + Api.feedInfoWeb, + queryParameters: { + if (aids != null) 'aids': aids.join(','), + if (epIds != null) 'ep_ids': epIds.join(','), + if (articleIds != null) 'article_ids': articleIds.join(','), + 'build': 0, + 'mobi_app': 'web', + }, + ); + if (res.data['code'] == 0) { + return {'status': true, 'data': res.data['data']}; + } else { + return {'status': false, 'msg': res.data['message']}; + } + } } diff --git a/lib/pages/article/controller.dart b/lib/pages/article/controller.dart index b4b9d2c3..d887c4b2 100644 --- a/lib/pages/article/controller.dart +++ b/lib/pages/article/controller.dart @@ -1,6 +1,7 @@ import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart'; import 'package:PiliPlus/http/dynamics.dart'; import 'package:PiliPlus/http/loading_state.dart'; +import 'package:PiliPlus/http/msg.dart'; import 'package:PiliPlus/http/user.dart'; import 'package:PiliPlus/http/video.dart'; import 'package:PiliPlus/models/dynamics/article_content_model.dart' @@ -141,7 +142,7 @@ class ArticleController extends ReplyController { // stats Future _getArticleInfo() async { - final res = await DynamicsHttp.articleInfo(cvId: id); + final res = await DynamicsHttp.articleInfo(cvId: commentId); if (res['status']) { stats.value = ModuleStatModel( comment: DynamicStat(count: res['data']?['stats']?['reply']), @@ -233,6 +234,19 @@ class ArticleController extends ReplyController { SmartDialog.showToast(res['msg']); } } + + Future getArticleCover() async { + final res = await MsgHttp.feedInfoWeb(articleIds: [commentId]); + if (res['status']) { + summary.cover = ((res['data']?['article'] as List?) + ?.firstOrNull?['image_urls'] as List?) + ?.firstOrNull; + // debugPrint('cover: ${summary.cover}'); + return summary.cover != null; + } else { + SmartDialog.showToast(res['msg']); + } + } } class Summary { diff --git a/lib/pages/article/view.dart b/lib/pages/article/view.dart index e7e2ad1a..90ff64b8 100644 --- a/lib/pages/article/view.dart +++ b/lib/pages/article/view.dart @@ -620,10 +620,17 @@ class _ArticlePageState extends State ], ), ), - if (_articleCtr.type == 'read' && _articleCtr.stats.value != null) + if (_articleCtr.commentType == 12 && + _articleCtr.stats.value != null) PopupMenuItem( - onTap: () { + onTap: () async { try { + if (_articleCtr.summary.cover == null) { + final res = await _articleCtr.getArticleCover(); + if (res != true) { + return; + } + } PageUtils.pmShare( content: { "id": _articleCtr.commentId,