mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-09 02:30:14 +08:00
refa fav video
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_tag/data.dart';
|
||||
import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -32,6 +35,21 @@ abstract class CommonIntroController extends GetxController {
|
||||
Future<void> actionFavVideo({String type = 'choose'});
|
||||
|
||||
late final enableQuickFav = Pref.enableQuickFav;
|
||||
late int? quickFavId = Pref.quickFavId;
|
||||
|
||||
FavFolderInfo get favFolderInfo {
|
||||
final list = favFolderData.value.list!;
|
||||
if (quickFavId != null) {
|
||||
final folderInfo = list.firstWhereOrNull((e) => e.id == quickFavId);
|
||||
if (folderInfo != null) {
|
||||
return folderInfo;
|
||||
} else {
|
||||
quickFavId = null;
|
||||
GStorage.setting.delete(SettingBoxKey.quickFavId);
|
||||
}
|
||||
}
|
||||
return list.first;
|
||||
}
|
||||
|
||||
// 收藏
|
||||
void showFavBottomSheet(BuildContext context, {type = 'tap'}) {
|
||||
|
||||
@@ -63,8 +63,8 @@ class FavDetailController
|
||||
}
|
||||
|
||||
Future<void> onCancelFav(int index, int id, int type) async {
|
||||
var result = await FavHttp.delFav(
|
||||
ids: ['$id:$type'],
|
||||
var result = await FavHttp.favVideo(
|
||||
resources: '$id:$type',
|
||||
delIds: mediaId.toString(),
|
||||
);
|
||||
if (result['status']) {
|
||||
@@ -112,8 +112,10 @@ class FavDetailController
|
||||
List<FavDetailItemModel> list = loadingState.value.data!
|
||||
.where((e) => e.checked == true)
|
||||
.toList();
|
||||
var result = await FavHttp.delFav(
|
||||
ids: list.map((item) => '${item.id}:${item.type}').toList(),
|
||||
var result = await FavHttp.favVideo(
|
||||
resources: list
|
||||
.map((item) => '${item.id}:${item.type}')
|
||||
.join(','),
|
||||
delIds: mediaId.toString(),
|
||||
);
|
||||
if (result['status']) {
|
||||
|
||||
@@ -38,10 +38,9 @@ class FavSearchController
|
||||
|
||||
Future<void> onCancelFav(int index, int id, int? type) async {
|
||||
var result = await FavHttp.favVideo(
|
||||
aid: id,
|
||||
resources: '$id:$type',
|
||||
addIds: '',
|
||||
delIds: mediaId.toString(),
|
||||
type: type,
|
||||
);
|
||||
if (result['status']) {
|
||||
loadingState
|
||||
|
||||
@@ -3,8 +3,10 @@ import 'dart:math' show pi, max;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/image/image_view.dart';
|
||||
import 'package:PiliPlus/common/widgets/pendant_avatar.dart';
|
||||
import 'package:PiliPlus/common/widgets/radio_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/grpc/reply.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/models/common/audio_normalization.dart';
|
||||
import 'package:PiliPlus/models/common/dynamic/dynamics_type.dart';
|
||||
import 'package:PiliPlus/models/common/member/tab_type.dart';
|
||||
@@ -12,6 +14,7 @@ import 'package:PiliPlus/models/common/reply/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/models/common/settings_type.dart';
|
||||
import 'package:PiliPlus/models/common/super_resolution_type.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/data.dart';
|
||||
import 'package:PiliPlus/pages/common/common_slide_page.dart';
|
||||
import 'package:PiliPlus/pages/home/controller.dart';
|
||||
import 'package:PiliPlus/pages/hot/controller.dart';
|
||||
@@ -20,7 +23,9 @@ import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/slide_dialog.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/cache_manage.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
@@ -774,9 +779,51 @@ List<SettingsModel> get extraSettings => [
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '快速收藏',
|
||||
subtitle: '点按收藏至默认,长按选择文件夹',
|
||||
subtitle: '点击设置默认收藏夹\n点按收藏至默认,长按选择文件夹',
|
||||
leading: const Icon(Icons.bookmark_add_outlined),
|
||||
setKey: SettingBoxKey.enableQuickFav,
|
||||
onTap: () async {
|
||||
if (Accounts.main.isLogin) {
|
||||
final res = await FavHttp.allFavFolders(Accounts.main.mid);
|
||||
if (res['status']) {
|
||||
final FavFolderData data = res['data'];
|
||||
final list = data.list;
|
||||
if (list.isNullOrEmpty) {
|
||||
return;
|
||||
}
|
||||
final quickFavId = Pref.quickFavId;
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
title: const Text('选择默认收藏夹'),
|
||||
contentPadding: const EdgeInsets.only(top: 5, bottom: 18),
|
||||
content: SingleChildScrollView(
|
||||
child: Builder(
|
||||
builder: (context) => Column(
|
||||
children: List.generate(list!.length, (index) {
|
||||
final item = list[index];
|
||||
return RadioWidget(
|
||||
padding: const EdgeInsets.only(left: 14),
|
||||
title: item.title,
|
||||
groupValue: quickFavId,
|
||||
value: item.id,
|
||||
onChanged: (value) {
|
||||
Get.back();
|
||||
GStorage.setting.put(SettingBoxKey.quickFavId, value);
|
||||
SmartDialog.showToast('设置成功');
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
SmartDialog.showToast('${res['msg']}');
|
||||
}
|
||||
}
|
||||
},
|
||||
defaultVal: false,
|
||||
),
|
||||
SettingsModel(
|
||||
|
||||
@@ -406,8 +406,8 @@ class VideoDetailController extends GetxController
|
||||
}
|
||||
SmartDialog.showToast(res['msg']);
|
||||
} else {
|
||||
var res = await FavHttp.delFav(
|
||||
ids: ['${item.aid}:${item.type}'],
|
||||
var res = await FavHttp.favVideo(
|
||||
resources: '${item.aid}:${item.type}',
|
||||
delIds: '${Get.arguments?['mediaId']}',
|
||||
);
|
||||
if (res['status']) {
|
||||
|
||||
@@ -130,19 +130,18 @@ class PgcIntroController extends CommonIntroController {
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
queryVideoInFolder().then((res) async {
|
||||
if (res['status']) {
|
||||
int defaultFolderId = favFolderData.value.list!.first.id;
|
||||
int favStatus = favFolderData.value.list!.first.favState!;
|
||||
var result = await FavHttp.favVideo(
|
||||
aid: epId,
|
||||
type: 24,
|
||||
addIds: favStatus == 0 ? '$defaultFolderId' : '',
|
||||
delIds: favStatus == 1 ? '$defaultFolderId' : '',
|
||||
);
|
||||
final favFolderInfo = this.favFolderInfo;
|
||||
final defaultFolderId = favFolderInfo.id;
|
||||
final isFav = favFolderInfo.favState == 1;
|
||||
var result = isFav
|
||||
? await FavHttp.unfavAll(rid: epId, type: 24)
|
||||
: await FavHttp.favVideo(
|
||||
resources: '$epId:24',
|
||||
addIds: defaultFolderId.toString(),
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
if (result['status']) {
|
||||
// 重新获取收藏状态
|
||||
await Future.delayed(const Duration(milliseconds: 255));
|
||||
await queryPgcLikeCoinFav();
|
||||
hasFav.value = !isFav;
|
||||
SmartDialog.showToast('✅ 快速收藏/取消收藏成功');
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
@@ -171,17 +170,15 @@ class PgcIntroController extends CommonIntroController {
|
||||
}
|
||||
} catch (_) {}
|
||||
var result = await FavHttp.favVideo(
|
||||
aid: epId,
|
||||
type: 24,
|
||||
resources: '$epId:24',
|
||||
addIds: addMediaIdsNew.join(','),
|
||||
delIds: delMediaIdsNew.join(','),
|
||||
);
|
||||
if (result['status']) {
|
||||
SmartDialog.showToast('操作成功');
|
||||
Get.back();
|
||||
Future.delayed(const Duration(milliseconds: 255), () {
|
||||
queryPgcLikeCoinFav();
|
||||
});
|
||||
hasFav.value =
|
||||
addMediaIdsNew.isNotEmpty || favIds?.length != delMediaIdsNew.length;
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
@@ -348,19 +348,18 @@ class VideoIntroController extends CommonIntroController with ReloadMixin {
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
queryVideoInFolder().then((res) async {
|
||||
if (res['status']) {
|
||||
final first = favFolderData.value.list!.first;
|
||||
int defaultFolderId = first.id;
|
||||
bool notInDefFolder = first.favState! == 0;
|
||||
var result = await FavHttp.favVideo(
|
||||
aid: IdUtils.bv2av(bvid),
|
||||
addIds: notInDefFolder ? '$defaultFolderId' : '',
|
||||
delIds: !notInDefFolder ? '$defaultFolderId' : '',
|
||||
);
|
||||
final favFolderInfo = this.favFolderInfo;
|
||||
final defaultFolderId = favFolderInfo.id;
|
||||
final isFav = favFolderInfo.favState == 1;
|
||||
var result = isFav
|
||||
? await FavHttp.unfavAll(rid: IdUtils.bv2av(bvid), type: 2)
|
||||
: await FavHttp.favVideo(
|
||||
resources: '${IdUtils.bv2av(bvid)}:2',
|
||||
addIds: defaultFolderId.toString(),
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
if (result['status']) {
|
||||
hasFav.value = !hasFav.value || (hasFav.value && notInDefFolder);
|
||||
// 重新获取收藏状态
|
||||
// await queryHasFavVideo();
|
||||
hasFav.value = !isFav;
|
||||
SmartDialog.showToast('✅ 快速收藏/取消收藏成功');
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
@@ -392,7 +391,7 @@ class VideoIntroController extends CommonIntroController with ReloadMixin {
|
||||
}
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
var result = await FavHttp.favVideo(
|
||||
aid: IdUtils.bv2av(bvid),
|
||||
resources: '${IdUtils.bv2av(bvid)}:2',
|
||||
addIds: addMediaIdsNew.join(','),
|
||||
delIds: delMediaIdsNew.join(','),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user