Compare commits

..

3 Commits

Author SHA1 Message Date
greatsage f1e8e7f530 1. 订阅卡片 - 移除 ScreenUtil,内容可见
Build Android APK / 编译 libcore.aar (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 编译 libcore (iOS/tvOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 构建 iOS (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
Build Windows / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Windows / build (push) Has been cancelled
2.  连接选项 - 移除 ScreenUtil,"国家/地区"可见
  3.  连接信息卡片 - 移除 ScreenUtil
  4.  试用卡片 - 移除 ScreenUtil
  5.  最后一天卡片 - 移除 ScreenUtil
  6.  底部面板 - 移除 ScreenUtil
  7.  购买页面 - 移除 ScreenUtil,点击订阅不再卡死

(cherry picked from commit 1b059c57f55d65a737d5713754486a9cf576b210)
2025-11-02 01:06:45 -08:00
greatsage 75c7d31da1 修复ScreenUtil 在某些安卓设备上计算异常,导致所有使用 .w 和 .h 的尺寸都变成 0 或极小值,导致界面不显示
(cherry picked from commit 73af298aebafc2e13668d645d461b99786b0c1e2)
2025-11-02 01:05:44 -08:00
greatsage 17b3f6b92d 新增日志全局开关便于调试,优化部分机型可能出现的界面错乱或不显示等问题
(cherry picked from commit 5853ba7fe4e0cbe4f04b20c86e9fd84c5557139f)
2025-11-02 01:05:43 -08:00
15 changed files with 263 additions and 133 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx4048m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xlint:-options
android.useAndroidX=true
android.enableJetifier=true
# org.gradle.java.home=/Users/mac/Library/Java/JavaVirtualMachines/ms-17.0.16/Contents/Home
+25 -6
View File
@@ -4,6 +4,7 @@ import '../utils/kr_update_util.dart';
import '../utils/kr_secure_storage.dart';
import '../utils/kr_log_util.dart';
import '../services/singbox_imp/kr_sing_box_imp.dart';
import '../utils/kr_init_log_collector.dart'; // 🔧 新增:导入日志收集器
import 'dart:async';
import 'dart:convert';
import 'dart:io';
@@ -1337,10 +1338,17 @@ class AppConfig {
KRUpdateApplication? kr_update_application;
// 🔧 新增:日志收集器实例
final _initLog = KRInitLogCollector();
Future<void> initConfig({
Future<void> Function()? onSuccess,
}) async {
_initLog.logSeparator();
_initLog.log('🌐 开始应用配置初始化(域名加载)', tag: 'Domain');
if (_isInitializing) {
_initLog.logWarning('配置初始化已在进行中,跳过重复调用', tag: 'Domain');
KRLogUtil.kr_w('配置初始化已在进行中,跳过重复调用', tag: 'AppConfig');
return;
}
@@ -1348,10 +1356,13 @@ class AppConfig {
_isInitializing = true;
try {
// 🔧 修复6:启动时优先加载上次成功的域名
_initLog.log('开始加载基础域名配置', tag: 'Domain');
await KRDomain.kr_loadBaseDomain();
_initLog.logSuccess('当前使用域名: ${KRDomain.kr_currentDomain}', tag: 'Domain');
KRLogUtil.kr_i('📍 当前使用域名: ${KRDomain.kr_currentDomain}', tag: 'AppConfig');
// 所有模式都走正常的配置请求流程
_initLog.log('开始配置请求流程(包含重试机制)', tag: 'Domain');
KRLogUtil.kr_i('🚀 开始配置初始化', tag: 'AppConfig');
await _startAutoRetry(onSuccess);
} finally {
@@ -1402,24 +1413,32 @@ class AppConfig {
return;
}
_initLog.log('发起配置请求 API (尝试 $totalAttempts/$maxTotalAttempts)', tag: 'Domain');
final result = await _kr_userApi.kr_config();
result.fold(
(error) async {
_initLog.logError('配置请求失败 (重试 $currentRetryCount/$kr_maxRetryCount)', tag: 'Domain', error: error);
KRLogUtil.kr_e('配置初始化失败: $error', tag: 'AppConfig');
currentRetryCount++;
// 计算重试延迟时间
final retryDelay = (kr_retryInterval * pow(kr_backoffFactor, currentRetryCount)).toInt();
// 尝试切换域名
await KRDomain.kr_switchToNextDomain();
// 等待后重试,至少延迟100ms避免立即重试
final actualDelay = max(retryDelay, 100);
_initLog.log('将在 ${actualDelay}ms 后重试', tag: 'Domain');
// 尝试切换域名
_initLog.log('尝试切换到下一个备用域名', tag: 'Domain');
await KRDomain.kr_switchToNextDomain();
_initLog.log('当前域名: ${KRDomain.kr_currentDomain}', tag: 'Domain');
// 等待后重试
await Future.delayed(Duration(milliseconds: actualDelay));
await executeConfigRequest();
},
(config) async {
_initLog.logSuccess('配置请求成功!', tag: 'Domain');
_initLog.log('网站ID: ${config.kr_website_id}', tag: 'Domain');
_initLog.log('官网: ${config.kr_official_website}', tag: 'Domain');
_retryTimer?.cancel();
currentRetryCount = 0;
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:kaer_with_panels/app/common/app_run_data.dart';
@@ -30,8 +31,11 @@ import 'package:kaer_with_panels/app/utils/kr_common_util.dart';
import 'package:kaer_with_panels/app/utils/kr_secure_storage.dart';
import 'package:kaer_with_panels/app/services/singbox_imp/kr_sing_box_imp.dart';
import 'package:flutter/foundation.dart';
import 'package:kaer_with_panels/app/utils/kr_init_log_collector.dart'; // 🔧 新增:导入日志收集器
class KRHomeController extends GetxController with WidgetsBindingObserver {
// 🔧 新增:日志收集器实例
final _initLog = KRInitLogCollector();
/// 订阅服务
final KRSubscribeService kr_subscribeService = KRSubscribeService();
@@ -278,16 +282,20 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
void _kr_initLoginStatus() {
_initLog.log('开始初始化登录状态处理', tag: 'Home');
KRLogUtil.kr_i('初始化登录状态', tag: 'HomeController');
// 🔧 Android 15 紧急修复:8秒超时,更快响应移动网络慢的情况
Timer(const Duration(seconds: 8), () {
if (kr_currentListStatus.value == KRHomeViewsListStatus.kr_loading) {
_initLog.logWarning('⏱️ 订阅加载超时(8秒保护),强制设置为无数据状态', tag: 'Subscribe');
_initLog.log('当前列表状态仍为: loading,触发超时保护', tag: 'Subscribe');
KRLogUtil.kr_w('⏱️ 订阅服务初始化超时(8秒),强制设置为无数据状态', tag: 'HomeController');
// 🔧 Android 15 优化:超时设置为 none 而非 error,避免底部面板显示错误界面
kr_currentListStatus.value = KRHomeViewsListStatus.kr_none;
// 强制更新底部面板高度,确保显示正常
kr_updateBottomPanelHeight();
_initLog.log('已强制切换到默认视图, 底部面板高度: ${kr_bottomPanelHeight.value}', tag: 'Subscribe');
KRLogUtil.kr_i('✅ 已强制切换到默认视图', tag: 'HomeController');
}
});
@@ -295,6 +303,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
// 🔧 Android 15 新增:3秒警告,帮助诊断
Timer(const Duration(seconds: 3), () {
if (kr_currentListStatus.value == KRHomeViewsListStatus.kr_loading) {
_initLog.logWarning('⚠️ 订阅服务已加载3秒,网络可能较慢', tag: 'Subscribe');
KRLogUtil.kr_w('⚠️ 订阅服务初始化已耗时3秒,可能网络较慢', tag: 'HomeController');
}
});
@@ -66,12 +66,22 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
final isNotLoggedIn = controller.kr_currentViewStatus.value ==
KRHomeViewsStatus.kr_notLoggedIn;
KRLogUtil.kr_i('构建默认视图', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('=' * 60, tag: 'HomeBottomPanel');
KRLogUtil.kr_i('🎨 构建默认视图', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('是否未登录: $isNotLoggedIn', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('是否有有效订阅: $hasValidSubscription', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('订阅列表数量: ${controller.kr_subscribeService.kr_availableSubscribes.length}', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('当前选中订阅: ${controller.kr_subscribeService.kr_currentSubscribe.value?.name ?? "null"}', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('是否试用: $isTrial', tag: 'HomeBottomPanel');
KRLogUtil.kr_i('当前高度: ${controller.kr_bottomPanelHeight.value}',
tag: 'HomeBottomPanel');
KRLogUtil.kr_i('当前高度: ${controller.kr_bottomPanelHeight.value}', tag: 'HomeBottomPanel');
// 🔧 新增:详细的 UI 渲染决策日志
if (hasValidSubscription) {
KRLogUtil.kr_i('✅ 将渲染: 连接信息卡片 (KRHomeConnectionInfoView)', tag: 'HomeBottomPanel');
} else {
KRLogUtil.kr_i('✅ 将渲染: 订阅卡片 (KRSubscriptionCard) - 开通会员界面', tag: 'HomeBottomPanel');
}
KRLogUtil.kr_i('=' * 60, tag: 'HomeBottomPanel');
// 🔧 关键修复:统一布局逻辑,确保无论登录状态如何都显示完整UI
return Column(
@@ -86,35 +96,41 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
// 🔧 核心修复:无论登录状态,都显示核心卡片(订阅或连接信息)
if (hasValidSubscription)
// 已订阅:显示连接信息卡片
Container(
margin: EdgeInsets.only(top: 12.h),
child: const KRHomeConnectionInfoView(),
)
Builder(builder: (context) {
KRLogUtil.kr_i('🔹 渲染连接信息卡片,margin top: ${12}', tag: 'HomeBottomPanel');
return Container(
margin: EdgeInsets.only(top: 12),
child: const KRHomeConnectionInfoView(),
);
})
else
// 未订阅(包括未登录):始终显示订阅卡片
Container(
margin: EdgeInsets.only(top: 12.h, left: 12.w, right: 12.w),
child: const KRSubscriptionCard(),
),
Builder(builder: (context) {
KRLogUtil.kr_i('🔹 渲染订阅卡片,margin: top=${12}, left=${12}, right=${12}', tag: 'HomeBottomPanel');
return Container(
margin: EdgeInsets.only(top: 12, left: 12, right: 12),
child: const KRSubscriptionCard(),
);
}),
// 2. 如果已订阅且是试用,展示试用卡片
if (hasValidSubscription && isTrial)
Container(
margin: EdgeInsets.only(top: 12.h),
margin: EdgeInsets.only(top: 12),
child: const KRHomeTrialCard(),
),
// 3. 如果已订阅且是最后一天,展示最后一天卡片
if (hasValidSubscription && isLastDay && !isTrial)
Container(
margin: EdgeInsets.only(top: 12.h),
margin: EdgeInsets.only(top: 12),
child: const KRHomeLastDayCard(),
),
// 4. 连接选项(分组和国家入口)- 始终显示
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
child: const KRHomeConnectionOptionsView(),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: KRHomeConnectionOptionsView(),
),
],
),
@@ -141,7 +157,7 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
// 顶层:加载指示器
Center(
child: Container(
padding: EdgeInsets.all(16.w),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Get.context!.theme.cardColor,
borderRadius: BorderRadius.circular(12.r),
@@ -160,7 +176,7 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
color: Colors.green,
strokeWidth: 3.0,
),
SizedBox(height: 12.h),
SizedBox(height: 12),
Text(
'正在加载...',
style: TextStyle(
@@ -178,18 +194,18 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
Widget _kr_buildErrorView(BuildContext context) {
return Container(
height: 200.h,
padding: EdgeInsets.all(16.w),
height: 200,
padding: EdgeInsets.all(16),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.error_outline,
size: 48.w,
size: 48,
color: Theme.of(context).colorScheme.error,
),
SizedBox(height: 16.h),
SizedBox(height: 16),
Text(
AppTranslations.kr_home.error,
style: KrAppTextStyle(
@@ -198,7 +214,7 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
color: Theme.of(context).textTheme.bodyMedium?.color,
),
),
SizedBox(height: 8.h),
SizedBox(height: 8),
Text(
AppTranslations.kr_home.checkNetwork,
style: KrAppTextStyle(
@@ -206,10 +222,10 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
color: Theme.of(context).textTheme.bodySmall?.color,
),
),
SizedBox(height: 24.h),
SizedBox(height: 24),
SizedBox(
width: 200.w,
height: 44.h,
width: 200,
height: 44,
child: ElevatedButton(
onPressed: () => controller.kr_refreshAll(),
style: ElevatedButton.styleFrom(
@@ -25,17 +25,17 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
Widget _buildConnectCard(BuildContext context) {
return Obx(() {
return Container(
margin: EdgeInsets.symmetric(horizontal: 16.w),
margin: EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
height: 116.h,
height: 116,
decoration: ShapeDecoration(
color: Theme.of(context).cardColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.w),
borderRadius: BorderRadius.circular(16),
),
),
child: Padding(
padding: EdgeInsets.all(14.w),
padding: EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -66,7 +66,7 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
),
Icon(
Icons.arrow_forward_ios,
size: 12.w,
size: 12,
color: Theme.of(context).textTheme.bodySmall?.color,
),
],
@@ -74,7 +74,7 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
),
],
),
SizedBox(height: 10.h),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -90,7 +90,7 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
countryCode: countryCode,
);
}),
SizedBox(width: 10.w),
SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -102,7 +102,7 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 6.h),
SizedBox(height: 6),
Row(
children: [
Obx(() {
@@ -147,10 +147,10 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
children: [
KRSimpleLoading(
color: Colors.green,
size: 12.w,
size: 12,
duration: const Duration(milliseconds: 800),
),
SizedBox(width: 2.w),
SizedBox(width: 2),
Text(
AppTranslations.kr_home.connecting,
style: TextStyle(
@@ -166,7 +166,7 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
return Row(
children: [
Icon(Icons.signal_cellular_alt,
size: 12.w,
size: 12,
color: getLatencyColor(delay)),
SizedBox(width: 2),
Text(
@@ -188,9 +188,9 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
}
return Row(
children: [
SizedBox(width: 10.w),
SizedBox(width: 10),
Icon(Icons.arrow_upward,
size: 12.w,
size: 12,
color: Theme.of(context).textTheme.bodySmall?.color),
Text(
controller.kr_formatBytes(KRSingBoxImp.instance.kr_stats.value.uplink),
@@ -200,9 +200,9 @@ class KRHomeConnectionInfoView extends GetView<KRHomeController> {
fontWeight: FontWeight.w400,
),
),
SizedBox(width: 10.w),
SizedBox(width: 10),
Icon(Icons.arrow_downward,
size: 12.w,
size: 12,
color: Theme.of(context).textTheme.bodySmall?.color),
Text(
controller.kr_formatBytes(KRSingBoxImp.instance.kr_stats.value.downlink),
@@ -14,19 +14,23 @@ class KRHomeConnectionOptionsView extends GetView<KRHomeController> {
@override
Widget build(BuildContext context) {
print('🔌 [ConnectionOptions] 开始构建连接选项组件');
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
AppTranslations.kr_home.connectionSectionTitle,
style: KrAppTextStyle(
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Theme.of(context).textTheme.bodyMedium?.color,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black87,
),
),
SizedBox(height: 8.h),
const SizedBox(height: 12),
_buildConnectionOption(
"home_ct",
AppTranslations.kr_home.countryRegion,
@@ -41,8 +45,11 @@ class KRHomeConnectionOptionsView extends GetView<KRHomeController> {
Widget _buildConnectionOption(String icon, String label, BuildContext context,
{VoidCallback? onTap}) {
print('🔌 [ConnectionOptions] 构建连接选项: $label');
return GestureDetector(
onTap: () {
print('🔌 [ConnectionOptions] 选项被点击: $label');
if (controller.kr_subscribeService.kr_currentSubscribe.value == null) {
// 未订阅状态下,使用统一的订阅导航工具
KRSubscribeNavigationUtil.navigateToPurchase(tag: 'ConnectionOptions');
@@ -52,30 +59,34 @@ class KRHomeConnectionOptionsView extends GetView<KRHomeController> {
}
},
child: Container(
padding: EdgeInsets.all(16.w),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(12.r),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
KrLocalImage(
imageName: icon,
width: 32.w,
height: 32.w,
color: Theme.of(context).textTheme.bodyMedium?.color,
width: 36,
height: 36,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white70
: Colors.black87,
),
SizedBox(height: 12.h),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: Text(
label,
style: KrAppTextStyle(
fontSize: 13,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).textTheme.bodyMedium?.color,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black87,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
@@ -83,8 +94,10 @@ class KRHomeConnectionOptionsView extends GetView<KRHomeController> {
),
Icon(
Icons.arrow_forward_ios,
size: 12.w,
color: Theme.of(context).textTheme.bodySmall?.color,
size: 14,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white54
: Colors.black45,
),
],
),
@@ -15,16 +15,16 @@ class KRHomeLastDayCard extends GetView<KRHomeController> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 16.w),
margin: EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
decoration: ShapeDecoration(
color: Theme.of(context).cardColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.w),
borderRadius: BorderRadius.circular(16),
),
),
child: Padding(
padding: EdgeInsets.all(14.w),
padding: EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@@ -54,7 +54,7 @@ class KRHomeLastDayCard extends GetView<KRHomeController> {
),
Icon(
Icons.arrow_forward_ios,
size: 12.w,
size: 12,
color: Colors.blue,
),
],
@@ -64,14 +64,14 @@ class KRHomeLastDayCard extends GetView<KRHomeController> {
),
// 倒计时显示
SizedBox(height: 10.h),
SizedBox(height: 10),
Row(
children: [
Container(
padding: EdgeInsets.all(8.w),
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.circular(8.w),
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -79,9 +79,9 @@ class KRHomeLastDayCard extends GetView<KRHomeController> {
Icon(
Icons.timer_outlined,
color: Colors.blue,
size: 16.w,
size: 16,
),
SizedBox(width: 4.w),
SizedBox(width: 4),
Text(
AppTranslations.kr_home.lastDaySubscriptionMessage,
style: KrAppTextStyle(
@@ -93,7 +93,7 @@ class KRHomeLastDayCard extends GetView<KRHomeController> {
],
),
),
SizedBox(width: 12.w),
SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -16,16 +16,16 @@ class KRHomeTrialCard extends GetView<KRHomeController> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 16.w),
margin: EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
decoration: ShapeDecoration(
color: Theme.of(context).cardColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.w),
borderRadius: BorderRadius.circular(16),
),
),
child: Padding(
padding: EdgeInsets.all(14.w),
padding: EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@@ -55,7 +55,7 @@ class KRHomeTrialCard extends GetView<KRHomeController> {
),
Icon(
Icons.arrow_forward_ios,
size: 12.w,
size: 12,
color: Colors.blue,
),
],
@@ -65,14 +65,14 @@ class KRHomeTrialCard extends GetView<KRHomeController> {
),
// 倒计时显示
SizedBox(height: 10.h),
SizedBox(height: 10),
Row(
children: [
Container(
padding: EdgeInsets.all(8.w),
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.circular(8.w),
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -80,9 +80,9 @@ class KRHomeTrialCard extends GetView<KRHomeController> {
Icon(
Icons.timer_outlined,
color: Colors.blue,
size: 16.w,
size: 16,
),
SizedBox(width: 4.w),
SizedBox(width: 4),
Text(
AppTranslations.kr_home.trialing,
style: KrAppTextStyle(
@@ -94,7 +94,7 @@ class KRHomeTrialCard extends GetView<KRHomeController> {
],
),
),
SizedBox(width: 12.w),
SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -24,63 +24,80 @@ class KRSubscriptionCard extends StatelessWidget {
// 构建订阅卡片
Widget _kr_buildSubscriptionCard(BuildContext context) {
// 🔧 新增:订阅卡片渲染日志
print('🎴 [SubscriptionCard] 开始构建订阅卡片');
print('🎴 [SubscriptionCard] 卡片颜色: ${Theme.of(context).cardColor}');
print('🎴 [SubscriptionCard] 主题亮度: ${Theme.of(context).brightness}');
print('🎴 [SubscriptionCard] 文本颜色: ${Theme.of(context).textTheme.bodyMedium?.color}');
print('🎴 [SubscriptionCard] ScreenUtil 测试 - 12.w=${12.w}, 16.h=${16.h}, 44.w=${44.w}');
// 🔧 关键修复:完全移除 ScreenUtil,使用固定像素值避免缩放问题
return Container(
// 添加固定高度,确保卡片可见
constraints: const BoxConstraints(minHeight: 200),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(12.w),
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// 图标
Container(
width: 44.w,
height: 44.w,
margin: EdgeInsets.only(top: 16.h),
width: 48,
height: 48,
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
shape: BoxShape.circle,
),
child: Icon(
child: const Icon(
Icons.language,
color: Colors.blue,
size: 26.w,
size: 28,
),
),
SizedBox(height: 12.h),
const SizedBox(height: 16),
// 描述文字
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
AppTranslations.kr_home.subscriptionDescription,
textAlign: TextAlign.center,
style: KrAppTextStyle(
fontSize: 14,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Theme.of(context).textTheme.bodyMedium?.color,
height: 1.5,
// 🔧 关键修复:确保文本颜色可见
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black87,
),
),
),
SizedBox(height: 16.h),
Padding(
padding: EdgeInsets.fromLTRB(16.w, 0, 16.w, 16.h),
child: SizedBox(
width: double.infinity,
height: 42.h,
child: ElevatedButton(
onPressed: () => KRSubscribeNavigationUtil.navigateToPurchase(tag: 'SubscriptionCard'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.r),
),
const SizedBox(height: 20),
// 订阅按钮
SizedBox(
width: double.infinity,
height: 46,
child: ElevatedButton(
onPressed: () {
print('🎴 [SubscriptionCard] 订阅按钮被点击');
KRSubscribeNavigationUtil.navigateToPurchase(tag: 'SubscriptionCard');
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
child: Text(
AppTranslations.kr_home.subscribe,
style: KrAppTextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
child: Text(
AppTranslations.kr_home.subscribe,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
@@ -1,4 +1,5 @@
import 'package:get/get.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:kaer_with_panels/app/modules/kr_home/controllers/kr_home_controller.dart';
import 'package:kaer_with_panels/app/modules/kr_invite/controllers/kr_invite_controller.dart';
import 'package:kaer_with_panels/app/modules/kr_login/controllers/kr_login_controller.dart';
@@ -10,15 +11,40 @@ import '../controllers/kr_main_controller.dart';
class KRMainBinding extends Bindings {
@override
void dependencies() {
if (kDebugMode) {
print('🔧 KRMainBinding.dependencies 被调用');
}
// 🔧 MainController 仍然使用 lazyPut,因为它由 MainView 触发
Get.lazyPut<KRMainController>(
() => KRMainController(),
() {
if (kDebugMode) {
print('🏗️ 创建 KRMainController 实例');
}
return KRMainController();
},
);
Get.lazyPut(() => KRHomeController());
Get.lazyPut(() => KRLoginController());
// 🔧 关键修复:使用 lazyPut 但设置为单例,避免重复创建
// fenix: true 允许控制器在被删除后重新创建
// 使用 lazyPut 让 HomeController 在真正需要时才创建,避免过早初始化导致资源冲突
Get.lazyPut<KRHomeController>(
() {
if (kDebugMode) {
print('🏗️ 创建 KRHomeController 实例(仅此一次)');
}
return KRHomeController();
},
fenix: true,
);
Get.lazyPut(() => KRLoginController());
Get.lazyPut(() => KRInviteController());
Get.lazyPut(() => KRUserInfoController());
Get.lazyPut(() => KRStatisticsController());
if (kDebugMode) {
print('✅ KRMainBinding.dependencies 完成');
}
}
}
@@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:get/get.dart';
import 'package:kaer_with_panels/app/modules/kr_home/views/kr_home_view.dart';
import 'package:kaer_with_panels/app/modules/kr_invite/views/kr_invite_view.dart';
@@ -30,19 +31,33 @@ class KRMainController extends GetxController {
static KRMainController get to => Get.find();
DateTime? lastPopTime;
var kr_currentIndex = 0.obs;
final List<Widget> widgets = [
KRKeepAliveWrapper(KRHomeView()),
KRKeepAliveWrapper(KRInviteView()),
KRKeepAliveWrapper(KRStatisticsView()),
KRKeepAliveWrapper(KRUserInfoView()),
];
late final List<Widget> widgets;
/// 分页控制器
PageController pageController = PageController(keepPage: true);
@override
void onInit() {
super.onInit();
// 🔧 诊断:在 onInit 中创建 widgets 列表
if (kDebugMode) {
print('🎬 KRMainController.onInit 被调用');
print('📝 开始创建 widgets 列表...');
}
widgets = [
KRKeepAliveWrapper(KRHomeView()),
KRKeepAliveWrapper(KRInviteView()),
KRKeepAliveWrapper(KRStatisticsView()),
KRKeepAliveWrapper(KRUserInfoView()),
];
if (kDebugMode) {
print('✅ widgets 列表创建完成,包含 ${widgets.length} 个页面');
}
}
@@ -555,11 +555,11 @@ class KRPurchaseMembershipView extends GetView<KRPurchaseMembershipController> {
// 账号部分
Widget _kr_buildAccountSection(BuildContext context) {
return Container(
margin: EdgeInsets.all(16.r),
padding: EdgeInsets.all(16.r),
margin: EdgeInsets.all(16),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(12.r),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
@@ -517,10 +517,12 @@ class KRSplashController extends GetxController {
_initLog.log('Token存在: $hasToken', tag: 'Splash');
_initLog.logSuccess('正常初始化流程完成', tag: 'Splash');
// 完成日志收集
await _initLog.finalize();
// 🔧 关键修复:不要在这里关闭日志文件!
// 日志文件需要保持打开状态,让 HomeController 也能写入日志
// 日志文件将在 HomeController 初始化完成后关闭
// await _initLog.finalize(); // ❌ 注释掉
if (kDebugMode && _initLog.getLogFilePath() != null) {
print('📁 初始化日志文件: ${_initLog.getLogFilePath()}');
print('📁 初始化日志文件(保持打开): ${_initLog.getLogFilePath()}');
}
// 直接导航到主页(无论是否登录,主页会根据登录状态显示不同内容)
@@ -549,8 +551,8 @@ class KRSplashController extends GetxController {
kr_hasError.value = true;
kr_errorMessage.value = '${AppTranslations.kr_splash.kr_initializationFailed}$e';
// 完成日志收集
await _initLog.finalize();
// 🔧 错误情况下也不关闭日志,让后续的错误处理也能写入
// await _initLog.finalize(); // ❌ 注释掉
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ class AppPages {
),
GetPage(
name: _Paths.KR_HOME,
page: () => const KRHomeView(),
page: () => KRHomeView(),
binding: KRHomeBinding(),
arguments: {'showSubscriptionButton': true}, // 显示购买按钮
customTransition: SlideOutOnlyTransition(
@@ -42,7 +42,20 @@ class KRSubscribeNavigationUtil {
} else {
// 正常流程 - 跳转到购买页面
KRLogUtil.kr_i('普通用户,跳转到购买页面', tag: tag);
Get.toNamed(Routes.KR_PURCHASE_MEMBERSHIP);
try {
// 🔧 添加加载保护,避免页面跳转时卡死
Get.toNamed(Routes.KR_PURCHASE_MEMBERSHIP);
} catch (e) {
KRLogUtil.kr_e('跳转购买页面失败: $e', tag: tag);
// 如果跳转失败,显示错误提示
KRDialog.show(
title: AppTranslations.kr_dialog.error,
message: AppTranslations.kr_home.checkNetwork,
confirmText: AppTranslations.kr_dialog.kr_ok,
onConfirm: () => Get.back(),
);
}
}
}
}