opt: 推荐视频拉黑逻辑

This commit is contained in:
guozhigq
2024-05-20 23:45:38 +08:00
parent 7922806d21
commit 38bddb236a
4 changed files with 46 additions and 9 deletions

View File

@ -20,11 +20,13 @@ import 'network_img_layer.dart';
class VideoCardV extends StatelessWidget { class VideoCardV extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
final int crossAxisCount; final int crossAxisCount;
final Function? blockUserCb;
const VideoCardV({ const VideoCardV({
Key? key, Key? key,
required this.videoItem, required this.videoItem,
required this.crossAxisCount, required this.crossAxisCount,
this.blockUserCb,
}) : super(key: key); }) : super(key: key);
bool isStringNumeric(String str) { bool isStringNumeric(String str) {
@ -157,7 +159,11 @@ class VideoCardV extends StatelessWidget {
); );
}), }),
), ),
VideoContent(videoItem: videoItem, crossAxisCount: crossAxisCount) VideoContent(
videoItem: videoItem,
crossAxisCount: crossAxisCount,
blockUserCb: blockUserCb,
)
], ],
), ),
); );
@ -167,9 +173,14 @@ class VideoCardV extends StatelessWidget {
class VideoContent extends StatelessWidget { class VideoContent extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
final int crossAxisCount; final int crossAxisCount;
const VideoContent( final Function? blockUserCb;
{Key? key, required this.videoItem, required this.crossAxisCount})
: super(key: key); const VideoContent({
Key? key,
required this.videoItem,
required this.crossAxisCount,
this.blockUserCb,
}) : super(key: key);
Widget _buildBadge(String text, String type, [double fs = 12]) { Widget _buildBadge(String text, String type, [double fs = 12]) {
return PBadge( return PBadge(
@ -241,7 +252,10 @@ class VideoContent extends StatelessWidget {
useRootNavigator: true, useRootNavigator: true,
isScrollControlled: true, isScrollControlled: true,
builder: (context) { builder: (context) {
return MorePanel(videoItem: videoItem); return MorePanel(
videoItem: videoItem,
blockUserCb: blockUserCb,
);
}, },
); );
}, },
@ -297,11 +311,17 @@ class VideoStat extends StatelessWidget {
class MorePanel extends StatelessWidget { class MorePanel extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
const MorePanel({super.key, required this.videoItem}); final Function? blockUserCb;
const MorePanel({
super.key,
required this.videoItem,
this.blockUserCb,
});
Future<dynamic> menuActionHandler(String type) async { Future<dynamic> menuActionHandler(String type) async {
switch (type) { switch (type) {
case 'block': case 'block':
Get.back();
blockUser(); blockUser();
break; break;
case 'watchLater': case 'watchLater':
@ -338,7 +358,10 @@ class MorePanel extends StatelessWidget {
reSrc: 11, reSrc: 11,
); );
SmartDialog.dismiss(); SmartDialog.dismiss();
SmartDialog.showToast(res['msg'] ?? '成功'); if (res['status']) {
blockUserCb?.call(videoItem.owner.mid);
}
SmartDialog.showToast(res['msg']);
}, },
child: const Text('确认'), child: const Text('确认'),
) )

View File

@ -387,9 +387,15 @@ class VideoHttp {
'csrf': await Request.getCsrf(), 'csrf': await Request.getCsrf(),
}); });
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']}; if (act == 5) {
List<int> blackMidsList =
setting.get(SettingBoxKey.blackMidsList, defaultValue: [-1]);
blackMidsList.add(mid);
setting.put(SettingBoxKey.blackMidsList, blackMidsList);
}
return {'status': true, 'data': res.data['data'], 'msg': '成功'};
} else { } else {
return {'status': false, 'data': []}; return {'status': false, 'data': [], 'msg': res.data['message']};
} }
} }

View File

@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/http/video.dart'; import 'package:pilipala/http/video.dart';
@ -106,4 +107,10 @@ class RcmdController extends GetxController {
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
} }
} }
void blockUserCb(mid) {
videoList.removeWhere((e) => e.owner.mid == mid);
videoList.refresh();
SmartDialog.showToast('已移除相关视频');
}
} }

View File

@ -146,6 +146,7 @@ class _RcmdPageState extends State<RcmdPage>
? VideoCardV( ? VideoCardV(
videoItem: videoList[index], videoItem: videoList[index],
crossAxisCount: crossAxisCount, crossAxisCount: crossAxisCount,
blockUserCb: (mid) => ctr.blockUserCb(mid),
) )
: const VideoCardVSkeleton(); : const VideoCardVSkeleton();
}, },