feat: debug
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 Windows / 编译 libcore (Windows) (push) Has been cancelled
Build Windows / build (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 / 构建 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 / 构建 Windows (push) Has been cancelled

This commit is contained in:
2025-11-01 23:14:39 -07:00
parent 1e7175edf5
commit 765b45c0fc
4 changed files with 185 additions and 282 deletions
@@ -25,67 +25,20 @@ class HINodeListController extends GetxController {
/// 更新连接类型
void kr_updateConnectionType(KRConnectionType type) {
KRSingBoxImp.instance.kr_updateConnectionType(type);
KRLogUtil.kr_i('连接类型已更新为: $type', tag: 'HINodeListController');
if (KRSingBoxImp().kr_connectionType.value != type) {
KRSingBoxImp.instance.kr_updateConnectionType(type);
KRLogUtil.kr_i('连接类型已更新为: $type', tag: 'HINodeListController');
// 这里可以添加其他需要的逻辑
}
// 如果当前有选择的国家,触发重选检查
if (homeController.currentSelectedCountry.isNotEmpty) {
KRLogUtil.kr_i('连接类型更新后,检查是否需要重选节点', tag: 'HINodeListController');
// 延迟一下让连接类型更新完成
Future.delayed(const Duration(milliseconds: 500), () {
homeController.checkCountryReselection(KRSingBoxImp.instance.kr_activeGroups);
// homeController.checkCountryReselection(KRSingBoxImp.instance.kr_activeGroups);
});
}
}
/// 获取当前国家内的有效节点标签列表
List<String> getValidNodesInCurrentCountry() {
final country = homeController.currentSelectedCountry.value;
if (country.isEmpty) {
return [];
}
final countryGroup = kr_subscribeService.countryOutboundList
.firstWhereOrNull((group) => group.country == country);
if (countryGroup == null) {
return [];
}
return countryGroup.outboundList
.where((node) => node.urlTestDelay.value < 65535 && node.urlTestDelay.value > 0)
.map((node) => node.tag)
.toList();
}
/// 手动触发当前国家内的重选
void manualReselection() {
final country = homeController.currentSelectedCountry.value;
if (country.isEmpty) {
KRLogUtil.kr_w('没有选择国家,无法进行重选', tag: 'HINodeListController');
return;
}
KRLogUtil.kr_i('用户手动触发国家内重选', tag: 'HINodeListController');
homeController.performCountryReselection(country);
}
/// 获取当前国家内节点的延迟统计(委托给homeController
Map<String, dynamic> getCurrentCountryLatencyStats() {
return homeController.getCurrentCountryNodeStats();
}
/// 启用/禁用动态重选功能(委托给homeController
void setDynamicReselectionEnabled(bool enabled) {
homeController.setCountryReselectionEnabled(enabled);
}
/// 获取动态重选状态信息
Map<String, dynamic> getDynamicReselectionStatus() {
return {
'enabled': homeController.isCountryReselectionEnabled.value,
'currentCountry': homeController.currentSelectedCountry.value,
'latencyThreshold': homeController.countryReselectionLatencyThreshold,
};
}
}
@@ -42,19 +42,22 @@ class HINodeListView extends GetView<HINodeListController> {
/// 获取分组内最快节点的延迟值(单位:ms)
/// 如果列表为空,返回 0
int getFastestNodeDelay(
HINodeListController controller, List<KROutboundItem> outboundList) {
HINodeListController controller,
List<KROutboundItem> outboundList,
) {
if (outboundList.isEmpty) return 0;
int fastestDelay = _getDisplayDelay(controller, outboundList.first);
// 过滤掉不可用节点(延迟标记为 65535 或负数)
final validNodes = outboundList.where((node) {
final delay = node.urlTestDelay.value;
return delay > 0 && delay < 65535;
}).toList();
for (final item in outboundList.skip(1)) {
final delay = _getDisplayDelay(controller, item);
if (delay < fastestDelay) {
fastestDelay = delay;
}
}
if (validNodes.isEmpty) return 0;
return fastestDelay;
// 返回最小延迟值
validNodes.sort((a, b) => a.urlTestDelay.value.compareTo(b.urlTestDelay.value));
return validNodes.first.urlTestDelay.value;
}
/// 找出延迟最低(最快)的节点对象
@@ -109,11 +112,19 @@ class HINodeListView extends GetView<HINodeListController> {
_buildEmptyListPlaceholder(context, AppTranslations.kr_home.noRegions)
else ...[
InkWell(
onTap: () {
controller.homeController.kr_selectNode('auto');
controller.homeController.kr_currentListStatus.value =
KRHomeViewsListStatus.kr_none;
controller.homeController.kr_coutryText.value = 'auto';
// 🔧 修复:改为 async,等待节点切换完成后再关闭列表
onTap: () async {
try {
final success =
await controller.homeController.kr_performNodeSwitch('auto');
if (success) {
controller.homeController.kr_currentListStatus.value =
KRHomeViewsListStatus.kr_none;
}
} catch (e) {
KRLogUtil.kr_e('Auto选项切换异常: $e',
tag: 'NodeListView');
}
},
child: Container(
decoration: BoxDecoration(
@@ -189,14 +200,7 @@ class HINodeListView extends GetView<HINodeListController> {
return InkWell(
onTap: () {
// 自动选择这个国家下的节点延迟中最快的
final item = findFastestNode(country.outboundList);
KRLogUtil.kr_i(item.tag);
print('item${item.toString()}');
controller.homeController.kr_selectNode(item.tag);
controller.homeController.kr_currentListStatus.value =
KRHomeViewsListStatus.kr_none;
controller.homeController.kr_coutryText.value = country.country;
controller.homeController.onCountrySelected(country.country);
},
child: _kr_buildCountryListItem(context, country: country),
);