opt: intro action

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-06 08:55:41 +08:00
parent 39716cc1d4
commit 51bf59e329
2 changed files with 21 additions and 16 deletions

View File

@@ -37,7 +37,7 @@ class VideoIntroController extends GetxController
bool preRender = false; bool preRender = false;
// 视频详情 上个页面传入 // 视频详情 上个页面传入
Map? videoItem = {}; Map videoItem = {};
// 请求状态 // 请求状态
RxBool isLoading = false.obs; RxBool isLoading = false.obs;
@@ -81,6 +81,8 @@ class VideoIntroController extends GetxController
ExpandableController? expandableCtr; ExpandableController? expandableCtr;
late final showArgueMsg = GStorage.showArgueMsg; late final showArgueMsg = GStorage.showArgueMsg;
late final enableAi =
GStorage.setting.get(SettingBoxKey.enableAi, defaultValue: false);
@override @override
void onInit() { void onInit() {
@@ -99,23 +101,23 @@ class VideoIntroController extends GetxController
var keys = Get.arguments.keys.toList(); var keys = Get.arguments.keys.toList();
try { try {
if (args.pic != null && args.pic != '') { if (args.pic != null && args.pic != '') {
videoItem!['pic'] = args.pic; videoItem['pic'] = args.pic;
} else if (args.cover != null && args.cover != '') { } else if (args.cover != null && args.cover != '') {
videoItem!['pic'] = args.cover; videoItem['pic'] = args.cover;
} }
} catch (_) {} } catch (_) {}
if (args.title is String) { if (args.title is String) {
videoItem!['title'] = args.title; videoItem['title'] = args.title;
} else { } else {
String str = ''; String str = '';
for (Map map in args.title) { for (Map map in args.title) {
str += map['text']; str += map['text'];
} }
videoItem!['title'] = str; videoItem['title'] = str;
} }
videoItem!['stat'] = keys.contains('stat') ? args.stat : null; videoItem['stat'] = keys.contains('stat') ? args.stat : null;
videoItem!['pubdate'] = keys.contains('pubdate') ? args.pubdate : null; videoItem['pubdate'] = keys.contains('pubdate') ? args.pubdate : null;
videoItem!['owner'] = keys.contains('owner') ? args.owner : null; videoItem['owner'] = keys.contains('owner') ? args.owner : null;
} }
} }
userLogin = userInfo != null; userLogin = userInfo != null;
@@ -142,7 +144,7 @@ class VideoIntroController extends GetxController
result['data']?.isPageReversed = videoDetail.value.isPageReversed; result['data']?.isPageReversed = videoDetail.value.isPageReversed;
} }
videoDetail.value = result['data']; videoDetail.value = result['data'];
videoItem!['staff'] = result['data'].staff; videoItem['staff'] = result['data'].staff;
try { try {
final videoDetailController = final videoDetailController =
Get.find<VideoDetailController>(tag: heroTag); Get.find<VideoDetailController>(tag: heroTag);
@@ -258,6 +260,10 @@ class VideoIntroController extends GetxController
SmartDialog.showToast('账号未登录'); SmartDialog.showToast('账号未登录');
return; return;
} }
if (videoDetail.value.stat?.like == null) {
// not init
return;
}
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value); var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
if (result['status']) { if (result['status']) {
// hasLike.value = result["data"] == 1 ? true : false; // hasLike.value = result["data"] == 1 ? true : false;
@@ -301,6 +307,10 @@ class VideoIntroController extends GetxController
} }
void coinVideo(int coin) async { void coinVideo(int coin) async {
if (videoDetail.value.stat?.coin == null) {
// not init
return;
}
var res = await VideoHttp.coinVideo(bvid: bvid, multiply: coin); var res = await VideoHttp.coinVideo(bvid: bvid, multiply: coin);
if (res['status']) { if (res['status']) {
SmartDialog.showToast('投币成功'); SmartDialog.showToast('投币成功');

View File

@@ -124,8 +124,8 @@ class VideoInfo extends StatefulWidget {
class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin { class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
late final VideoDetailController videoDetailCtr; late final VideoDetailController videoDetailCtr;
late final Map<dynamic, dynamic> videoItem;
Map get videoItem => videoIntroController.videoItem;
VideoIntroController get videoIntroController => widget.videoIntroController; VideoIntroController get videoIntroController => widget.videoIntroController;
VideoDetailData get videoDetail => VideoDetailData get videoDetail =>
widget.videoIntroController.videoDetail.value; widget.videoIntroController.videoDetail.value;
@@ -133,7 +133,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
late final _coinKey = GlobalKey<ActionItemState>(); late final _coinKey = GlobalKey<ActionItemState>();
late final _favKey = GlobalKey<ActionItemState>(); late final _favKey = GlobalKey<ActionItemState>();
late bool enableAi;
bool isProcessing = false; bool isProcessing = false;
late final _horizontalMemberPage = GStorage.horizontalMemberPage; late final _horizontalMemberPage = GStorage.horizontalMemberPage;
@@ -150,10 +149,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
void initState() { void initState() {
super.initState(); super.initState();
videoDetailCtr = Get.find<VideoDetailController>(tag: widget.heroTag); videoDetailCtr = Get.find<VideoDetailController>(tag: widget.heroTag);
videoItem = videoIntroController.videoItem!;
enableAi =
GStorage.setting.get(SettingBoxKey.enableAi, defaultValue: false);
if (videoIntroController.expandableCtr == null) { if (videoIntroController.expandableCtr == null) {
bool alwaysExapndIntroPanel = GStorage.alwaysExapndIntroPanel; bool alwaysExapndIntroPanel = GStorage.alwaysExapndIntroPanel;
@@ -547,7 +542,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
], ],
), ),
), ),
if (enableAi) if (videoIntroController.enableAi)
Positioned( Positioned(
right: 10, right: 10,
top: 0, top: 0,