From 8a29e147d34c776328c8151cf2df7b74eee02705 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 10 Feb 2025 20:04:47 +0800 Subject: [PATCH] Added Enable Mixin parameter --- .../CoreConfig/CoreConfigClashService.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs index 8867dce3..386e28fa 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs @@ -128,7 +128,7 @@ namespace ServiceLib.Services.CoreConfig //Mixin try { - MixinContent(fileContent, node); + await MixinContent(fileContent, node); } catch (Exception ex) { @@ -158,20 +158,21 @@ namespace ServiceLib.Services.CoreConfig } } - private void MixinContent(Dictionary fileContent, ProfileItem node) + private async Task MixinContent(Dictionary fileContent, ProfileItem node) { - //if (!_config.clashUIItem.enableMixinContent) - //{ - // return; - //} - - var path = Utils.GetConfigPath(Global.ClashMixinConfigFileName); - if (!File.Exists(path)) + if (!_config.ClashUIItem.EnableMixinContent) { return; } - var txtFile = File.ReadAllText(Utils.GetConfigPath(Global.ClashMixinConfigFileName)); + var path = Utils.GetConfigPath(Global.ClashMixinConfigFileName); + if (!File.Exists(path)) + { + var mixin = EmbedUtils.GetEmbedText(Global.ClashMixinYaml); + await File.AppendAllTextAsync(path, mixin); + } + + var txtFile = await File.ReadAllTextAsync(Utils.GetConfigPath(Global.ClashMixinConfigFileName)); var mixinContent = YamlUtils.FromYaml>(txtFile); if (mixinContent == null) @@ -269,4 +270,4 @@ namespace ServiceLib.Services.CoreConfig } } } -} \ No newline at end of file +}