Compare commits

..

1 Commits

Author SHA1 Message Date
bc26e79bf9 feat: 取消订阅 issues #606 2024-03-09 00:22:58 +08:00
9 changed files with 101 additions and 29 deletions

View File

@ -490,6 +490,9 @@ class Api {
/// 我的订阅详情 /// 我的订阅详情
static const userSubFolderDetail = '/x/space/fav/season/list'; static const userSubFolderDetail = '/x/space/fav/season/list';
/// 取消订阅
static const userSubCancel = '/x/v3/fav/season/unfav';
/// 表情 /// 表情
static const emojiList = '/x/emote/user/panel/web'; static const emojiList = '/x/emote/user/panel/web';

View File

@ -349,4 +349,21 @@ class UserHttp {
return {'status': false, 'msg': res.data['message']}; return {'status': false, 'msg': res.data['message']};
} }
} }
// 取消订阅
static Future userSubCancel({required int seasonId}) async {
var res = await Request().post(
Api.userSubCancel,
queryParameters: {
'season_id': seasonId,
'platform': 'web',
'csrf': await Request.getCsrf(),
},
);
if (res.data['code'] == 0) {
return {'status': true, 'msg': '取消订阅成功'};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
} }

View File

@ -91,21 +91,19 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
vsync: this, vsync: this,
); );
// 监听 tabController 切换 // 监听 tabController 切换
if (enableGradientBg) { tabController.animation!.addListener(() {
tabController.animation!.addListener(() { if (tabController.indexIsChanging) {
if (tabController.indexIsChanging) { if (initialIndex.value != tabController.index) {
if (initialIndex.value != tabController.index) { initialIndex.value = tabController.index;
initialIndex.value = tabController.index;
}
} else {
final int temp = tabController.animation!.value.round();
if (initialIndex.value != temp) {
initialIndex.value = temp;
tabController.index = initialIndex.value;
}
} }
}); } else {
} final int temp = tabController.animation!.value.round();
if (initialIndex.value != temp) {
initialIndex.value = temp;
tabController.index = initialIndex.value;
}
}
});
} }
void searchDefault() async { void searchDefault() async {

View File

@ -46,4 +46,41 @@ class SubController extends GetxController {
Future onLoad() async { Future onLoad() async {
querySubFolder(type: 'onload'); querySubFolder(type: 'onload');
} }
// 取消订阅
Future<dynamic> cancelSub({required int id}) async {
showDialog(
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text('提示'),
content: const Text('确认要取消订阅吗?'),
actions: [
TextButton(
onPressed: () => Get.back(),
child: Text(
'取消',
style:
TextStyle(color: Theme.of(context).colorScheme.outline),
)),
TextButton(
onPressed: () async {
Get.back();
var res = await UserHttp.userSubCancel(seasonId: id);
if (res['status']) {
SmartDialog.showToast('取消订阅成功');
subFolderData.value.list!
.removeWhere((element) => element.id == id);
subFolderData.update((val) {});
} else {
SmartDialog.showToast(res['msg']);
}
},
child: const Text('确认'),
)
],
);
},
);
}
} }

View File

@ -57,8 +57,15 @@ class _SubPageState extends State<SubPage> {
itemCount: _subController.subFolderData.value.list!.length, itemCount: _subController.subFolderData.value.list!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return SubItem( return SubItem(
subFolderItem: subFolderItem:
_subController.subFolderData.value.list![index]); _subController.subFolderData.value.list![index],
fuc: () {
_subController.cancelSub(
id: _subController
.subFolderData.value.list![index].id!,
);
},
);
}, },
), ),
); );

View File

@ -8,7 +8,8 @@ import '../../../models/user/sub_folder.dart';
class SubItem extends StatelessWidget { class SubItem extends StatelessWidget {
final SubFolderItemData subFolderItem; final SubFolderItemData subFolderItem;
const SubItem({super.key, required this.subFolderItem}); final Function fuc;
const SubItem({super.key, required this.subFolderItem, required this.fuc});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -51,7 +52,7 @@ class SubItem extends StatelessWidget {
}, },
), ),
), ),
VideoContent(subFolderItem: subFolderItem) VideoContent(subFolderItem: subFolderItem, fuc: fuc)
], ],
), ),
); );
@ -64,7 +65,9 @@ class SubItem extends StatelessWidget {
class VideoContent extends StatelessWidget { class VideoContent extends StatelessWidget {
final SubFolderItemData subFolderItem; final SubFolderItemData subFolderItem;
const VideoContent({super.key, required this.subFolderItem}); final Function fuc;
const VideoContent(
{super.key, required this.subFolderItem, required this.fuc});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -100,6 +103,20 @@ class VideoContent extends StatelessWidget {
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
), ),
), ),
const Spacer(),
SizedBox(
height: 34,
child: TextButton(
onPressed: () => fuc(),
style: TextButton.styleFrom(
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
foregroundColor: Theme.of(context).colorScheme.outline,
backgroundColor:
Theme.of(context).colorScheme.onInverseSurface, // 设置按钮背景色
),
child: const Text('取消订阅'),
),
),
], ],
), ),
), ),

View File

@ -129,7 +129,6 @@ class VideoDetailController extends GetxController
videoDetailCtr: this, videoDetailCtr: this,
floating: floating, floating: floating,
bvid: bvid, bvid: bvid,
videoType: videoType,
); );
// CDN优化 // CDN优化
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true); enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);

View File

@ -572,7 +572,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
controller: plPlayerController, controller: plPlayerController,
videoDetailCtr: videoDetailController, videoDetailCtr: videoDetailController,
bvid: videoDetailController.bvid, bvid: videoDetailController.bvid,
videoType: videoDetailController.videoType,
), ),
danmuWidget: Obx( danmuWidget: Obx(
() => PlDanmaku( () => PlDanmaku(

View File

@ -19,7 +19,6 @@ import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/http/danmaku.dart'; import 'package:pilipala/http/danmaku.dart';
import 'package:pilipala/services/shutdown_timer_service.dart'; import 'package:pilipala/services/shutdown_timer_service.dart';
import '../../../../models/common/search_type.dart';
import '../../../../models/video_detail_res.dart'; import '../../../../models/video_detail_res.dart';
import '../introduction/index.dart'; import '../introduction/index.dart';
@ -29,14 +28,12 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
this.videoDetailCtr, this.videoDetailCtr,
this.floating, this.floating,
this.bvid, this.bvid,
this.videoType,
super.key, super.key,
}); });
final PlPlayerController? controller; final PlPlayerController? controller;
final VideoDetailController? videoDetailCtr; final VideoDetailController? videoDetailCtr;
final Floating? floating; final Floating? floating;
final String? bvid; final String? bvid;
final SearchType? videoType;
@override @override
State<HeaderControl> createState() => _HeaderControlState(); State<HeaderControl> createState() => _HeaderControlState();
@ -1110,16 +1107,14 @@ class _HeaderControlState extends State<HeaderControl> {
}, },
), ),
SizedBox(width: buttonSpace), SizedBox(width: buttonSpace),
if (showTitle && if (showTitle && isLandscape) ...[
isLandscape &&
widget.videoType == SearchType.video) ...[
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 200), constraints: BoxConstraints(maxWidth: 200),
child: Text( child: Text(
videoIntroController.videoDetail.value.title ?? '', videoIntroController.videoDetail.value.title!,
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 16, fontSize: 16,