feat: 优化未连接节点时候批量节点测速功能,修复网络初始化报错后,导致的连锁反应界面出现错乱和DioExceptionType.unknown报错信息,直连模式,不依赖未初始化的核心
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 / 构建 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 Multi-Platform / 编译 libcore (iOS/tvOS) (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 Windows / 编译 libcore (Windows) (push) Has been cancelled
Build Windows / build (push) Has been cancelled

This commit is contained in:
2025-11-04 03:08:24 -08:00
parent 33f45aa4a5
commit 6131a80b2c
4 changed files with 420 additions and 218 deletions
@@ -1,4 +1,3 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kaer_with_panels/app/localization/app_translations.dart';
@@ -25,25 +24,18 @@ class KRHomeNodeListView extends GetView<KRHomeController> {
// 添加常量定义
static const Color krModernGreen = Color(0xFF4CAF50);
static const Color krModernGreenLight = Color(0xFF81C784);
// 存储每个节点的随机延迟值(仅用于界面显示)
static final Map<String, int> _fakeDelays = {};
// 🔧 修复无限刷新:添加标志位确保自动测试只触发一次
static bool _hasTriggeredAutoTest = false;
/// 获取显示的延迟值
/// ✅ 修复:始终显示真实的 TCP 测试结果
int _getDisplayDelay(KRHomeController controller, KROutboundItem item) {
// 如果已连接,使用真实的延迟
if (controller.kr_isConnected.value) {
return item.urlTestDelay.value;
}
// 如果未连接,使用随机延迟值
if (!_fakeDelays.containsKey(item.tag)) {
// 生成30ms-100ms之间的随机延迟
final random = Random();
_fakeDelays[item.tag] = 30 + random.nextInt(71); // 30 + (0-70) = 30-100ms
}
return _fakeDelays[item.tag] ?? 0;
// 直接返回真实的延迟测试结果
// 无论是否连接VPN,都使用 item.urlTestDelay.value
// - 已连接:通过 SingBox 代理测试的真实延迟
// - 未连接:通过 TCP Socket 直连测试的真实延迟
return item.urlTestDelay.value;
}
@override
@@ -658,13 +650,16 @@ class KRHomeNodeListView extends GetView<KRHomeController> {
);
}
// 自动触发延迟测试(仅在未连接状态下)
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!controller.kr_isConnected.value && !controller.kr_isLatency.value) {
KRLogUtil.kr_i('🔄 节点列表显示 - 自动触发延迟测试', tag: 'NodeListView');
controller.kr_urlTest();
}
});
// 🔧 修复无限刷新:自动触发延迟测试(仅在未连接状态下,且只触发一次
if (!_hasTriggeredAutoTest) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!controller.kr_isConnected.value && !controller.kr_isLatency.value && !_hasTriggeredAutoTest) {
_hasTriggeredAutoTest = true; // 标记已触发
KRLogUtil.kr_i('🔄 节点列表显示 - 自动触发延迟测试(首次)', tag: 'NodeListView');
controller.kr_urlTest();
}
});
}
return _kr_buildListContainer(
context,
child: ListView(