From 788b639c1f0ee9ebad4e7d026f81f35223df8707 Mon Sep 17 00:00:00 2001 From: Space Time Date: Sun, 6 Oct 2024 21:52:19 +0800 Subject: [PATCH] =?UTF-8?q?1.1.1=20->=201.1.2=20=E7=AC=AC42=E6=AC=A1?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Consts/MainMultilangConst.Designer.cs | 18 +++++++++ Consts/MainMultilangConst.resx | 6 +++ Consts/MainMultilangConst.zh.resx | 6 +++ Convs/MainMihomoButtonContentConv.cs | 12 +++--- Convs/MainNginxButtonContentConv.cs | 12 +++--- Convs/MainProxyButtonIsEnabledConv.cs | 18 +++++++++ Preses/MainPres.cs | 6 +++ Utils/MihomoProc.cs | 6 +-- Utils/NginxProc.cs | 7 ++++ Wins/MainWin.xaml | 50 +++++++++++++++++------ Wins/MainWin.xaml.cs | 58 ++++++++++----------------- 11 files changed, 134 insertions(+), 65 deletions(-) create mode 100644 Convs/MainProxyButtonIsEnabledConv.cs diff --git a/Consts/MainMultilangConst.Designer.cs b/Consts/MainMultilangConst.Designer.cs index 8ed26ba..29a2eef 100644 --- a/Consts/MainMultilangConst.Designer.cs +++ b/Consts/MainMultilangConst.Designer.cs @@ -321,6 +321,15 @@ namespace Sheas_Cealer.Consts { } } + /// + /// 查找类似 Global Purging is Initing 的本地化字符串。 + /// + public static string MihomoButtonIsInitingContent { + get { + return ResourceManager.GetString("MihomoButtonIsInitingContent", resourceCulture); + } + } + /// /// 查找类似 Stop Global Purging 的本地化字符串。 /// @@ -357,6 +366,15 @@ namespace Sheas_Cealer.Consts { } } + /// + /// 查找类似 Global Cealing is Initing 的本地化字符串。 + /// + public static string NginxButtonIsInitingContent { + get { + return ResourceManager.GetString("NginxButtonIsInitingContent", resourceCulture); + } + } + /// /// 查找类似 Stop Global Cealing 的本地化字符串。 /// diff --git a/Consts/MainMultilangConst.resx b/Consts/MainMultilangConst.resx index b065e58..9438a7b 100644 --- a/Consts/MainMultilangConst.resx +++ b/Consts/MainMultilangConst.resx @@ -159,6 +159,9 @@ Extra Args + + Global Purging is Initing + Stop Global Purging @@ -171,6 +174,9 @@ Click to launch a local Mihomo + + Global Cealing is Initing + Stop Global Cealing diff --git a/Consts/MainMultilangConst.zh.resx b/Consts/MainMultilangConst.zh.resx index 0f3a4be..9d70a1a 100644 --- a/Consts/MainMultilangConst.zh.resx +++ b/Consts/MainMultilangConst.zh.resx @@ -159,6 +159,9 @@ 额外参数 + + 全局净化启动中 + 停止全局净化 @@ -171,6 +174,9 @@ 点击启动本地 Mihomo + + 全局伪造启动中 + 停止全局伪造 diff --git a/Convs/MainMihomoButtonContentConv.cs b/Convs/MainMihomoButtonContentConv.cs index 7450c3b..ba47b91 100644 --- a/Convs/MainMihomoButtonContentConv.cs +++ b/Convs/MainMihomoButtonContentConv.cs @@ -5,14 +5,16 @@ using Sheas_Cealer.Consts; namespace Sheas_Cealer.Convs; -internal class MainMihomoButtonContentConv : IValueConverter +internal class MainMihomoButtonContentConv : IMultiValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - bool isMihomoRunning = (bool)value; + bool isMihomoRunning = (bool)values[0]; + bool isMihomoIniting = (bool)values[1]; - return isMihomoRunning ? MainConst.MihomoButtonIsRunningContent : MainConst.MihomoButtonIsStoppedContent; + return isMihomoIniting ? MainConst.MihomoButtonIsInitingContent : + isMihomoRunning ? MainConst.MihomoButtonIsRunningContent : MainConst.MihomoButtonIsStoppedContent; } - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); } \ No newline at end of file diff --git a/Convs/MainNginxButtonContentConv.cs b/Convs/MainNginxButtonContentConv.cs index 2865782..4b9b262 100644 --- a/Convs/MainNginxButtonContentConv.cs +++ b/Convs/MainNginxButtonContentConv.cs @@ -5,14 +5,16 @@ using Sheas_Cealer.Consts; namespace Sheas_Cealer.Convs; -internal class MainNginxButtonContentConv : IValueConverter +internal class MainNginxButtonContentConv : IMultiValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - bool isNginxRunning = (bool)value; + bool isNginxRunning = (bool)values[0]; + bool isNginxIniting = (bool)values[1]; - return isNginxRunning ? MainConst.NginxButtonIsRunningContent : MainConst.NginxButtonIsStoppedContent; + return isNginxIniting ? MainConst.NginxButtonIsInitingContent : + isNginxRunning ? MainConst.NginxButtonIsRunningContent : MainConst.NginxButtonIsStoppedContent; } - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); } \ No newline at end of file diff --git a/Convs/MainProxyButtonIsEnabledConv.cs b/Convs/MainProxyButtonIsEnabledConv.cs new file mode 100644 index 0000000..bcb28b1 --- /dev/null +++ b/Convs/MainProxyButtonIsEnabledConv.cs @@ -0,0 +1,18 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Sheas_Cealer.Convs; + +internal class MainProxyButtonIsEnabledConv : IMultiValueConverter +{ + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + bool isProxyExist = (bool)values[0]; + bool isProxyIniting = (bool)values[1]; + + return !isProxyIniting && isProxyExist; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); +} \ No newline at end of file diff --git a/Preses/MainPres.cs b/Preses/MainPres.cs index e7425a3..5a473cf 100644 --- a/Preses/MainPres.cs +++ b/Preses/MainPres.cs @@ -84,12 +84,18 @@ internal partial class MainPres : ObservableObject [ObservableProperty] private bool isNginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Nginx.exe")); + [ObservableProperty] + private bool isNginxIniting = false; + [ObservableProperty] private bool isNginxRunning = Process.GetProcessesByName("Cealing-Nginx").Length != 0; [ObservableProperty] private bool isMihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Mihomo.exe")); + [ObservableProperty] + private bool isMihomoIniting = false; + [ObservableProperty] private bool isMihomoRunning = Process.GetProcessesByName("Cealing-Mihomo").Length != 0; diff --git a/Utils/MihomoProc.cs b/Utils/MihomoProc.cs index b555e4e..3000500 100644 --- a/Utils/MihomoProc.cs +++ b/Utils/MihomoProc.cs @@ -1,12 +1,8 @@ -using System; -using Microsoft.Win32; -using SheasCore; +using SheasCore; namespace Sheas_Cealer.Utils; internal class MihomoProc : Proc { internal MihomoProc() : base("Cealing-Mihomo.exe") { } - - public override void Process_Exited(object sender, EventArgs e) => Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true)!.SetValue("ProxyEnable", 0); } \ No newline at end of file diff --git a/Utils/NginxProc.cs b/Utils/NginxProc.cs index 7412212..ed48055 100644 --- a/Utils/NginxProc.cs +++ b/Utils/NginxProc.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using Sheas_Cealer.Consts; using SheasCore; @@ -17,5 +18,11 @@ internal class NginxProc : Proc if (cealingNginxStartIndex != -1 && cealingNginxEndIndex != -1) File.WriteAllText(MainConst.HostsConfPath, hostsContent.Remove(cealingNginxStartIndex, cealingNginxEndIndex - cealingNginxStartIndex + "# Cealing Nginx End".Length)); + + using X509Store certStore = new(StoreName.Root, StoreLocation.CurrentUser, OpenFlags.ReadWrite); + + foreach (X509Certificate2 cert in certStore.Certificates) + if (cert.Subject == "CN=Cealing Cert Root") + certStore.Remove(cert); } } \ No newline at end of file diff --git a/Wins/MainWin.xaml b/Wins/MainWin.xaml index 52c949c..71ae840 100644 --- a/Wins/MainWin.xaml +++ b/Wins/MainWin.xaml @@ -18,7 +18,7 @@ - + @@ -123,8 +123,7 @@ - -