diff --git a/lib/http/html.dart b/lib/http/html.dart
index 41570d0a..52b228a5 100644
--- a/lib/http/html.dart
+++ b/lib/http/html.dart
@@ -40,9 +40,13 @@ class HtmlHttp {
//
String opusContent =
opusDetail.querySelector('.opus-module-content')!.innerHtml;
- String test = opusDetail
- .querySelector('.horizontal-scroll-album__pic__img')!
- .innerHtml;
+ String? test;
+ try {
+ test = opusDetail
+ .querySelector('.horizontal-scroll-album__pic__img')!
+ .innerHtml;
+ } catch (_) {}
+
String commentId = opusDetail
.querySelector('.bili-comment-container')!
.className
@@ -54,7 +58,7 @@ class HtmlHttp {
'avatar': avatar,
'uname': uname,
'updateTime': updateTime,
- 'content': test + opusContent,
+ 'content': (test ?? '') + opusContent,
'commentId': int.parse(commentId)
};
} catch (err) {
diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart
index d8aff7b5..2f7c2d40 100644
--- a/lib/models/dynamics/result.dart
+++ b/lib/models/dynamics/result.dart
@@ -78,12 +78,14 @@ class ItemModulesModel {
this.moduleDynamic,
// this.moduleInter,
this.moduleStat,
+ this.moduleTag,
});
ModuleAuthorModel? moduleAuthor;
ModuleDynamicModel? moduleDynamic;
// ModuleInterModel? moduleInter;
ModuleStatModel? moduleStat;
+ Map? moduleTag;
ItemModulesModel.fromJson(Map json) {
moduleAuthor = json['module_author'] != null
@@ -96,6 +98,7 @@ class ItemModulesModel {
moduleStat = json['module_stat'] != null
? ModuleStatModel.fromJson(json['module_stat'])
: null;
+ moduleTag = json['module_tag'];
}
}
diff --git a/lib/pages/dynamics/deatil/controller.dart b/lib/pages/dynamics/deatil/controller.dart
index 62f0245d..1520377e 100644
--- a/lib/pages/dynamics/deatil/controller.dart
+++ b/lib/pages/dynamics/deatil/controller.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
+import 'package:pilipala/http/html.dart';
import 'package:pilipala/http/reply.dart';
import 'package:pilipala/models/common/reply_sort_type.dart';
import 'package:pilipala/models/video/reply/item.dart';
@@ -103,4 +104,10 @@ class DynamicDetailController extends GetxController {
replyList.clear();
queryReplyList(reqType: 'init');
}
+
+ // 根据jumpUrl获取动态html
+ reqHtmlByOpusId(int id) async {
+ var res = await HtmlHttp.reqHtml(id, 'opus');
+ oid = res['commentId'];
+ }
}
diff --git a/lib/pages/dynamics/deatil/view.dart b/lib/pages/dynamics/deatil/view.dart
index 116e0d27..28f70bcf 100644
--- a/lib/pages/dynamics/deatil/view.dart
+++ b/lib/pages/dynamics/deatil/view.dart
@@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_reply.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/models/common/reply_type.dart';
+import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/pages/dynamics/deatil/index.dart';
import 'package:pilipala/pages/dynamics/widgets/author_panel.dart';
import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart';
@@ -35,39 +36,17 @@ class _DynamicDetailPageState extends State
bool _visibleTitle = false;
String? action;
// 回复类型
- late int type;
+ late int replyType;
bool _isFabVisible = true;
+ int oid = 0;
+ int? opusId;
+ bool isOpusId = false;
@override
void initState() {
super.initState();
- int oid = 0;
// floor 1原创 2转发
- if (Get.arguments['floor'] == 1) {
- oid = int.parse(Get.arguments['item'].basic!['comment_id_str']);
- print(oid);
- } else {
- try {
- String type = Get.arguments['item'].modules.moduleDynamic.major.type;
-
- /// TODO
- if (type == 'MAJOR_TYPE_OPUS') {
- } else {
- oid = Get.arguments['item'].modules.moduleDynamic.major.draw.id;
- }
- } catch (_) {}
- }
- int commentType = 11;
- try {
- commentType = Get.arguments['item'].basic!['comment_type'];
- } catch (_) {}
- type = (commentType == 0) ? 11 : commentType;
-
- action =
- Get.arguments.containsKey('action') ? Get.arguments['action'] : null;
- _dynamicDetailController =
- Get.put(DynamicDetailController(oid, type), tag: oid.toString());
- _futureBuilderFuture = _dynamicDetailController.queryReplyList();
+ init();
titleStreamC = StreamController();
if (action == 'comment') {
_visibleTitle = true;
@@ -83,6 +62,49 @@ class _DynamicDetailPageState extends State
scrollListener();
}
+ // 页面初始化
+ void init() async {
+ Map args = Get.arguments;
+ // 楼层
+ int floor = args['floor'];
+ // 从action栏点击进入
+ action = args.containsKey('action') ? args['action'] : null;
+ // 评论类型
+ int commentType = args['item'].basic!['comment_type'] ?? 11;
+ replyType = (commentType == 0) ? 11 : commentType;
+
+ if (floor == 1) {
+ oid = int.parse(args['item'].basic!['comment_id_str']);
+ } else {
+ try {
+ ModuleDynamicModel moduleDynamic = args['item'].modules.moduleDynamic;
+ String majorType = moduleDynamic.major!.type!;
+
+ if (majorType == 'MAJOR_TYPE_OPUS') {
+ // 转发的动态
+ String jumpUrl = moduleDynamic.major!.opus!.jumpUrl!;
+ opusId = int.parse(jumpUrl.split('/').last);
+ if (opusId != null) {
+ isOpusId = true;
+ _dynamicDetailController = Get.put(
+ DynamicDetailController(oid, replyType),
+ tag: opusId.toString());
+ await _dynamicDetailController.reqHtmlByOpusId(opusId!);
+ setState(() {});
+ }
+ } else {
+ oid = moduleDynamic.major!.draw!.id!;
+ }
+ } catch (_) {}
+ }
+ if (!isOpusId) {
+ _dynamicDetailController =
+ Get.put(DynamicDetailController(oid, replyType), tag: oid.toString());
+ }
+ _futureBuilderFuture = _dynamicDetailController.queryReplyList();
+ }
+
+ // 查看二级评论
void replyReply(replyItem) {
int oid = replyItem.oid;
int rpid = replyItem.rpid!;
@@ -100,13 +122,14 @@ class _DynamicDetailPageState extends State
oid: oid,
rpid: rpid,
source: 'dynamic',
- replyType: ReplyType.values[type],
+ replyType: ReplyType.values[replyType],
firstFloor: replyItem,
),
),
);
}
+ // 滑动事件监听
void scrollListener() {
scrollController = _dynamicDetailController.scrollController;
scrollController.addListener(
@@ -307,7 +330,8 @@ class _DynamicDetailPageState extends State
replyLevel: '1',
replyReply: (replyItem) =>
replyReply(replyItem),
- replyType: ReplyType.values[type],
+ replyType:
+ ReplyType.values[replyType],
addReply: (replyItem) {
_dynamicDetailController
.replyList[index].replies!
@@ -365,7 +389,7 @@ class _DynamicDetailPageState extends State
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
- replyType: ReplyType.values[type],
+ replyType: ReplyType.values[replyType],
);
},
).then(
diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart
index b6ea5eb9..c21516e5 100644
--- a/lib/pages/dynamics/widgets/author_panel.dart
+++ b/lib/pages/dynamics/widgets/author_panel.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
+import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/utils/feed_back.dart';
@@ -44,15 +45,27 @@ class AuthorPanel extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(
- item.modules.moduleAuthor.name,
- style: TextStyle(
- color: item.modules.moduleAuthor!.vip != null &&
- item.modules.moduleAuthor!.vip['status'] > 0
- ? const Color.fromARGB(255, 251, 100, 163)
- : Theme.of(context).colorScheme.onBackground,
- fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
- ),
+ Row(
+ children: [
+ Text(
+ item.modules.moduleAuthor.name,
+ style: TextStyle(
+ color: item.modules.moduleAuthor!.vip != null &&
+ item.modules.moduleAuthor!.vip['status'] > 0
+ ? const Color.fromARGB(255, 251, 100, 163)
+ : Theme.of(context).colorScheme.onBackground,
+ fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
+ ),
+ ),
+ if (item.modules.moduleTag != null) ...[
+ const SizedBox(width: 6),
+ PBadge(
+ bottom: 10,
+ right: 10,
+ text: item.modules.moduleTag['text'],
+ )
+ ]
+ ],
),
DefaultTextStyle.merge(
style: TextStyle(