解决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:
@@ -77,8 +77,6 @@ class KRSingBoxImp {
|
||||
/// 是否自动自动选择线路
|
||||
final kr_isAutoOutbound = false.obs;
|
||||
|
||||
bool _initialized = false;
|
||||
|
||||
/// 连接类型
|
||||
final kr_connectionType = KRConnectionType.rule.obs;
|
||||
|
||||
@@ -148,12 +146,6 @@ class KRSingBoxImp {
|
||||
}
|
||||
|
||||
try {
|
||||
if (_initialized) {
|
||||
KRLogUtil.kr_i('SingBox 已经初始化,跳过重复初始化');
|
||||
return;
|
||||
}
|
||||
_initialized = true;
|
||||
|
||||
KRLogUtil.kr_i('开始初始化 SingBox');
|
||||
// 在应用启动时初始化
|
||||
await KRCountryUtil.kr_init();
|
||||
@@ -620,8 +612,7 @@ class KRSingBoxImp {
|
||||
|
||||
/// 订阅分组数据流
|
||||
void _kr_subscribeToGroups() {
|
||||
KRLogUtil.kr_i('🛰 启动分组监听 watchActiveGroups / watchGroups', tag: 'SingBox');
|
||||
|
||||
print('[_kr_subscribeToGroups] 🚀 开始订阅分组数据流');
|
||||
// 取消之前的分组订阅
|
||||
for (var sub in _kr_subscriptions) {
|
||||
if (sub.hashCode.toString().contains('Groups')) {
|
||||
@@ -634,6 +625,7 @@ class KRSingBoxImp {
|
||||
_kr_subscriptions.add(
|
||||
kr_singBox.watchActiveGroups().listen(
|
||||
(groups) {
|
||||
print('[watchActiveGroups] 📡 收到活动组更新,数量: ${groups.length}');
|
||||
KRLogUtil.kr_i('📡 收到活动组更新,数量: ${groups.length}', tag: 'SingBox');
|
||||
kr_activeGroups.value = groups;
|
||||
|
||||
@@ -650,6 +642,7 @@ class KRSingBoxImp {
|
||||
KRLogUtil.kr_i('✅ 活动组处理完成', tag: 'SingBox');
|
||||
},
|
||||
onError: (error) {
|
||||
print('[watchActiveGroups] ❌ 活动分组监听错误: $error');
|
||||
KRLogUtil.kr_e('❌ 活动分组监听错误: $error', tag: 'SingBox');
|
||||
},
|
||||
cancelOnError: false,
|
||||
@@ -659,14 +652,22 @@ class KRSingBoxImp {
|
||||
_kr_subscriptions.add(
|
||||
kr_singBox.watchGroups().listen(
|
||||
(groups) {
|
||||
print('[watchGroups] 📡 收到所有组更新,数量: ${groups.length}');
|
||||
kr_allGroups.value = groups;
|
||||
// 打印每个组的基本信息
|
||||
for (int i = 0; i < groups.length; i++) {
|
||||
final group = groups[i];
|
||||
print('[watchGroups] 组[$i]: tag=${group.tag}, type=${group.type}, selected=${group.selected}');
|
||||
}
|
||||
},
|
||||
onError: (error) {
|
||||
print('[watchGroups] ❌ 所有分组监听错误: $error');
|
||||
KRLogUtil.kr_e('所有分组监听错误: $error');
|
||||
},
|
||||
cancelOnError: false,
|
||||
),
|
||||
);
|
||||
print('[_kr_subscribeToGroups] ✅ 分组数据流订阅完成,当前订阅数: ${_kr_subscriptions.length}');
|
||||
}
|
||||
|
||||
/// 验证节点选择是否生效
|
||||
@@ -1128,7 +1129,7 @@ class KRSingBoxImp {
|
||||
|
||||
KRLogUtil.kr_i('✅ SingBox 核心已启动,开始初始化 command client', tag: 'SingBox');
|
||||
|
||||
// 🔑 在后台延迟订阅统计流,避免阻塞 UI
|
||||
// 🔑 在后台延迟订阅统计流和分组流,避免阻塞 UI
|
||||
Future.delayed(const Duration(milliseconds: 1000), () async {
|
||||
try {
|
||||
KRLogUtil.kr_i('📊 开始订阅统计数据流...', tag: 'SingBox');
|
||||
@@ -1147,6 +1148,24 @@ class KRSingBoxImp {
|
||||
});
|
||||
}
|
||||
|
||||
// 🔧 关键修复:订阅分组数据流
|
||||
try {
|
||||
KRLogUtil.kr_i('📋 开始订阅分组数据流...', tag: 'SingBox');
|
||||
_kr_subscribeToGroups();
|
||||
KRLogUtil.kr_i('✅ 分组数据流订阅成功', tag: 'SingBox');
|
||||
} catch (e) {
|
||||
KRLogUtil.kr_w('⚠️ 分组数据流订阅失败(稍后重试): $e', tag: 'SingBox');
|
||||
// 如果第一次失败,再等待一段时间重试
|
||||
Future.delayed(const Duration(milliseconds: 2000), () {
|
||||
try {
|
||||
_kr_subscribeToGroups();
|
||||
KRLogUtil.kr_i('✅ 分组数据流重试订阅成功', tag: 'SingBox');
|
||||
} catch (e2) {
|
||||
KRLogUtil.kr_e('❌ 分组数据流重试订阅失败: $e2', tag: 'SingBox');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 🔧 关键修复:恢复用户选择的节点
|
||||
try {
|
||||
final selectedNode = await KRSecureStorage().kr_readData(key: _keySelectedNode);
|
||||
|
||||
Reference in New Issue
Block a user