diff --git a/clashN/clashN/Forms/OptionSettingForm.cs b/clashN/clashN/Forms/OptionSettingForm.cs index 99a40d1..ca5e03c 100644 --- a/clashN/clashN/Forms/OptionSettingForm.cs +++ b/clashN/clashN/Forms/OptionSettingForm.cs @@ -198,8 +198,17 @@ namespace clashN.Forms } private void btnEditMixinContent_Click(object sender, EventArgs e) - { + { var address = Utils.GetPath(Global.mixinConfigFileName); + if (!File.Exists(address)) + { + string contents = Utils.GetEmbedText(Global.SampleMixin); + if (!Utils.IsNullOrEmpty(contents)) + { + File.WriteAllText(address, contents); + } + } + if (File.Exists(address)) { Utils.ProcessStart(address); diff --git a/clashN/clashN/Global.cs b/clashN/clashN/Global.cs index 1c69e6b..f3665c2 100644 --- a/clashN/clashN/Global.cs +++ b/clashN/clashN/Global.cs @@ -45,6 +45,9 @@ namespace clashN public const string mixinConfigFileName = "Mixin.yaml"; + public const string SampleMixin = "clashN.Sample.SampleMixin.yaml"; + public const string SampleTun = "clashN.Sample.SampleTun.yaml"; + public const string InboundSocks = "socks"; public const string InboundHttp = "http"; public const string Loopback = "127.0.0.1"; diff --git a/clashN/clashN/Handler/CoreConfigHandler.cs b/clashN/clashN/Handler/CoreConfigHandler.cs index db9b0b6..52faf23 100644 --- a/clashN/clashN/Handler/CoreConfigHandler.cs +++ b/clashN/clashN/Handler/CoreConfigHandler.cs @@ -16,8 +16,6 @@ namespace clashN.Handler /// class CoreConfigHandler { - private static string SampleTun = "clashN.Sample.SampleTun.yaml"; - /// /// 生成配置文件 /// @@ -116,7 +114,7 @@ namespace clashN.Handler //enable tun mode if (node.enableTun) { - string tun = Utils.GetEmbedText(SampleTun); + string tun = Utils.GetEmbedText(Global.SampleTun); if (!Utils.IsNullOrEmpty(tun)) { var tunContent = Utils.FromYaml>(tun); @@ -155,6 +153,12 @@ namespace clashN.Handler return; } + var path = Utils.GetPath(Global.mixinConfigFileName); + if (!File.Exists(path)) + { + return; + } + var txtFile = File.ReadAllText(Utils.GetPath(Global.mixinConfigFileName)); txtFile = txtFile.Replace("!", ""); diff --git a/clashN/clashN/Mixin.yaml b/clashN/clashN/Sample/SampleMixin.yaml similarity index 100% rename from clashN/clashN/Mixin.yaml rename to clashN/clashN/Sample/SampleMixin.yaml diff --git a/clashN/clashN/clashN.csproj b/clashN/clashN/clashN.csproj index 4661ced..a9f09f0 100644 --- a/clashN/clashN/clashN.csproj +++ b/clashN/clashN/clashN.csproj @@ -97,10 +97,8 @@ - - PreserveNewest - + @@ -122,7 +120,7 @@ - +