mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-16 07:06:14 +08:00
opt introctr
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/data.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:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class CommonIntroController extends GetxController {
|
||||
String bvid = Get.parameters['bvid']!;
|
||||
|
||||
// 是否点赞
|
||||
RxBool hasLike = false.obs;
|
||||
// 投币数量
|
||||
@@ -22,5 +29,36 @@ abstract class CommonIntroController extends GetxController {
|
||||
|
||||
Future queryVideoInFolder();
|
||||
|
||||
Future<void> actionFavVideo();
|
||||
Future<void> actionFavVideo({String type = 'choose'});
|
||||
|
||||
late final enableQuickFav =
|
||||
GStorage.setting.get(SettingBoxKey.enableQuickFav, defaultValue: false);
|
||||
|
||||
// 收藏
|
||||
void showFavBottomSheet(BuildContext context, {type = 'tap'}) {
|
||||
if (!accountService.isLogin.value) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
// 快速收藏 &
|
||||
// 点按 收藏至默认文件夹
|
||||
// 长按选择文件夹
|
||||
if (enableQuickFav) {
|
||||
if (type == 'tap') {
|
||||
actionFavVideo(type: 'default');
|
||||
} else {
|
||||
PageUtils.showFavBottomSheet(context: context, ctr: this);
|
||||
}
|
||||
} else if (type != 'longPress') {
|
||||
PageUtils.showFavBottomSheet(context: context, ctr: this);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> queryVideoTags() async {
|
||||
videoTags = null;
|
||||
var result = await UserHttp.videoTags(bvid: bvid);
|
||||
if (result['status']) {
|
||||
videoTags = result['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:PiliPlus/grpc/bilibili/app/viewunite/pgcanymodel.pb.dart'
|
||||
import 'package:PiliPlus/grpc/view.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/pgc_lcf.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
|
||||
@@ -21,15 +20,12 @@ import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PgcIntroController extends CommonIntroController {
|
||||
// 视频bvid
|
||||
String bvid = Get.parameters['bvid'] ?? '';
|
||||
var seasonId = Get.parameters['seasonId'] != null
|
||||
? int.tryParse(Get.parameters['seasonId']!)
|
||||
: null;
|
||||
@@ -44,9 +40,6 @@ class PgcIntroController extends CommonIntroController {
|
||||
|
||||
final PgcInfoModel pgcItem = Get.arguments['pgcItem'];
|
||||
|
||||
late final enableQuickFav =
|
||||
GStorage.setting.get(SettingBoxKey.enableQuickFav, defaultValue: false);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -61,13 +54,6 @@ class PgcIntroController extends CommonIntroController {
|
||||
queryVideoTags();
|
||||
}
|
||||
|
||||
Future<void> queryVideoTags() async {
|
||||
var result = await UserHttp.videoTags(bvid: bvid);
|
||||
if (result['status']) {
|
||||
videoTags = result['data'];
|
||||
}
|
||||
}
|
||||
|
||||
// 获取点赞/投币/收藏状态
|
||||
Future<void> queryPgcLikeCoinFav() async {
|
||||
var result = await VideoHttp.pgcLikeCoinFav(epId: epId);
|
||||
@@ -532,24 +518,4 @@ class PgcIntroController extends CommonIntroController {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 收藏
|
||||
void showFavBottomSheet(BuildContext context, {type = 'tap'}) {
|
||||
if (!accountService.isLogin.value) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
// 快速收藏 &
|
||||
// 点按 收藏至默认文件夹
|
||||
// 长按选择文件夹
|
||||
if (enableQuickFav) {
|
||||
if (type == 'tap') {
|
||||
actionFavVideo(type: 'default');
|
||||
} else {
|
||||
PageUtils.showFavBottomSheet(context: context, ctr: this);
|
||||
}
|
||||
} else if (type != 'longPress') {
|
||||
PageUtils.showFavBottomSheet(context: context, ctr: this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,6 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class VideoIntroController extends CommonIntroController {
|
||||
// 视频bvid
|
||||
late String bvid;
|
||||
|
||||
// 视频详情 上个页面传入
|
||||
Map videoItem = {};
|
||||
late final RxMap staffRelations = {}.obs;
|
||||
@@ -68,7 +65,7 @@ class VideoIntroController extends CommonIntroController {
|
||||
|
||||
// 同时观看
|
||||
bool isShowOnlineTotal = false;
|
||||
RxString total = '1'.obs;
|
||||
late final RxString total = '1'.obs;
|
||||
Timer? timer;
|
||||
String heroTag = '';
|
||||
AiConclusionResult? aiConclusionResult;
|
||||
@@ -80,8 +77,6 @@ class VideoIntroController extends CommonIntroController {
|
||||
late final showArgueMsg = GStorage.showArgueMsg;
|
||||
late final enableAi =
|
||||
GStorage.setting.get(SettingBoxKey.enableAi, defaultValue: false);
|
||||
late final enableQuickFav =
|
||||
GStorage.setting.get(SettingBoxKey.enableQuickFav, defaultValue: false);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -90,7 +85,6 @@ class VideoIntroController extends CommonIntroController {
|
||||
if (heroTag.isEmpty) {
|
||||
heroTag = Get.arguments['heroTag'];
|
||||
}
|
||||
bvid = Get.parameters['bvid']!;
|
||||
} catch (_) {}
|
||||
if (Get.arguments.isNotEmpty) {
|
||||
if (Get.arguments.containsKey('videoItem')) {
|
||||
@@ -112,9 +106,10 @@ class VideoIntroController extends CommonIntroController {
|
||||
}
|
||||
videoItem['title'] = str;
|
||||
}
|
||||
videoItem['stat'] = keys.contains('stat') ? args.stat : null;
|
||||
videoItem['pubdate'] = keys.contains('pubdate') ? args.pubdate : null;
|
||||
videoItem['owner'] = keys.contains('owner') ? args.owner : null;
|
||||
videoItem
|
||||
..['stat'] = keys.contains('stat') ? args.stat : null
|
||||
..['pubdate'] = keys.contains('pubdate') ? args.pubdate : null
|
||||
..['owner'] = keys.contains('owner') ? args.owner : null;
|
||||
}
|
||||
}
|
||||
lastPlayCid.value = int.parse(Get.parameters['cid']!);
|
||||
@@ -177,14 +172,6 @@ class VideoIntroController extends CommonIntroController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> queryVideoTags() async {
|
||||
videoTags = null;
|
||||
var result = await UserHttp.videoTags(bvid: bvid);
|
||||
if (result['status']) {
|
||||
videoTags = result['data'];
|
||||
}
|
||||
}
|
||||
|
||||
// 获取up主粉丝数
|
||||
Future<void> queryUserStat() async {
|
||||
if (videoItem['staff']?.isNotEmpty == true) {
|
||||
@@ -895,24 +882,4 @@ class VideoIntroController extends CommonIntroController {
|
||||
SmartDialog.showToast("当前视频可能暂不支持AI视频总结");
|
||||
}
|
||||
}
|
||||
|
||||
// 收藏
|
||||
void showFavBottomSheet(BuildContext context, {type = 'tap'}) {
|
||||
if (!accountService.isLogin.value) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
// 快速收藏 &
|
||||
// 点按 收藏至默认文件夹
|
||||
// 长按选择文件夹
|
||||
if (enableQuickFav) {
|
||||
if (type == 'tap') {
|
||||
actionFavVideo(type: 'default');
|
||||
} else {
|
||||
PageUtils.showFavBottomSheet(context: context, ctr: this);
|
||||
}
|
||||
} else if (type != 'longPress') {
|
||||
PageUtils.showFavBottomSheet(context: context, ctr: this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user