From afcc5a9a02cb15f9fd7d905a48edc05e2d3b5e68 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 18 Sep 2023 23:44:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E4=B8=93=E6=A0=8F?= =?UTF-8?q?=E3=80=81=E7=9B=B4=E6=92=AD=E7=9A=84=E5=8E=86=E5=8F=B2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/user.dart | 2 +- lib/pages/history/controller.dart | 14 ++++-- lib/pages/history/widgets/item.dart | 67 +++++++++++++++-------------- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/lib/http/user.dart b/lib/http/user.dart index b27cfde1..705fbec3 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -238,7 +238,7 @@ class UserHttp { var res = await Request().post( Api.delHistory, queryParameters: { - 'kid': 'archive_$kid', + 'kid': kid, 'jsonp': 'jsonp', 'csrf': await Request.getCsrf(), }, diff --git a/lib/pages/history/controller.dart b/lib/pages/history/controller.dart index d6475d32..2152c161 100644 --- a/lib/pages/history/controller.dart +++ b/lib/pages/history/controller.dart @@ -123,8 +123,15 @@ class HistoryController extends GetxController { } // 删除某条历史记录 - Future delHistory(kid) async { - var res = await UserHttp.delHistory(kid); + Future delHistory(kid, business) async { + String resKid = 'archive_$kid'; + if (business == 'live') { + resKid = 'live_$kid'; + } else if (business.contains('article')) { + resKid = 'article_$kid'; + } + + var res = await UserHttp.delHistory(resKid); if (res['status']) { historyList.removeWhere((e) => e.kid == kid); SmartDialog.showToast(res['msg']); @@ -136,7 +143,8 @@ class HistoryController extends GetxController { List result = historyList.where((e) => e.progress == -1).toList(); for (HisListItem i in result) { - await UserHttp.delHistory(i.kid); + String resKid = 'archive_${i.kid}'; + await UserHttp.delHistory(resKid); historyList.removeWhere((e) => e.kid == i.kid); } SmartDialog.showToast('操作完成'); diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 3500febe..81c100a7 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -247,26 +247,26 @@ class VideoContent extends StatelessWidget { Theme.of(context).textTheme.labelMedium!.fontSize, color: Theme.of(context).colorScheme.outline), ), - if (videoItem.badge != '番剧' && - !videoItem.tagName.contains('动画') && - videoItem.history.business != 'live' && - !videoItem.history.business.contains('article')) - SizedBox( - width: 24, - height: 24, - child: PopupMenuButton( - padding: EdgeInsets.zero, - tooltip: '功能菜单', - icon: Icon( - Icons.more_vert_outlined, - color: Theme.of(context).colorScheme.outline, - size: 14, - ), - position: PopupMenuPosition.under, - // constraints: const BoxConstraints(maxHeight: 35), - onSelected: (String type) {}, - itemBuilder: (BuildContext context) => - >[ + SizedBox( + width: 24, + height: 24, + child: PopupMenuButton( + padding: EdgeInsets.zero, + tooltip: '功能菜单', + icon: Icon( + Icons.more_vert_outlined, + color: Theme.of(context).colorScheme.outline, + size: 14, + ), + position: PopupMenuPosition.under, + // constraints: const BoxConstraints(maxHeight: 35), + onSelected: (String type) {}, + itemBuilder: (BuildContext context) => + >[ + if (videoItem.badge != '番剧' && + !videoItem.tagName.contains('动画') && + videoItem.history.business != 'live' && + !videoItem.history.business.contains('article')) PopupMenuItem( onTap: () async { var res = await UserHttp.toViewLater( @@ -283,21 +283,22 @@ class VideoContent extends StatelessWidget { ], ), ), - PopupMenuItem( - onTap: () => ctr!.delHistory(videoItem.kid), - value: 'pause', - height: 35, - child: const Row( - children: [ - Icon(Icons.close_outlined, size: 16), - SizedBox(width: 6), - Text('删除记录', style: TextStyle(fontSize: 13)) - ], - ), + PopupMenuItem( + onTap: () => ctr!.delHistory( + videoItem.kid, videoItem.history.business), + value: 'pause', + height: 35, + child: const Row( + children: [ + Icon(Icons.close_outlined, size: 16), + SizedBox(width: 6), + Text('删除记录', style: TextStyle(fontSize: 13)) + ], ), - ], - ), + ), + ], ), + ), ], ), ],