修正切换订阅计划多节点列表展示问题
This commit is contained in:
parent
f1a8dfe4e7
commit
6936fab392
@ -1044,6 +1044,8 @@ class AppConfig {
|
||||
return "${KRProtocol.kr_https}://${KRDomain.kr_api}";
|
||||
}
|
||||
|
||||
/// ⚠️ 已遗弃:WebSocket 连接不再使用
|
||||
@Deprecated('wsBaseUrl has been deprecated')
|
||||
String get wsBaseUrl {
|
||||
if (kDebugMode) {
|
||||
return "ws://192.168.0.113";
|
||||
|
||||
@ -258,26 +258,11 @@ class KRAppRunData {
|
||||
}
|
||||
|
||||
/// 建立 Socket 连接
|
||||
/// ⚠️ 已遗弃:wsBaseUrl 不再使用
|
||||
Future<void> _kr_connectSocket(String userId) async {
|
||||
// 如果已存在连接,先断开
|
||||
await _kr_disconnectSocket();
|
||||
|
||||
final deviceId = KRDeviceInfoService().deviceId ?? 'unknown';
|
||||
KRLogUtil.kr_i('设备ID: $deviceId', tag: 'AppRunData');
|
||||
KrSocketService.instance.kr_init(
|
||||
baseUrl: AppConfig.getInstance().wsBaseUrl,
|
||||
userId: userId,
|
||||
deviceNumber: deviceId,
|
||||
token: kr_token ?? "",
|
||||
);
|
||||
|
||||
// 设置消息处理回调
|
||||
KrSocketService.instance.setOnMessageCallback(_kr_handleMessage);
|
||||
// 设置连接状态回调
|
||||
KrSocketService.instance.setOnConnectionStateCallback(_kr_handleConnectionState);
|
||||
|
||||
// 建立连接
|
||||
KrSocketService.instance.connect();
|
||||
// 已遗弃,不再建立 Socket 连接
|
||||
KRLogUtil.kr_i('Socket 连接已遗弃', tag: 'AppRunData');
|
||||
// 如果需要实时消息,使用其他实现方式
|
||||
}
|
||||
|
||||
/// 处理接收到的消息
|
||||
|
||||
@ -26,12 +26,33 @@ class KRNodeList {
|
||||
return const KRNodeList(list: []);
|
||||
}
|
||||
|
||||
// 获取第一个订阅对象
|
||||
final subscribeData = listData[0] as Map<String, dynamic>;
|
||||
// 尝试找到与请求参数 id 匹配的订阅项
|
||||
// 如果 json 中有 subscribeId,则查找匹配项;否则使用第一个
|
||||
Map<String, dynamic>? subscribeData;
|
||||
|
||||
final String? requestSubscribeId = json['subscribeId']?.toString();
|
||||
if (requestSubscribeId != null && requestSubscribeId.isNotEmpty) {
|
||||
// 查找 id 匹配的订阅项
|
||||
try {
|
||||
subscribeData = listData.firstWhere(
|
||||
(item) => (item as Map<String, dynamic>)['id']?.toString() == requestSubscribeId,
|
||||
orElse: () => listData[0] as Map<String, dynamic>
|
||||
) as Map<String, dynamic>;
|
||||
KRLogUtil.kr_i('✅ 找到匹配的订阅项: id=$requestSubscribeId', tag: 'NodeList');
|
||||
} catch (e) {
|
||||
KRLogUtil.kr_w('⚠️ 未找到匹配的订阅项,使用第一个', tag: 'NodeList');
|
||||
subscribeData = listData[0] as Map<String, dynamic>;
|
||||
}
|
||||
} else {
|
||||
// 如果没有提供 subscribeId,使用第一个
|
||||
subscribeData = listData[0] as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
final bool isTryOut = subscribeData['is_try_out'] as bool? ?? false;
|
||||
final List<dynamic>? nodesData = subscribeData['nodes'] as List<dynamic>?;
|
||||
|
||||
KRLogUtil.kr_i('节点列表解析: is_try_out=$isTryOut, 节点数=${nodesData?.length ?? 0}', tag: 'NodeList');
|
||||
KRLogUtil.kr_i('🔍 节点列表解析: subscribe_id=${subscribeData['id']}, is_try_out=$isTryOut, 节点数=${nodesData?.length ?? 0}', tag: 'NodeList');
|
||||
KRLogUtil.kr_i('📊 所有订阅项数量: ${listData.length}', tag: 'NodeList');
|
||||
|
||||
return KRNodeList(
|
||||
list: nodesData?.map((e) => KrNodeListItem.fromJson(e as Map<String, dynamic>)).toList() ?? [],
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:kaer_with_panels/app/model/response/kr_package_list.dart';
|
||||
import 'package:kaer_with_panels/app/network/base_response.dart';
|
||||
import 'package:kaer_with_panels/app/network/http_error.dart';
|
||||
import 'package:kaer_with_panels/app/network/http_util.dart';
|
||||
import 'package:kaer_with_panels/app/utils/kr_log_util.dart';
|
||||
|
||||
import '../../model/response/kr_already_subscribe.dart';
|
||||
import '../../model/response/kr_node_group_list.dart';
|
||||
@ -55,7 +56,24 @@ class KRSubscribeApi {
|
||||
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
|
||||
}
|
||||
|
||||
return right(baseResponse.model);
|
||||
// 将请求的 subscribeId 传入节点列表模型中
|
||||
final nodeList = baseResponse.model;
|
||||
|
||||
// 将请求ID添加到模型中用于查找匹配的订阅项
|
||||
// 使用 body 字段重新解析,以便能够找到正确的订阅项
|
||||
if (baseResponse.body.isNotEmpty && baseResponse.body.containsKey('list')) {
|
||||
try {
|
||||
// 添加订阅ID信息到解析参数中
|
||||
baseResponse.body['subscribeId'] = id.toString();
|
||||
final reparsed = KRNodeList.fromJson(baseResponse.body);
|
||||
return right(reparsed);
|
||||
} catch (e) {
|
||||
// 如果重新解析失败,使用原始模型
|
||||
KRLogUtil.kr_w('重新解析节点列表失败: $e,使用原始模型', tag: 'SubscribeApi');
|
||||
}
|
||||
}
|
||||
|
||||
return right(nodeList);
|
||||
}
|
||||
|
||||
/// 获取用户可用订阅
|
||||
|
||||
@ -230,11 +230,10 @@ class KRSingBoxImp {
|
||||
"log-level": "warn",
|
||||
"resolve-destination": false,
|
||||
"ipv6-mode": "ipv4_only",
|
||||
// "remote-dns-address": "https://cloudflare-dns.com/dns-query",
|
||||
"remote-dns-address": "udp://1.1.1.1",
|
||||
"remote-dns-domain-strategy": "",
|
||||
"direct-dns-address": "223.5.5.5",
|
||||
"direct-dns-domain-strategy": "",
|
||||
"remote-dns-address": "udp://8.8.8.8",
|
||||
"remote-dns-domain-strategy": "prefer_ipv4",
|
||||
"direct-dns-address": "udp://1.1.1.1",
|
||||
"direct-dns-domain-strategy": "prefer_ipv4",
|
||||
"mixed-port": kr_port,
|
||||
"tproxy-port": kr_port,
|
||||
"local-dns-port": 36450,
|
||||
|
||||
@ -53,6 +53,25 @@ post_install do |installer|
|
||||
flutter_additional_macos_build_settings(target)
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings[deployment_target_key] = minimum_deployment_target
|
||||
|
||||
# 抑制第三方库的过时 API 警告
|
||||
config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = 'NO'
|
||||
config.build_settings['CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS'] = 'NO'
|
||||
config.build_settings['CLANG_WARN_DEPRECATED_DECLARATIONS'] = 'NO'
|
||||
config.build_settings['CLANG_WARN_NONFUNCTIONAL_PARAMETER'] = 'NO'
|
||||
config.build_settings['SWIFT_VERSION'] = '5.0'
|
||||
config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
|
||||
end
|
||||
end
|
||||
|
||||
# 针对特定包的警告抑制
|
||||
installer.pods_project.targets.each do |target|
|
||||
if ['webview_flutter_wkwebview', 'flutter_inappwebview_macos', 'SAMKeychain'].include?(target.name)
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings['SWIFT_SUPPRESS_WARNINGS'] = 'YES'
|
||||
config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = 'NO'
|
||||
config.build_settings['CLANG_WARN_DEPRECATED_DECLARATIONS'] = 'NO'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
2
macos/Podfile.lock
Executable file → Normal file
2
macos/Podfile.lock
Executable file → Normal file
@ -94,6 +94,6 @@ SPEC CHECKSUMS:
|
||||
webview_flutter_wkwebview: 1821ceac936eba6f7984d89a9f3bcb4dea99ebb2
|
||||
window_manager: 1d01fa7ac65a6e6f83b965471b1a7fdd3f06166c
|
||||
|
||||
PODFILE CHECKSUM: a18d1ba050af210055cfb0cee8d759913f9ff3e3
|
||||
PODFILE CHECKSUM: 04e3af9980f29522a03273385f61d561da92c2fb
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// 仅为项目代码启用严格警告,第三方库通过 Podfile 配置
|
||||
WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES
|
||||
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
|
||||
@ -11,3 +12,9 @@ CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
||||
GCC_WARN_SHADOW = YES
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||
|
||||
// 第三方库警告抑制
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO
|
||||
CLANG_WARN_DEPRECATED_DECLARATIONS = NO
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO
|
||||
SWIFT_SUPPRESS_WARNINGS = YES
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user