From 5929150047343fba31922bd942d721ab88eefc89 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Mon, 31 Mar 2025 14:51:10 +0800 Subject: [PATCH] fix: push `bilibili://following/detail` related #576 Signed-off-by: bggRGjQaUbCoE --- lib/models/msg/msgfeed_reply_me.dart | 82 +++++++++++------------ lib/pages/msg_feed_top/reply_me/view.dart | 38 +++++------ lib/utils/app_scheme.dart | 12 +++- 3 files changed, 69 insertions(+), 63 deletions(-) diff --git a/lib/models/msg/msgfeed_reply_me.dart b/lib/models/msg/msgfeed_reply_me.dart index 4d824a61..6c9106ee 100644 --- a/lib/models/msg/msgfeed_reply_me.dart +++ b/lib/models/msg/msgfeed_reply_me.dart @@ -6,8 +6,7 @@ class MsgFeedReplyMe { MsgFeedReplyMe({this.cursor, this.items, this.lastViewAt}); MsgFeedReplyMe.fromJson(Map json) { - cursor = - json['cursor'] != null ? Cursor.fromJson(json['cursor']) : null; + cursor = json['cursor'] != null ? Cursor.fromJson(json['cursor']) : null; if (json['items'] != null) { items = []; json['items'].forEach((v) { @@ -56,13 +55,14 @@ class ReplyMeItems { int? isMulti; int? replyTime; - ReplyMeItems( - {this.id, - this.user, - this.item, - this.counts, - this.isMulti, - this.replyTime}); + ReplyMeItems({ + this.id, + this.user, + this.item, + this.counts, + this.isMulti, + this.replyTime, + }); ReplyMeItems.fromJson(Map json) { id = json['id']; @@ -99,11 +99,11 @@ class User { User( {this.mid, - this.fans, - this.nickname, - this.avatar, - this.midLink, - this.follow}); + this.fans, + this.nickname, + this.avatar, + this.midLink, + this.follow}); User.fromJson(Map json) { mid = json['mid']; @@ -153,28 +153,28 @@ class Item { Item( {this.subjectId, - this.rootId, - this.sourceId, - this.targetId, - this.type, - this.businessId, - this.business, - this.title, - this.desc, - this.image, - this.uri, - this.nativeUri, - this.detailTitle, - this.rootReplyContent, - this.sourceContent, - this.targetReplyContent, - this.atDetails, - this.topicDetails, - this.hideReplyButton, - this.hideLikeButton, - this.likeState, - this.danmu, - this.message}); + this.rootId, + this.sourceId, + this.targetId, + this.type, + this.businessId, + this.business, + this.title, + this.desc, + this.image, + this.uri, + this.nativeUri, + this.detailTitle, + this.rootReplyContent, + this.sourceContent, + this.targetReplyContent, + this.atDetails, + this.topicDetails, + this.hideReplyButton, + this.hideLikeButton, + this.likeState, + this.danmu, + this.message}); Item.fromJson(Map json) { subjectId = json['subject_id']; @@ -246,11 +246,11 @@ class AtDetails { AtDetails( {this.mid, - this.fans, - this.nickname, - this.avatar, - this.midLink, - this.follow}); + this.fans, + this.nickname, + this.avatar, + this.midLink, + this.follow}); AtDetails.fromJson(Map json) { mid = json['mid']; diff --git a/lib/pages/msg_feed_top/reply_me/view.dart b/lib/pages/msg_feed_top/reply_me/view.dart index d8411356..b7a52f0d 100644 --- a/lib/pages/msg_feed_top/reply_me/view.dart +++ b/lib/pages/msg_feed_top/reply_me/view.dart @@ -1,6 +1,7 @@ import 'package:PiliPlus/common/widgets/loading_widget.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/http/loading_state.dart'; +import 'package:PiliPlus/models/msg/msgfeed_reply_me.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -46,29 +47,31 @@ class _ReplyMePageState extends State { _replyMeController.onLoadMore(); } + ReplyMeItems item = loadingState.response[index]; return ListTile( onTap: () { - String? nativeUri = - loadingState.response[index].item?.nativeUri; + String? nativeUri = item.item?.nativeUri; if (nativeUri != null) { - PiliScheme.routePushFromUrl(nativeUri); + PiliScheme.routePushFromUrl( + nativeUri, + businessId: item.item?.businessId, + ); } }, leading: GestureDetector( onTap: () { - Get.toNamed( - '/member?mid=${loadingState.response[index].user?.mid}'); + Get.toNamed('/member?mid=${item.user?.mid}'); }, child: NetworkImgLayer( width: 45, height: 45, type: 'avatar', - src: loadingState.response[index].user?.avatar, + src: item.user?.avatar, ), ), title: Text( - "${loadingState.response[index].user?.nickname} " - "回复了我的${loadingState.response[index].item?.business}", + "${item.user?.nickname}${item.isMulti == 1 ? '等人' : ''} " + "回复了我的${item.item?.business} ${item.isMulti == 1 ? ',共${item.counts}条' : ''}", style: Theme.of(context) .textTheme .bodyMedium! @@ -79,9 +82,7 @@ class _ReplyMePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 4), - Text( - loadingState.response[index].item?.sourceContent ?? - "", + Text(item.item?.sourceContent ?? "", style: Theme.of(context).textTheme.bodyMedium), const SizedBox(height: 4), if (loadingState @@ -90,8 +91,7 @@ class _ReplyMePageState extends State { loadingState .response[index].item?.targetReplyContent != "") - Text( - "| ${loadingState.response[index].item?.targetReplyContent}", + Text("| ${item.item?.targetReplyContent}", maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context) @@ -101,12 +101,9 @@ class _ReplyMePageState extends State { color: Theme.of(context).colorScheme.outline, height: 1.5)), - if (loadingState.response[index].item?.rootReplyContent != - null && - loadingState.response[index].item?.rootReplyContent != - "") - Text( - " | ${loadingState.response[index].item?.rootReplyContent}", + if (item.item?.rootReplyContent != null && + item.item?.rootReplyContent != "") + Text(" | ${item.item?.rootReplyContent}", maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context) @@ -117,8 +114,7 @@ class _ReplyMePageState extends State { Theme.of(context).colorScheme.outline, height: 1.5)), Text( - Utils.dateFormat( - loadingState.response[index].replyTime), + Utils.dateFormat(item.replyTime), style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: Theme.of(context).colorScheme.outline, ), diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 0d8a8f78..315e4781 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -35,6 +35,7 @@ class PiliScheme { bool selfHandle = false, bool off = false, Map? parameters, + int? businessId, }) async { try { if (url.startsWith('//')) { @@ -47,6 +48,7 @@ class PiliScheme { selfHandle: selfHandle, off: off, parameters: parameters, + businessId: businessId, ); } catch (_) { return false; @@ -59,6 +61,7 @@ class PiliScheme { bool selfHandle = false, bool off = false, Map? parameters, + int? businessId, }) async { final String scheme = uri.scheme; final String host = uri.host.toLowerCase(); @@ -273,9 +276,14 @@ class PiliScheme { ), ); return true; + } else if (path.startsWith("/msg_fold/")) { + // bilibili://comment/msg_fold/1/22222/33333/11111/?enterUri=bilibili://video/22222 + // bilibili://comment/msg_fold/11/22222/33333/11111/?enterUri=bilibili://following/detail/44444 } return false; case 'following': + // bilibili://following/detail/832703053858603029 + // bilibili://following/detail/12345678?comment_root_id=654321\u0026comment_on=1 if (path.startsWith("/detail/")) { final queryParameters = uri.queryParameters; final commentRootId = queryParameters['comment_root_id']; @@ -302,7 +310,9 @@ class PiliScheme { oid: int.parse(oid), rpid: rpid, source: 'routePush', - replyType: ReplyType.dynamics, + replyType: businessId != null + ? ReplyType.values[businessId] + : ReplyType.dynamics, firstFloor: null, id: queryParameters['comment_secondary_id'] != null ? int.tryParse(