diff --git a/lib/app/modules/hi_menu/widgets/user_info_card.dart b/lib/app/modules/hi_menu/widgets/user_info_card.dart index 9d59f55..e8c9f2e 100644 --- a/lib/app/modules/hi_menu/widgets/user_info_card.dart +++ b/lib/app/modules/hi_menu/widgets/user_info_card.dart @@ -59,6 +59,8 @@ class UserInfoCard extends StatelessWidget { children: [ Text( 'ID: $userId', + overflow: TextOverflow.ellipsis, + maxLines: 1, style: TextStyle( color: Colors.white, fontSize: 14.sp, diff --git a/lib/app/services/kr_subscribe_service.dart b/lib/app/services/kr_subscribe_service.dart index 5e48103..75d77c3 100755 --- a/lib/app/services/kr_subscribe_service.dart +++ b/lib/app/services/kr_subscribe_service.dart @@ -309,7 +309,7 @@ class KRSubscribeService { // 保存配置 KRSingBoxImp.instance.kr_saveOutbounds(listModel.configJsonList); - KRSingBoxImp.instance.kr_saveAllOutbounds(listModel.configJsonList); + KRSingBoxImp.instance.kr_saveAllOutbounds(listModel.countryOutboundList); // 更新试用和订阅状态 _kr_updateSubscribeStatus(); @@ -662,7 +662,7 @@ class KRSubscribeService { // 保存配置 KRSingBoxImp.instance.kr_saveOutbounds(listModel.configJsonList); - KRSingBoxImp.instance.kr_saveAllOutbounds(listModel.configJsonList); + KRSingBoxImp.instance.kr_saveAllOutbounds(listModel.countryOutboundList); // 更新试用和订阅状态 _kr_updateSubscribeStatus(); diff --git a/lib/app/services/singbox_imp/kr_sing_box_imp.dart b/lib/app/services/singbox_imp/kr_sing_box_imp.dart index c6677c6..204ff9c 100755 --- a/lib/app/services/singbox_imp/kr_sing_box_imp.dart +++ b/lib/app/services/singbox_imp/kr_sing_box_imp.dart @@ -19,6 +19,8 @@ import '../../../singbox/model/singbox_config_option.dart'; import '../../../singbox/model/singbox_outbound.dart'; import '../../../singbox/model/singbox_stats.dart'; import '../../../singbox/model/singbox_status.dart'; +import '../../model/business/kr_group_outbound_list.dart'; +import '../../model/business/kr_outbound_item.dart'; import '../../utils/kr_country_util.dart'; import '../../utils/kr_log_util.dart'; import '../../utils/kr_secure_storage.dart'; @@ -66,7 +68,7 @@ class KRSingBoxImp { Map kr_configOption = {}; List> kr_outbounds = []; - List> Kr_allOutbounds = []; + List Kr_allOutbounds = []; /// 首次启动 RxBool kr_isFristStart = false.obs; @@ -1202,8 +1204,13 @@ class KRSingBoxImp { // print("错误堆栈: $stack"); // } // } - void kr_saveAllOutbounds(List> outbounds) { + void kr_saveAllOutbounds(List outbounds) { Kr_allOutbounds = outbounds; + KRLogUtil.kr_i('📊 保存国家分组: ${Kr_allOutbounds.length}', tag: 'SingBox'); + for (int i = 0; i < Kr_allOutbounds.length; i++) { + final c = Kr_allOutbounds[i]; + KRLogUtil.kr_i(' group[$i] country="${c.country}" outbounds=${c.outboundList.length}', tag: 'SingBox'); + } } /// 保存配置文件 void kr_saveOutbounds(List> outbounds) async { @@ -1457,18 +1464,40 @@ class KRSingBoxImp { if (kr_outbounds.isNotEmpty) { KRLogUtil.kr_i('🔄 启动前强制重新生成配置文件...', tag: 'SingBox'); final selectedNode = await KRSecureStorage().kr_readData(key: _keySelectedNode); - var toSave = Kr_allOutbounds; + KRLogUtil.kr_i('📊 国家分组数量: ${Kr_allOutbounds.length}', tag: 'SingBox'); + for (int i = 0; i < Kr_allOutbounds.length; i++) { + final g = Kr_allOutbounds[i]; + KRLogUtil.kr_i('Kr_allOutbounds[$i] country="${g.country}" outbounds=${g.outboundList.length}', tag: 'SingBox'); + } + List> toSave = []; if (selectedNode != null && selectedNode.endsWith('-auto')) { KRLogUtil.kr_i('🤖 检测到自动国家节点: $selectedNode', tag: 'SingBox'); - final selectedCountry = selectedNode.replaceAll(RegExp(r'-auto$'), ''); - toSave = Kr_allOutbounds.where((o) { - final country = o['country']?.toString() ?? ''; - if (country.isNotEmpty) return country == selectedCountry; - final tag = o['tag']?.toString() ?? ''; - if (tag == selectedNode) return true; - return tag.toLowerCase().contains(selectedCountry.toLowerCase()); - }).toList(); - KRLogUtil.kr_i('✅ 自动国家过滤: ${toSave.length}/${Kr_allOutbounds.length}', tag: 'SingBox'); + String selectedCountry = selectedNode.replaceAll(RegExp(r'-auto$'), ''); + final selectedCountryLower = selectedCountry.toLowerCase(); + final matchedGroup = Kr_allOutbounds.firstWhere( + (g) => g.country.toLowerCase() == selectedCountryLower, + orElse: () => KRCountryOutboundList(country: '', outboundList: []), + ); + if (matchedGroup.country.isNotEmpty) { + KRLogUtil.kr_i('🎯 命中分组: ${matchedGroup.country}, 节点数: ${matchedGroup.outboundList.length}', tag: 'SingBox'); + toSave = matchedGroup.outboundList.map((it) => it.config).toList(); + } else { + for (final g in Kr_allOutbounds) { + for (final it in g.outboundList) { + final tagLower = it.tag.toLowerCase(); + if (tagLower == selectedNode.toLowerCase() || tagLower.contains(selectedCountryLower)) { + toSave.add(it.config); + } + } + } + } + KRLogUtil.kr_i('✅ 自动国家过滤: ${toSave.length}', tag: 'SingBox'); + } else { + for (final g in Kr_allOutbounds) { + for (final it in g.outboundList) { + toSave.add(it.config); + } + } } kr_saveOutbounds(toSave); await Future.delayed(const Duration(milliseconds: 100));