安卓15部分机型出现界面不兼容并且UI库有BUG,MD
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 (Android) (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 Windows / build (push) Has been cancelled
Build Multi-Platform / 编译 libcore (iOS/tvOS) (push) Has been cancelled
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 (Android) (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 Windows / build (push) Has been cancelled
Build Multi-Platform / 编译 libcore (iOS/tvOS) (push) Has been cancelled
(cherry picked from commit 010405edda74bdb0251dcff2e32482edae2c9976)
This commit is contained in:
@@ -528,8 +528,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
// 添加更详细的状态监听
|
||||
ever(KRSingBoxImp.instance.kr_status, (status) {
|
||||
if (kDebugMode) {
|
||||
print('🔵 Controller 收到状态变化: ${status.runtimeType}');
|
||||
}
|
||||
}
|
||||
KRLogUtil.kr_i('🔄 连接状态变化: $status', tag: 'HomeController');
|
||||
KRLogUtil.kr_i('📊 当前状态类型: ${status.runtimeType}', tag: 'HomeController');
|
||||
|
||||
@@ -558,8 +557,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
case SingboxStarted():
|
||||
KRLogUtil.kr_i('🟢 状态: 已启动', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 状态变为 Started, 当前延迟=${kr_currentNodeLatency.value}');
|
||||
}
|
||||
}
|
||||
|
||||
// 取消连接超时处理
|
||||
_cancelConnectionTimeout();
|
||||
@@ -572,13 +570,11 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
// 🔧 关键修复:如果延迟还是-1(连接中状态),立即设置为0(已连接但延迟未知)
|
||||
if (kr_currentNodeLatency.value == -1) {
|
||||
if (kDebugMode) {
|
||||
print('🔵 强制将延迟从 -1 更新为 0');
|
||||
}
|
||||
}
|
||||
kr_currentNodeLatency.value = 0;
|
||||
kr_currentNodeLatency.refresh(); // 强制刷新延迟值
|
||||
if (kDebugMode) {
|
||||
print('🔵 延迟值已刷新');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 修复:立即尝试更新延迟值
|
||||
@@ -589,8 +585,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
// 强制更新UI
|
||||
update();
|
||||
if (kDebugMode) {
|
||||
print('🔵 状态更新完成,当前延迟=${kr_currentNodeLatency.value}');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SingboxStopping():
|
||||
KRLogUtil.kr_i('🟠 状态: 正在停止', tag: 'HomeController');
|
||||
@@ -677,15 +672,13 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
KRLogUtil.kr_i('🔵 toggleSwitch 被调用: value=$value, currentStatus=$currentStatus', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 toggleSwitch: value=$value, currentStatus=$currentStatus');
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 关键: 如果正在切换中,直接忽略(参考 hiddify-app 的 "switching status, debounce")
|
||||
if (currentStatus is SingboxStarting || currentStatus is SingboxStopping) {
|
||||
KRLogUtil.kr_i('🔄 正在切换中,忽略本次操作 (当前状态: $currentStatus)', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 忽略操作:正在切换中');
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -694,13 +687,11 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
// 开启连接
|
||||
KRLogUtil.kr_i('🔄 开始连接...', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 执行 kr_start()');
|
||||
}
|
||||
}
|
||||
await KRSingBoxImp.instance.kr_start();
|
||||
KRLogUtil.kr_i('✅ 连接命令已发送', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 kr_start() 完成');
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 修复: 等待状态更新,最多3秒
|
||||
await _waitForStatus(SingboxStarted, maxSeconds: 3);
|
||||
@@ -708,8 +699,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
// 关闭连接
|
||||
KRLogUtil.kr_i('🛑 开始断开连接...', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 执行 kr_stop()');
|
||||
}
|
||||
}
|
||||
await KRSingBoxImp.instance.kr_stop().timeout(
|
||||
const Duration(seconds: 10),
|
||||
onTimeout: () {
|
||||
@@ -719,8 +709,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
);
|
||||
KRLogUtil.kr_i('✅ 断开命令已发送', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 kr_stop() 完成');
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 修复: 等待状态更新,最多2秒
|
||||
await _waitForStatus(SingboxStopped, maxSeconds: 2);
|
||||
@@ -728,34 +717,29 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
} catch (e) {
|
||||
KRLogUtil.kr_e('❌ 切换失败: $e', tag: 'HomeController');
|
||||
if (kDebugMode) {
|
||||
print('🔵 切换失败: $e');
|
||||
}
|
||||
}
|
||||
// 发生错误时强制同步状态
|
||||
kr_forceSyncConnectionStatus();
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
print('🔵 toggleSwitch 完成,当前 kr_isConnected=${kr_isConnected.value}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 🔧 等待状态达到预期值
|
||||
Future<void> _waitForStatus(Type expectedType, {int maxSeconds = 3}) async {
|
||||
if (kDebugMode) {
|
||||
print('🔵 等待状态变为: $expectedType');
|
||||
}
|
||||
}
|
||||
final startTime = DateTime.now();
|
||||
|
||||
while (DateTime.now().difference(startTime).inSeconds < maxSeconds) {
|
||||
final currentStatus = KRSingBoxImp.instance.kr_status.value;
|
||||
if (kDebugMode) {
|
||||
print('🔵 当前状态: ${currentStatus.runtimeType}');
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStatus.runtimeType == expectedType) {
|
||||
if (kDebugMode) {
|
||||
print('🔵 状态已达到: $expectedType');
|
||||
}
|
||||
}
|
||||
// 强制同步确保 kr_isConnected 正确
|
||||
kr_forceSyncConnectionStatus();
|
||||
return;
|
||||
@@ -765,8 +749,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
print('🔵 等待超时,强制同步状态');
|
||||
}
|
||||
}
|
||||
kr_forceSyncConnectionStatus();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user