解决kr_start() 方法中缺少对分组数据流的订阅
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 (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 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 (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
This commit is contained in:
@@ -530,8 +530,6 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
void _bindConnectionStatus() {
|
||||
// 添加更详细的状态监听
|
||||
ever(KRSingBoxImp.instance.kr_status, (status) {
|
||||
if (kDebugMode) {
|
||||
}
|
||||
KRLogUtil.kr_i('🔄 连接状态变化: $status', tag: 'HomeController');
|
||||
KRLogUtil.kr_i('📊 当前状态类型: ${status.runtimeType}', tag: 'HomeController');
|
||||
|
||||
@@ -1159,50 +1157,110 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
/// 获取当前节点国家
|
||||
/// 🔧 修复:使用 kr_cutTag 而不是 kr_cutSeletedTag,确保UI立即响应
|
||||
/// 🔧 修复:处理 "auto" 等特殊标签,从活动组中获取实际选中的节点
|
||||
/// 🔧 修复:优先使用 kr_cutSeletedTag,避免依赖可能为空的 kr_activeGroups
|
||||
/// 策略:
|
||||
/// 1. 如果 kr_cutTag 不是 auto,直接使用(用户手动选择的节点)
|
||||
/// 2. 如果是 auto,优先使用 kr_cutSeletedTag(保存了实际选中的节点)
|
||||
/// 3. 如果 kr_cutSeletedTag 也是 auto 或空,再尝试从 kr_activeGroups 获取
|
||||
String kr_getCurrentNodeCountry() {
|
||||
KRLogUtil.kr_i('========== 开始获取国家代码 ==========', tag: 'getCurrentNodeCountry');
|
||||
KRLogUtil.kr_i('kr_cutTag: ${kr_cutTag.value}', tag: 'getCurrentNodeCountry');
|
||||
KRLogUtil.kr_i('kr_cutSeletedTag: ${kr_cutSeletedTag.value}', tag: 'getCurrentNodeCountry');
|
||||
KRLogUtil.kr_i('keyList 节点总数: ${kr_subscribeService.keyList.length}', tag: 'getCurrentNodeCountry');
|
||||
|
||||
if (kr_cutTag.isEmpty) {
|
||||
KRLogUtil.kr_w('kr_cutTag 为空,返回空字符串', tag: 'getCurrentNodeCountry');
|
||||
return '';
|
||||
String actualTag;
|
||||
|
||||
// 🔧 优先策略:
|
||||
// 1. 如果 kr_cutTag 不是 auto,直接使用(用户手动选择的节点)
|
||||
if (kr_cutTag.value != 'auto' && kr_cutTag.value != 'select' && kr_cutTag.value.isNotEmpty) {
|
||||
// 用户手动选择了具体节点
|
||||
actualTag = kr_cutTag.value;
|
||||
KRLogUtil.kr_i('✅ 使用手动选择的节点: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
}
|
||||
|
||||
String actualTag = kr_cutTag.value;
|
||||
|
||||
// 🔧 修复:如果是 "auto" 或其他选择器组,从活动组中获取实际选中的节点
|
||||
if (actualTag == 'auto' || actualTag == 'select') {
|
||||
// 2. 如果是 auto,优先使用 kr_cutSeletedTag(保存了实际选中的节点)
|
||||
else if (kr_cutSeletedTag.value.isNotEmpty &&
|
||||
kr_cutSeletedTag.value != 'auto' &&
|
||||
kr_cutSeletedTag.value != 'select') {
|
||||
// auto 模式下,使用保存的实际节点
|
||||
actualTag = kr_cutSeletedTag.value;
|
||||
KRLogUtil.kr_i('✅ 使用 auto 模式下的实际节点 (kr_cutSeletedTag): $actualTag', tag: 'getCurrentNodeCountry');
|
||||
}
|
||||
// 3. 降级:尝试从活动组获取
|
||||
else {
|
||||
try {
|
||||
KRLogUtil.kr_i('检测到特殊标签: $actualTag,尝试从活动组获取实际节点', tag: 'getCurrentNodeCountry');
|
||||
KRLogUtil.kr_i('⚠️ 尝试从活动组获取实际节点', tag: 'getCurrentNodeCountry');
|
||||
KRLogUtil.kr_i('活动组数量: ${KRSingBoxImp.instance.kr_activeGroups.length}', tag: 'getCurrentNodeCountry');
|
||||
|
||||
// 从 SingBox 活动组中找到 "select" 选择器组
|
||||
final selectGroup = KRSingBoxImp.instance.kr_activeGroups.firstWhere(
|
||||
(group) => group.tag == 'select',
|
||||
orElse: () => throw Exception('未找到 select 组'),
|
||||
);
|
||||
// 🔧 修复:活动组为空时,尝试使用 allGroups
|
||||
if (KRSingBoxImp.instance.kr_activeGroups.isEmpty) {
|
||||
print('[getCurrentNodeCountry] ⚠️ 活动组为空,尝试使用 allGroups');
|
||||
KRLogUtil.kr_w('⚠️ 活动组为空,尝试使用 allGroups', tag: 'getCurrentNodeCountry');
|
||||
|
||||
KRLogUtil.kr_i('找到 select 组,当前选中: ${selectGroup.selected}', tag: 'getCurrentNodeCountry');
|
||||
final allGroups = KRSingBoxImp.instance.kr_allGroups;
|
||||
print('[getCurrentNodeCountry] allGroups 数量: ${allGroups.length}');
|
||||
if (allGroups.isEmpty) {
|
||||
print('[getCurrentNodeCountry] ❌ allGroups 也为空,返回空字符串');
|
||||
KRLogUtil.kr_w('❌ allGroups 也为空,返回空字符串', tag: 'getCurrentNodeCountry');
|
||||
return '';
|
||||
}
|
||||
|
||||
// 从 allGroups 中查找 select 组
|
||||
final selectGroup = allGroups.firstWhere(
|
||||
(group) => group.tag == 'select',
|
||||
orElse: () => throw Exception('未找到 select 组'),
|
||||
);
|
||||
print('[getCurrentNodeCountry] selectGroup.selected: ${selectGroup.selected}');
|
||||
|
||||
if (selectGroup.selected.isEmpty || selectGroup.selected == 'auto' || selectGroup.selected == 'select') {
|
||||
print('[getCurrentNodeCountry] select 组选中的是 auto,查找 urltest 组');
|
||||
// 如果 select 组选中的是 auto,从 urltest 组获取
|
||||
final urlTestGroup = allGroups.firstWhere(
|
||||
(group) => group.type == ProxyType.urltest,
|
||||
orElse: () => throw Exception('未找到 urltest 组'),
|
||||
);
|
||||
|
||||
if (urlTestGroup.selected.isNotEmpty) {
|
||||
actualTag = urlTestGroup.selected;
|
||||
print('[getCurrentNodeCountry] ✅ 从 allGroups 的 urltest 组获取节点: $actualTag');
|
||||
KRLogUtil.kr_i('✅ 从 allGroups 的 urltest 组获取节点: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
} else {
|
||||
print('[getCurrentNodeCountry] ❌ urltest 组的 selected 也为空');
|
||||
KRLogUtil.kr_w('❌ urltest 组的 selected 也为空', tag: 'getCurrentNodeCountry');
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
actualTag = selectGroup.selected;
|
||||
print('[getCurrentNodeCountry] ✅ 从 allGroups 的 select 组获取节点: $actualTag');
|
||||
KRLogUtil.kr_i('✅ 从 allGroups 的 select 组获取节点: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
}
|
||||
} else {
|
||||
// 活动组不为空,从活动组获取
|
||||
// 从 SingBox 活动组中找到 "select" 选择器组
|
||||
final selectGroup = KRSingBoxImp.instance.kr_activeGroups.firstWhere(
|
||||
(group) => group.tag == 'select',
|
||||
orElse: () => throw Exception('未找到 select 组'),
|
||||
);
|
||||
|
||||
if (selectGroup.selected.isEmpty) {
|
||||
KRLogUtil.kr_w('❌ select 组的 selected 为空', tag: 'getCurrentNodeCountry');
|
||||
return '';
|
||||
}
|
||||
|
||||
// 获取该组当前选中的实际节点标签
|
||||
if (selectGroup.selected.isNotEmpty) {
|
||||
actualTag = selectGroup.selected;
|
||||
KRLogUtil.kr_i('从 select 组获取实际节点: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
KRLogUtil.kr_i('✅ 从活动组获取节点: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
}
|
||||
} catch (e) {
|
||||
KRLogUtil.kr_w('获取实际节点失败: $e', tag: 'getCurrentNodeCountry');
|
||||
// 失败时使用 kr_cutSeletedTag 作为备选
|
||||
if (kr_cutSeletedTag.value.isNotEmpty && kr_cutSeletedTag.value != 'auto') {
|
||||
actualTag = kr_cutSeletedTag.value;
|
||||
KRLogUtil.kr_i('使用 kr_cutSeletedTag 作为备选: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
}
|
||||
KRLogUtil.kr_e('❌ 从活动组获取节点失败: $e', tag: 'getCurrentNodeCountry');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// 验证 actualTag 是否有效
|
||||
if (actualTag.isEmpty) {
|
||||
KRLogUtil.kr_w('❌ 节点标签为空', tag: 'getCurrentNodeCountry');
|
||||
return '';
|
||||
}
|
||||
|
||||
// 使用实际节点标签查找国家代码
|
||||
KRLogUtil.kr_i('查找节点: $actualTag', tag: 'getCurrentNodeCountry');
|
||||
final node = kr_subscribeService.keyList[actualTag];
|
||||
@@ -1232,6 +1290,7 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
return node.country;
|
||||
}
|
||||
|
||||
|
||||
/// 获取真实连接的节点信息(auto 模式下获取实际连接的节点)
|
||||
Map<String, dynamic> kr_getRealConnectedNodeInfo() {
|
||||
// 如果不是 auto 模式,直接返回当前选中的节点信息
|
||||
@@ -1284,6 +1343,8 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
|
||||
String kr_getRealConnectedNodeCountry() {
|
||||
final info = kr_getRealConnectedNodeInfo();
|
||||
final delay = kr_currentNodeLatency.value;
|
||||
final country1 = kr_getCurrentNodeCountry();
|
||||
print('country----$country1');
|
||||
final country = kr_getCountryFullName(info['country']);
|
||||
if (delay == -2) {
|
||||
return '--';
|
||||
|
||||
Reference in New Issue
Block a user