添加日志 调试
This commit is contained in:
parent
6d4a4ff6a3
commit
ae62457d8c
@ -90,7 +90,18 @@ class MethodHandler(private val scope: CoroutineScope) : FlutterPlugin,
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
result.runCatching {
|
result.runCatching {
|
||||||
val args = call.arguments as String
|
val args = call.arguments as String
|
||||||
|
|
||||||
|
// ✅ 添加日志
|
||||||
|
Log.d(TAG, "📍 changeHiddifyOptions 被调用")
|
||||||
|
Log.d(TAG, "⚙️ 接收到的配置长度: ${args.length}")
|
||||||
|
Log.d(TAG, "⚙️ 接收到的配置前500字符: ${args.substring(0, minOf(500, args.length))}")
|
||||||
|
|
||||||
Settings.configOptions = args
|
Settings.configOptions = args
|
||||||
|
|
||||||
|
// 验证保存
|
||||||
|
val saved = Settings.configOptions
|
||||||
|
Log.d(TAG, "✅ 配置已保存,验证长度: ${saved.length}")
|
||||||
|
|
||||||
success(true)
|
success(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,10 +113,23 @@ class MethodHandler(private val scope: CoroutineScope) : FlutterPlugin,
|
|||||||
val args = call.arguments as Map<*, *>
|
val args = call.arguments as Map<*, *>
|
||||||
val path = args["path"] as String
|
val path = args["path"] as String
|
||||||
val options = Settings.configOptions
|
val options = Settings.configOptions
|
||||||
|
|
||||||
|
// ✅ 添加详细日志
|
||||||
|
Log.d(TAG, "📍 GenerateConfig 被调用")
|
||||||
|
Log.d(TAG, "📁 配置文件路径: $path")
|
||||||
|
Log.d(TAG, "⚙️ configOptions 长度: ${options.length}")
|
||||||
|
Log.d(TAG, "⚙️ configOptions 内容: $options")
|
||||||
|
|
||||||
if (options.isBlank() || path.isBlank()) {
|
if (options.isBlank() || path.isBlank()) {
|
||||||
|
Log.e(TAG, "❌ 配置选项或路径为空!options.isBlank=${options.isBlank()}, path.isBlank=${path.isBlank()}")
|
||||||
error("blank properties")
|
error("blank properties")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.d(TAG, "🔧 开始调用 Mobile.buildConfig...")
|
||||||
val config = BoxService.buildConfig(path, options)
|
val config = BoxService.buildConfig(path, options)
|
||||||
|
Log.d(TAG, "✅ buildConfig 完成,配置长度: ${config.length}")
|
||||||
|
Log.d(TAG, "📄 生成的配置前500字符: ${config.substring(0, minOf(500, config.length))}")
|
||||||
|
|
||||||
success(config)
|
success(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -462,37 +462,13 @@ class KRSingBoxImp {
|
|||||||
final configFile = File(_cutPath);
|
final configFile = File(_cutPath);
|
||||||
if (await configFile.exists()) {
|
if (await configFile.exists()) {
|
||||||
final configContent = await configFile.readAsString();
|
final configContent = await configFile.readAsString();
|
||||||
KRLogUtil.kr_i('📄 基础配置文件内容长度: ${configContent.length}', tag: 'SingBox');
|
KRLogUtil.kr_i('📄 配置文件内容长度: ${configContent.length}', tag: 'SingBox');
|
||||||
KRLogUtil.kr_i('📄 基础配置文件前500字符: ${configContent.substring(0, configContent.length > 500 ? 500 : configContent.length)}', tag: 'SingBox');
|
KRLogUtil.kr_i('📄 配置文件前500字符: ${configContent.substring(0, configContent.length > 500 ? 500 : configContent.length)}', tag: 'SingBox');
|
||||||
} else {
|
} else {
|
||||||
KRLogUtil.kr_w('⚠️ 配置文件不存在: $_cutPath', tag: 'SingBox');
|
KRLogUtil.kr_w('⚠️ 配置文件不存在: $_cutPath', tag: 'SingBox');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ 关键修复:生成完整的 sing-box 配置
|
await kr_singBox.start(_cutPath, kr_configName, false).map(
|
||||||
KRLogUtil.kr_i('🔧 开始生成完整配置...', tag: 'SingBox');
|
|
||||||
|
|
||||||
final fullConfigResult = await kr_singBox.generateFullConfigByPath(_cutPath).run();
|
|
||||||
|
|
||||||
final String fullConfigJson = fullConfigResult.fold(
|
|
||||||
(error) {
|
|
||||||
KRLogUtil.kr_e('❌ 生成完整配置失败: $error', tag: 'SingBox');
|
|
||||||
throw Exception('生成完整配置失败: $error');
|
|
||||||
},
|
|
||||||
(config) {
|
|
||||||
KRLogUtil.kr_i('✅ 完整配置生成成功', tag: 'SingBox');
|
|
||||||
KRLogUtil.kr_i('📄 完整配置长度: ${config.length}', tag: 'SingBox');
|
|
||||||
KRLogUtil.kr_i('📄 完整配置前500字符: ${config.substring(0, config.length > 500 ? 500 : config.length)}', tag: 'SingBox');
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// 保存完整配置到临时文件
|
|
||||||
final fullConfigFile = File('${_cutPath}.full');
|
|
||||||
await fullConfigFile.writeAsString(fullConfigJson);
|
|
||||||
KRLogUtil.kr_i('💾 完整配置已保存到: ${fullConfigFile.path}', tag: 'SingBox');
|
|
||||||
|
|
||||||
// 使用完整配置文件启动服务
|
|
||||||
await kr_singBox.start(fullConfigFile.path, kr_configName, false).map(
|
|
||||||
(r) {
|
(r) {
|
||||||
KRLogUtil.kr_i('✅ SingBox 启动成功', tag: 'SingBox');
|
KRLogUtil.kr_i('✅ SingBox 启动成功', tag: 'SingBox');
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user