From 108c37f0d7147330ff44ff3a72abe2f6d5925e6f Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 30 Aug 2023 09:36:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E5=8D=95=E4=B8=AA?= =?UTF-8?q?=E7=A8=8D=E5=90=8E=E5=86=8D=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/user.dart | 14 ++++++++------ lib/pages/later/controller.dart | 33 +++++++++++++++++++++++---------- lib/pages/later/view.dart | 8 +++++--- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/lib/http/user.dart b/lib/http/user.dart index 8fceea41..404502b3 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -179,14 +179,16 @@ class UserHttp { } // 移除已观看 - static Future toViewDel() async { + static Future toViewDel({int? aid}) async { + final Map params = { + 'jsonp': 'jsonp', + 'csrf': await Request.getCsrf(), + }; + + params[aid != null ? 'aid' : 'viewed'] = aid ?? true; var res = await Request().post( Api.toViewDel, - queryParameters: { - 'jsonp': 'jsonp', - 'viewed': true, - 'csrf': await Request.getCsrf(), - }, + queryParameters: params, ); if (res.data['code'] == 0) { return {'status': true, 'msg': 'yeah!成功移除'}; diff --git a/lib/pages/later/controller.dart b/lib/pages/later/controller.dart index 6de9254c..3de51901 100644 --- a/lib/pages/later/controller.dart +++ b/lib/pages/later/controller.dart @@ -23,29 +23,38 @@ class LaterController extends GetxController { return res; } - Future toViewDel() async { + Future toViewDel({int? aid}) async { SmartDialog.show( useSystem: true, animationType: SmartAnimationType.centerFade_otherSlide, builder: (BuildContext context) { return AlertDialog( title: const Text('提示'), - content: const Text('即将删除所有已观看视频,此操作不可恢复。确定是否删除?'), + content: Text( + aid != null ? '即将移除该视频,确定是否移除' : '即将删除所有已观看视频,此操作不可恢复。确定是否删除?'), actions: [ TextButton( - onPressed: () => SmartDialog.dismiss(), - child: const Text('取消')), + onPressed: () => SmartDialog.dismiss(), + child: Text( + '取消', + style: TextStyle(color: Theme.of(context).colorScheme.outline), + ), + ), TextButton( onPressed: () async { - var res = await UserHttp.toViewDel(); + var res = await UserHttp.toViewDel(aid: aid); if (res['status']) { - laterList.clear(); - queryLaterList(); + if (aid != null) { + laterList.removeWhere((e) => e.aid == aid); + } else { + laterList.clear(); + queryLaterList(); + } } SmartDialog.dismiss(); SmartDialog.showToast(res['msg']); }, - child: const Text('确认删除'), + child: Text(aid != null ? '确认移除' : '确认删除'), ) ], ); @@ -64,8 +73,12 @@ class LaterController extends GetxController { content: const Text('确定要清空你的稍后再看列表吗?'), actions: [ TextButton( - onPressed: () => SmartDialog.dismiss(), - child: const Text('取消')), + onPressed: () => SmartDialog.dismiss(), + child: Text( + '取消', + style: TextStyle(color: Theme.of(context).colorScheme.outline), + ), + ), TextButton( onPressed: () async { var res = await UserHttp.toViewClear(); diff --git a/lib/pages/later/view.dart b/lib/pages/later/view.dart index 7c04f8dc..76527ca1 100644 --- a/lib/pages/later/view.dart +++ b/lib/pages/later/view.dart @@ -80,10 +80,12 @@ class _LaterPageState extends State { ? SliverList( delegate: SliverChildBuilderDelegate((context, index) { + var videoItem = _laterController.laterList[index]; return VideoCardH( - videoItem: _laterController.laterList[index], - source: 'later', - ); + videoItem: videoItem, + source: 'later', + longPress: () => _laterController.toViewDel( + aid: videoItem.aid)); }, childCount: _laterController.laterList.length), ) : _laterController.isLoading.value