fix:切换播放问题

This commit is contained in:
zengyi 2025-09-24 14:51:32 +08:00
parent ab042840b9
commit def8b49505
2 changed files with 180 additions and 172 deletions

View File

@ -1,5 +1,6 @@
import 'package:easy_refresh/easy_refresh.dart'; import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_kinetra/kt_pages/kt_main_page/view.dart';
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart'; import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -28,6 +29,7 @@ class _KtExplorePageState extends State<KtExplorePage>
super.build(context); super.build(context);
return GetBuilder<KtExploreLogic>( return GetBuilder<KtExploreLogic>(
builder: (ctrl) { builder: (ctrl) {
if(Get.find<KtMainLogic>().curIndex != 1) return Container();
if (state.loadStatus == KtLoadStatusType.loadNoData || if (state.loadStatus == KtLoadStatusType.loadNoData ||
state.loadStatus == KtLoadStatusType.loadFailed) { state.loadStatus == KtLoadStatusType.loadFailed) {
return KtStatusWidget( return KtStatusWidget(

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_kinetra/kt_pages/kt_actor/kt_actor_page.dart'; import 'package:flutter_kinetra/kt_pages/kt_actor/kt_actor_page.dart';
import 'package:flutter_kinetra/kt_pages/kt_explore/logic.dart';
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart'; import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -110,8 +111,13 @@ class _KtMainPageState extends State<KtMainPage>
_currentIndex = index; _currentIndex = index;
logic.curIndex = index; logic.curIndex = index;
_controller.jumpToPage(index); _controller.jumpToPage(index);
if (index == 3) {
final myListLogic = Get.put(MyListLogic()); final myListLogic = Get.put(MyListLogic());
myListLogic.initData(); myListLogic.initData();
} else if (index == 1) {
final exploreLogic = Get.put(KtExploreLogic());
exploreLogic.update();
}
}, },
items: [ items: [
..._tabsTitle.map( ..._tabsTitle.map(
@ -139,7 +145,7 @@ class _KtMainPageState extends State<KtMainPage>
], ],
), ),
); );
} },
), ),
); );
} }
@ -171,174 +177,174 @@ class _KtMainPageState extends State<KtMainPage>
super.dispose(); super.dispose();
} }
// @override // @override
// void didChangeAppLifecycleState(AppLifecycleState state) { // void didChangeAppLifecycleState(AppLifecycleState state) {
// super.didChangeAppLifecycleState(state); // super.didChangeAppLifecycleState(state);
// if (state == AppLifecycleState.paused) { // if (state == AppLifecycleState.paused) {
// _cycleLifeTime = DateTime.now(); // _cycleLifeTime = DateTime.now();
// } else if (state == AppLifecycleState.resumed) { // } else if (state == AppLifecycleState.resumed) {
// AppBadgePlus.updateBadge(0); // AppBadgePlus.updateBadge(0);
// final now = DateTime.now(); // final now = DateTime.now();
// final duration = now.difference(_cycleLifeTime ?? now); // final duration = now.difference(_cycleLifeTime ?? now);
// if ((duration.inMilliseconds > 3 || _isAndroidTwicePermission) && _pageOpen) { // if ((duration.inMilliseconds > 3 || _isAndroidTwicePermission) && _pageOpen) {
// Future.delayed(const Duration(milliseconds: 1000)).then((_) { // Future.delayed(const Duration(milliseconds: 1000)).then((_) {
// if (mounted) _checkDeeplink(); // if (mounted) _checkDeeplink();
// }); // });
// } // }
// _cycleLifeTime = null; // _cycleLifeTime = null;
// } // }
// } // }
// //
// void _checkDeeplink() { // void _checkDeeplink() {
// EasyThrottle.throttle('check-deeplink', Duration(seconds: 2), () async { // EasyThrottle.throttle('check-deeplink', Duration(seconds: 2), () async {
// try { // try {
// // deepling链接 // // deepling链接
// // final adjustProvider = context.read<AdjustProvider>(); // // final adjustProvider = context.read<AdjustProvider>();
// final deepLink = AdjustService().deeplink ?? ''; // final deepLink = AdjustService().deeplink ?? '';
// debugPrint('[CheckDeeplink] DEEPLINK链接: $deepLink'); // debugPrint('[CheckDeeplink] DEEPLINK链接: $deepLink');
// // 使使 // // 使使
// String useString = ''; // String useString = '';
// String useStr = ''; // String useStr = '';
// //使 // //使
// if (deepLink != '') { // if (deepLink != '') {
// useString = deepLink; // useString = deepLink;
// useStr = deepLink; // useStr = deepLink;
// // deeplink // // deeplink
// AdjustService().clearDeeplink(); // AdjustService().clearDeeplink();
// debugPrint('----清理deeplink:${AdjustService().deeplink}'); // debugPrint('----清理deeplink:${AdjustService().deeplink}');
// } else { // } else {
// // // //
// final clipboardData = await Clipboard.getData(Clipboard.kTextPlain); // final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
// final clipboardString = clipboardData?.text ?? ''; // final clipboardString = clipboardData?.text ?? '';
// debugPrint('[CheckDeeplink] 剪贴板原始链接: $clipboardString'); // debugPrint('[CheckDeeplink] 剪贴板原始链接: $clipboardString');
// // // //
// final clipboardStr = // final clipboardStr =
// clipboardString != '' && // clipboardString != '' &&
// clipboardString.startsWith(Apis.W2A_PREFIX) && // clipboardString.startsWith(Apis.W2A_PREFIX) &&
// clipboardString.contains(Apis.W2A_NAME) // clipboardString.contains(Apis.W2A_NAME)
// ? clipboardString.substring(Apis.W2A_PREFIX.length).trim() // ? clipboardString.substring(Apis.W2A_PREFIX.length).trim()
// : ''; // : '';
// debugPrint('[CheckDeeplink] 剪贴板处理链接: $clipboardStr'); // debugPrint('[CheckDeeplink] 剪贴板处理链接: $clipboardStr');
// useString = clipboardString; // useString = clipboardString;
// useStr = clipboardStr; // useStr = clipboardStr;
// } // }
// //
// // 使 // // 使
// if (useStr != '') { // if (useStr != '') {
// final uri = Uri.tryParse(useStr); // final uri = Uri.tryParse(useStr);
// Map<String, dynamic> params = uri!.queryParameters; // Map<String, dynamic> params = uri!.queryParameters;
// // params.forEach((k, v) { // // params.forEach((k, v) {
// // debugPrint('----key:$k value:$v'); // // debugPrint('----key:$k value:$v');
// // }); // // });
// //
// final shortPlayId = params['short_play_id']; // final shortPlayId = params['short_play_id'];
// final videoId = params['video_id'] ?? 0; // final videoId = params['video_id'] ?? 0;
// if (shortPlayId?.isEmpty ?? false) { // if (shortPlayId?.isEmpty ?? false) {
// debugPrint('[CheckDeeplink] 链接中没有参数'); // debugPrint('[CheckDeeplink] 链接中没有参数');
// return; // return;
// } // }
// // w2a // // w2a
// HttpClient().request(Apis.uploadW2a, data: {"data": useString}); // HttpClient().request(Apis.uploadW2a, data: {"data": useString});
// debugPrint('[CheckDeeplink] 跳转链接: $useStr'); // debugPrint('[CheckDeeplink] 跳转链接: $useStr');
// debugPrint('[CheckDeeplink] 上报链接: $useString'); // debugPrint('[CheckDeeplink] 上报链接: $useString');
// debugPrint('---current route:${Get.currentRoute}'); // debugPrint('---current route:${Get.currentRoute}');
// AdjustService().clearDeeplink(); // AdjustService().clearDeeplink();
// // // //
// await Clipboard.setData(const ClipboardData(text: '')); // await Clipboard.setData(const ClipboardData(text: ''));
// if (Get.currentRoute == AppRoutes.shortVideo) { // if (Get.currentRoute == AppRoutes.shortVideo) {
// // Get.offAndToNamed( // // Get.offAndToNamed(
// // AppRoutes.shortVideo, // // AppRoutes.shortVideo,
// // arguments: {'shortPlayId': int.parse(shortPlayId), "videoId": int.parse(videoId)}, // // arguments: {'shortPlayId': int.parse(shortPlayId), "videoId": int.parse(videoId)},
// // ); // // );
// final logic = Get.put(ShortVideoLogic()); // final logic = Get.put(ShortVideoLogic());
// logic.state.shortPlayId = int.parse(shortPlayId); // logic.state.shortPlayId = int.parse(shortPlayId);
// logic.state.videoId = int.parse(videoId); // logic.state.videoId = int.parse(videoId);
// logic.initData(); // logic.initData();
// } else { // } else {
// Get.toNamed( // Get.toNamed(
// AppRoutes.shortVideo, // AppRoutes.shortVideo,
// arguments: {'shortPlayId': int.parse(shortPlayId.toString()), "videoId": int.parse(videoId.toString())}, // arguments: {'shortPlayId': int.parse(shortPlayId.toString()), "videoId": int.parse(videoId.toString())},
// ); // );
// } // }
// } // }
// } catch (e) { // } catch (e) {
// debugPrint('[AdjustManager] 读取剪贴板异常: $e'); // debugPrint('[AdjustManager] 读取剪贴板异常: $e');
// } // }
// }); // });
// } // }
// //
// _initFirebase() async { // _initFirebase() async {
// try { // try {
// await Firebase.initializeApp(); // await Firebase.initializeApp();
// } catch (e) { // } catch (e) {
// debugPrint("----initFirebase err: $e"); // debugPrint("----initFirebase err: $e");
// } // }
// if (Platform.isIOS) { // if (Platform.isIOS) {
// await FirebaseIOS().initialize(); // await FirebaseIOS().initialize();
// } else if (Platform.isAndroid) { // } else if (Platform.isAndroid) {
// await FirebaseAndroid().initialize(); // await FirebaseAndroid().initialize();
// await FirebaseAndroid().initializeNotifications(); // await FirebaseAndroid().initializeNotifications();
// } // }
// // // //
// if (Platform.isIOS) { // if (Platform.isIOS) {
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { // WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
// // // //
// RemoteMessage? remoteMessage = await FirebaseMessaging.instance.getInitialMessage(); // RemoteMessage? remoteMessage = await FirebaseMessaging.instance.getInitialMessage();
// debugPrint("杀死app启动通知:$remoteMessage"); // debugPrint("杀死app启动通知:$remoteMessage");
// if (remoteMessage != null) { // if (remoteMessage != null) {
// final msgData = remoteMessage.data as Map; // final msgData = remoteMessage.data as Map;
// final msgNotification = remoteMessage.notification; // final msgNotification = remoteMessage.notification;
// final String? msgId = msgData['msg_id']; // final String? msgId = msgData['msg_id'];
// final String title = msgNotification?.title ?? ""; // final String title = msgNotification?.title ?? "";
// if (msgId != null) { // if (msgId != null) {
// HttpClient().request(Apis.sendMessageReport, data: {"message_id": int.parse(msgId), "title": title}); // HttpClient().request(Apis.sendMessageReport, data: {"message_id": int.parse(msgId), "title": title});
// } // }
// FirebaseCommon().onFirebaseRoute(msgData); // FirebaseCommon().onFirebaseRoute(msgData);
// } // }
// }); // });
// } // }
// } // }
// //
// // // //
// Future<void> _checkNotificationPermission() async { // Future<void> _checkNotificationPermission() async {
// final permissionStatus = await Permission.notification.status; // final permissionStatus = await Permission.notification.status;
// if (permissionStatus.isDenied) { // if (permissionStatus.isDenied) {
// if (Platform.isAndroid) { // if (Platform.isAndroid) {
// //,w2a链接 // //,w2a链接
// _isAndroidTwicePermission = true; // _isAndroidTwicePermission = true;
// } // }
// // // //
// await Permission.notification.request(); // await Permission.notification.request();
// } else if (permissionStatus.isPermanentlyDenied) { // } else if (permissionStatus.isPermanentlyDenied) {
// int now = DateTime.now().millisecondsSinceEpoch; // int now = DateTime.now().millisecondsSinceEpoch;
// int lastRequestTime = SpUtils().getInt(SpKeys.notiPermissionTime) ?? now; // int lastRequestTime = SpUtils().getInt(SpKeys.notiPermissionTime) ?? now;
// int hours = DateTime.now().difference(DateTime.fromMillisecondsSinceEpoch(lastRequestTime)).inHours; // int hours = DateTime.now().difference(DateTime.fromMillisecondsSinceEpoch(lastRequestTime)).inHours;
// if (hours < 24) return; // if (hours < 24) return;
// SpUtils().setInt(SpKeys.notiPermissionTime, now); // SpUtils().setInt(SpKeys.notiPermissionTime, now);
// // // //
// Get.dialog( // Get.dialog(
// CommonDialog( // CommonDialog(
// topIconWidget: Positioned( // topIconWidget: Positioned(
// left: -35.w, // left: -35.w,
// top: 0.w, // top: 0.w,
// child: Image.asset('ic_dialog_subscribe.png'.icon, width: 140.w, height: 100.w), // child: Image.asset('ic_dialog_subscribe.png'.icon, width: 140.w, height: 100.w),
// ), // ),
// title: 'Turn on Notifications?', // title: 'Turn on Notifications?',
// subTitle: 'Get alerts for new episodes and exclusive offers.', // subTitle: 'Get alerts for new episodes and exclusive offers.',
// hasLeftBtn: false, // hasLeftBtn: false,
// rightBtnText: 'Allow', // rightBtnText: 'Allow',
// rightBtnFunc: () => openAppSettings(), // rightBtnFunc: () => openAppSettings(),
// ), // ),
// ); // );
// } // }
// } // }
// //
// _restore() async { // _restore() async {
// await Get.put(MineLogic()).getUserInfo(); // await Get.put(MineLogic()).getUserInfo();
// EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false)); // EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false));
// } // }
} }
class KtMainLogic extends GetxController{ class KtMainLogic extends GetxController {
int curIndex = 0; int curIndex = 0;
} }