diff --git a/Consts/MainMultilangConst.Designer.cs b/Consts/MainMultilangConst.Designer.cs
index 1214bce..a3fb154 100644
--- a/Consts/MainMultilangConst.Designer.cs
+++ b/Consts/MainMultilangConst.Designer.cs
@@ -69,6 +69,15 @@ namespace Sheas_Cealer.Consts {
}
}
+ ///
+ /// 查找类似 The config cannot be recognized, check if the config contain syntax errors 的本地化字符串。
+ ///
+ public static string _ConfigErrorHint {
+ get {
+ return ResourceManager.GetString("_ConfigErrorHint", resourceCulture);
+ }
+ }
+
///
/// 查找类似 The args cannot be recognized, check if the hosts contain syntax errors 的本地化字符串。
///
@@ -187,20 +196,74 @@ namespace Sheas_Cealer.Consts {
}
///
- /// 查找类似 Start Proxy 的本地化字符串。
+ /// 查找类似 Stop Mihomo 的本地化字符串。
///
- public static string ProxyButtonContent {
+ public static string MihomoButtonIsRunningContent {
get {
- return ResourceManager.GetString("ProxyButtonContent", resourceCulture);
+ return ResourceManager.GetString("MihomoButtonIsRunningContent", resourceCulture);
}
}
///
- /// 查找类似 Click to launch a local proxy 的本地化字符串。
+ /// 查找类似 Click to stop the local Mihomo 的本地化字符串。
///
- public static string ProxyButtonToolTip {
+ public static string MihomoButtonIsRunningToolTip {
get {
- return ResourceManager.GetString("ProxyButtonToolTip", resourceCulture);
+ return ResourceManager.GetString("MihomoButtonIsRunningToolTip", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Start Mihomo 的本地化字符串。
+ ///
+ public static string MihomoButtonIsStoppedContent {
+ get {
+ return ResourceManager.GetString("MihomoButtonIsStoppedContent", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Click to launch a local Mihomo 的本地化字符串。
+ ///
+ public static string MihomoButtonIsStoppedToolTip {
+ get {
+ return ResourceManager.GetString("MihomoButtonIsStoppedToolTip", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Stop Nginx 的本地化字符串。
+ ///
+ public static string NginxButtonIsRunningContent {
+ get {
+ return ResourceManager.GetString("NginxButtonIsRunningContent", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Click to stop the local Nginx 的本地化字符串。
+ ///
+ public static string NginxButtonIsRunningToolTip {
+ get {
+ return ResourceManager.GetString("NginxButtonIsRunningToolTip", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Start Nginx 的本地化字符串。
+ ///
+ public static string NginxButtonIsStoppedContent {
+ get {
+ return ResourceManager.GetString("NginxButtonIsStoppedContent", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Click to launch a local Nginx 的本地化字符串。
+ ///
+ public static string NginxButtonIsStoppedToolTip {
+ get {
+ return ResourceManager.GetString("NginxButtonIsStoppedToolTip", resourceCulture);
}
}
diff --git a/Consts/MainMultilangConst.resx b/Consts/MainMultilangConst.resx
index a2f702b..61142b7 100644
--- a/Consts/MainMultilangConst.resx
+++ b/Consts/MainMultilangConst.resx
@@ -141,11 +141,29 @@
Extra Args
-
- Start Proxy
+
+ Stop Mihomo
-
- Click to launch a local proxy
+
+ Click to stop the local Mihomo
+
+
+ Start Mihomo
+
+
+ Click to launch a local Mihomo
+
+
+ Stop Nginx
+
+
+ Click to stop the local Nginx
+
+
+ Start Nginx
+
+
+ Click to launch a local Nginx
Fill in a Chromium-based browser path
@@ -201,6 +219,9 @@
Browser
+
+ The config cannot be recognized, check if the config contain syntax errors
+
The args cannot be recognized, check if the hosts contain syntax errors
diff --git a/Consts/MainMultilangConst.zh.resx b/Consts/MainMultilangConst.zh.resx
index da56feb..201732d 100644
--- a/Consts/MainMultilangConst.zh.resx
+++ b/Consts/MainMultilangConst.zh.resx
@@ -141,11 +141,29 @@
额外参数
-
- 启动代理
+
+ 停止 Mihomo
-
- 点击启动本地代理
+
+ 点击停止本地 Mihomo
+
+
+ 启动 Mihomo
+
+
+ 点击启动本地 Mihomo
+
+
+ 停止 Nginx
+
+
+ 点击停止 Nginx
+
+
+ 启动 Nginx
+
+
+ 点击启动本地 Nginx
填入任意以 Chromium 为内核的浏览器路径
@@ -201,6 +219,9 @@
浏览器
+
+ 配置无法识别,请检查配置文件中是否含有语法错误
+
规则无法识别,请检查伪造规则中是否含有语法错误
diff --git a/Convs/MainMihomoButtonContentConv.cs b/Convs/MainMihomoButtonContentConv.cs
new file mode 100644
index 0000000..7450c3b
--- /dev/null
+++ b/Convs/MainMihomoButtonContentConv.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using Sheas_Cealer.Consts;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainMihomoButtonContentConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isMihomoRunning = (bool)value;
+
+ return isMihomoRunning ? MainConst.MihomoButtonIsRunningContent : MainConst.MihomoButtonIsStoppedContent;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainMihomoButtonIsEnabledConv.cs b/Convs/MainMihomoButtonIsEnabledConv.cs
new file mode 100644
index 0000000..66f35c9
--- /dev/null
+++ b/Convs/MainMihomoButtonIsEnabledConv.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainMihomoButtonIsEnabledConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isMihomoExist = (bool)value;
+
+ return isMihomoExist;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainMihomoButtonToolTipConv.cs b/Convs/MainMihomoButtonToolTipConv.cs
new file mode 100644
index 0000000..647bc0a
--- /dev/null
+++ b/Convs/MainMihomoButtonToolTipConv.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using Sheas_Cealer.Consts;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainMihomoButtonToolTipConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isMihomoRunning = (bool)value;
+
+ return isMihomoRunning ? MainConst.MihomoButtonIsRunningToolTip : MainConst.MihomoButtonIsStoppedToolTip;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainNginxButtonContentConv.cs b/Convs/MainNginxButtonContentConv.cs
new file mode 100644
index 0000000..2865782
--- /dev/null
+++ b/Convs/MainNginxButtonContentConv.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using Sheas_Cealer.Consts;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainNginxButtonContentConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isNginxRunning = (bool)value;
+
+ return isNginxRunning ? MainConst.NginxButtonIsRunningContent : MainConst.NginxButtonIsStoppedContent;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainNginxButtonIsEnabledConv.cs b/Convs/MainNginxButtonIsEnabledConv.cs
new file mode 100644
index 0000000..95c54a9
--- /dev/null
+++ b/Convs/MainNginxButtonIsEnabledConv.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainNginxButtonIsEnabledConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isNginxExist = (bool)value;
+
+ return isNginxExist;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainNginxButtonToolTipConv.cs b/Convs/MainNginxButtonToolTipConv.cs
new file mode 100644
index 0000000..a9633d7
--- /dev/null
+++ b/Convs/MainNginxButtonToolTipConv.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using Sheas_Cealer.Consts;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainNginxButtonToolTipConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isNginxRunning = (bool)value;
+
+ return isNginxRunning ? MainConst.NginxButtonIsRunningToolTip : MainConst.NginxButtonIsStoppedToolTip;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainProxyButtonVisibilityConv.cs b/Convs/MainProxyButtonVisibilityConv.cs
new file mode 100644
index 0000000..b316392
--- /dev/null
+++ b/Convs/MainProxyButtonVisibilityConv.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainProxyButtonVisibilityConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isAdmin = (bool)value;
+
+ return isAdmin ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Convs/MainProxyColumnWidthConv.cs b/Convs/MainProxyColumnWidthConv.cs
new file mode 100644
index 0000000..8be6321
--- /dev/null
+++ b/Convs/MainProxyColumnWidthConv.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Sheas_Cealer.Convs;
+
+internal class MainProxyColumnWidthConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isAdmin = (bool)value;
+
+ return new GridLength(1, isAdmin ? GridUnitType.Star : GridUnitType.Auto);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Preses/MainPres.cs b/Preses/MainPres.cs
index 84bc5b1..def4c12 100644
--- a/Preses/MainPres.cs
+++ b/Preses/MainPres.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.IO;
using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignThemes.Wpf;
@@ -19,9 +20,9 @@ internal partial class MainPres : ObservableObject
BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
- (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe", string.Empty, null) ??
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe", string.Empty, null) ??
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\brave.exe", string.Empty, null) ??
+ (Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe")?.GetValue(string.Empty, null) ??
+ Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe")?.GetValue(string.Empty, null) ??
+ Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\brave.exe")?.GetValue(string.Empty, null) ??
string.Empty).ToString()!;
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
@@ -36,17 +37,6 @@ internal partial class MainPres : ObservableObject
[ObservableProperty]
private MainConst.SettingsMode settingsMode;
- [ObservableProperty]
- private bool? isLightTheme = null;
- partial void OnIsLightThemeChanged(bool? value)
- {
- PaletteHelper paletteHelper = new();
- Theme newTheme = paletteHelper.GetTheme();
-
- newTheme.SetBaseTheme(value.HasValue ? value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
- paletteHelper.SetTheme(newTheme);
- }
-
[ObservableProperty]
private string browserPath;
partial void OnBrowserPathChanged(string value)
@@ -79,4 +69,27 @@ internal partial class MainPres : ObservableObject
Settings.Default.Save();
}
}
+
+ [ObservableProperty]
+ private bool? isLightTheme = null;
+ partial void OnIsLightThemeChanged(bool? value)
+ {
+ PaletteHelper paletteHelper = new();
+ Theme newTheme = paletteHelper.GetTheme();
+
+ newTheme.SetBaseTheme(value.HasValue ? value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
+ paletteHelper.SetTheme(newTheme);
+ }
+
+ [ObservableProperty]
+ private bool isNginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Nginx.exe"));
+
+ [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 isMihomoRunning = Process.GetProcessesByName("Cealing-Mihomo").Length != 0;
}
\ No newline at end of file
diff --git a/Sheas-Cealer.csproj b/Sheas-Cealer.csproj
index a0db81e..bc28f12 100644
--- a/Sheas-Cealer.csproj
+++ b/Sheas-Cealer.csproj
@@ -76,6 +76,7 @@
+
diff --git a/Utils/MihomoProc.cs b/Utils/MihomoProc.cs
new file mode 100644
index 0000000..3000500
--- /dev/null
+++ b/Utils/MihomoProc.cs
@@ -0,0 +1,8 @@
+using SheasCore;
+
+namespace Sheas_Cealer.Utils;
+
+internal class MihomoProc : Proc
+{
+ internal MihomoProc() : base("Cealing-Mihomo.exe") { }
+}
\ No newline at end of file
diff --git a/Utils/NginxProc.cs b/Utils/NginxProc.cs
new file mode 100644
index 0000000..955b73e
--- /dev/null
+++ b/Utils/NginxProc.cs
@@ -0,0 +1,8 @@
+using SheasCore;
+
+namespace Sheas_Cealer.Utils;
+
+internal class NginxProc : Proc
+{
+ internal NginxProc() : base("Cealing-Nginx.exe") { }
+}
\ No newline at end of file
diff --git a/Wins/MainWin.xaml b/Wins/MainWin.xaml
index c9b80df..4363c02 100644
--- a/Wins/MainWin.xaml
+++ b/Wins/MainWin.xaml
@@ -79,7 +79,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
diff --git a/Wins/MainWin.xaml.cs b/Wins/MainWin.xaml.cs
index 709a321..416a52a 100644
--- a/Wins/MainWin.xaml.cs
+++ b/Wins/MainWin.xaml.cs
@@ -15,6 +15,7 @@ using OnaCore;
using Sheas_Cealer.Consts;
using Sheas_Cealer.Preses;
using Sheas_Cealer.Utils;
+using YamlDotNet.RepresentationModel;
using File = System.IO.File;
namespace Sheas_Cealer.Wins;
@@ -24,6 +25,7 @@ public partial class MainWin : Window
private static MainPres? MainPres;
private static readonly HttpClient MainClient = new();
private static DispatcherTimer? HoldButtonTimer;
+ private static readonly DispatcherTimer ProxyTimer = new() { Interval = TimeSpan.FromSeconds(0.1) };
private static readonly FileSystemWatcher HostWatcher = new(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-*.json") { EnableRaisingEvents = true, NotifyFilter = NotifyFilters.LastWrite };
private static readonly Dictionary CealArgsFragments = [];
private static string CealArgs = string.Empty;
@@ -34,8 +36,10 @@ public partial class MainWin : Window
DataContext = MainPres = new(args);
- HostWatcher.Changed += HostWatcher_Changed;
+ ProxyTimer.Tick += ProxyTimer_Tick;
+ ProxyTimer.Start();
+ HostWatcher.Changed += HostWatcher_Changed;
foreach (string hostPath in Directory.GetFiles(HostWatcher.Path, HostWatcher.Filter))
HostWatcher_Changed(null!, new(new(), Path.GetDirectoryName(hostPath)!, Path.GetFileName(hostPath)));
}
@@ -132,8 +136,69 @@ public partial class MainWin : Window
new CommandProc(sender == null).ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, ($"{CealArgs} {MainPres!.ExtraArgs}").Trim());
}
- private void ProxyButton_Click(object sender, RoutedEventArgs e)
+ private void NginxButton_Click(object sender, RoutedEventArgs e)
{
+ string configPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "nginx.conf");
+ string logsPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "logs");
+ string tempPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "temp");
+
+ if (!MainPres!.IsNginxRunning)
+ {
+ if (!File.Exists(configPath))
+ File.Create(configPath).Dispose();
+ if (!Directory.Exists(logsPath))
+ Directory.CreateDirectory(logsPath);
+ if (!Directory.Exists(tempPath))
+ Directory.CreateDirectory(tempPath);
+
+ new NginxProc().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"-c nginx.conf");
+ }
+ else
+ {
+ foreach (Process mihomoProcess in Process.GetProcessesByName("Cealing-Nginx"))
+ {
+ mihomoProcess.Kill();
+ mihomoProcess.WaitForExit();
+ }
+ }
+ }
+ private void MihomoButton_Click(object sender, RoutedEventArgs e)
+ {
+ RegistryKey proxyKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true)!;
+ string configPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "config.yaml");
+
+ if (!MainPres!.IsMihomoRunning)
+ {
+ YamlStream configStream = [];
+ YamlMappingNode configMapNode;
+ YamlNode mihomoPortNode;
+
+ if (!File.Exists(configPath))
+ File.Create(configPath).Dispose();
+
+ configStream.Load(File.OpenText(configPath));
+
+ try { configMapNode = (YamlMappingNode)configStream.Documents[0].RootNode; }
+ catch { throw new Exception(MainConst._ConfigErrorHint); }
+
+ if (!configMapNode.Children.TryGetValue("mixed-port", out mihomoPortNode!) && !configMapNode.Children.TryGetValue("port", out mihomoPortNode!))
+ mihomoPortNode = "7890";
+
+ proxyKey.SetValue("ProxyEnable", 1);
+ proxyKey.SetValue("ProxyServer", "127.0.0.1:" + mihomoPortNode);
+
+ new MihomoProc().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "-d .");
+ }
+ else
+ {
+ proxyKey.SetValue("ProxyEnable", 0);
+
+ foreach (Process mihomoProcess in Process.GetProcessesByName("Cealing-Mihomo"))
+ {
+ mihomoProcess.Kill();
+ mihomoProcess.WaitForExit();
+ }
+ }
}
private void EditHostButton_Click(object sender, RoutedEventArgs e)
@@ -150,34 +215,40 @@ public partial class MainWin : Window
}
private async void UpdateUpstreamHostButton_Click(object sender, RoutedEventArgs e)
{
- string upstreamHostUrl = (MainPres!.UpstreamUrl.StartsWith("http://") || MainPres!.UpstreamUrl.StartsWith("https://") ? string.Empty : "https://") + MainPres!.UpstreamUrl;
- string upstreamHostString = await Http.GetAsync(upstreamHostUrl, MainClient);
- string localHostPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-Upstream.json");
- string localHostString;
+ string newUpstreamHostUrl = (MainPres!.UpstreamUrl.StartsWith("http://") || MainPres!.UpstreamUrl.StartsWith("https://") ? string.Empty : "https://") + MainPres!.UpstreamUrl;
+ string newUpstreamHostString = await Http.GetAsync(newUpstreamHostUrl, MainClient);
+ string oldUpstreamHostPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-Upstream.json");
+ string oldUpstreamHostString;
- if (!File.Exists(localHostPath))
- File.Create(localHostPath).Dispose();
+ if (!File.Exists(oldUpstreamHostPath))
+ File.Create(oldUpstreamHostPath).Dispose();
- using (StreamReader localHostStreamReader = new(localHostPath))
- localHostString = localHostStreamReader.ReadToEnd();
+ oldUpstreamHostString = File.ReadAllText(oldUpstreamHostPath);
- if (localHostString.Replace("\r", string.Empty) == upstreamHostString)
+ if (oldUpstreamHostString.Replace("\r", string.Empty) == newUpstreamHostString)
MessageBox.Show(MainConst._UpstreamHostUtdHint);
else
{
MessageBoxResult overrideOptionResult = MessageBox.Show(MainConst._OverrideUpstreamHostPrompt, string.Empty, MessageBoxButton.YesNoCancel);
if (overrideOptionResult == MessageBoxResult.Yes)
{
- File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-Upstream.json"), upstreamHostString);
+ File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-Upstream.json"), newUpstreamHostString);
MessageBox.Show(MainConst._UpdateUpstreamHostSuccessHint);
}
else if (overrideOptionResult == MessageBoxResult.No)
- Process.Start(new ProcessStartInfo(upstreamHostUrl) { UseShellExecute = true });
+ Process.Start(new ProcessStartInfo(newUpstreamHostUrl) { UseShellExecute = true });
}
}
private void ThemesButton_Click(object sender, RoutedEventArgs e) => MainPres!.IsLightTheme = MainPres.IsLightTheme.HasValue ? MainPres.IsLightTheme.Value ? null : true : false;
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog();
+ private void ProxyTimer_Tick(object? sender, EventArgs e)
+ {
+ MainPres!.IsNginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Nginx.exe"));
+ MainPres.IsNginxRunning = Process.GetProcessesByName("Cealing-Nginx").Length != 0;
+ MainPres.IsMihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Mihomo.exe"));
+ MainPres.IsMihomoRunning = Process.GetProcessesByName("Cealing-Mihomo").Length != 0;
+ }
private void HostWatcher_Changed(object sender, FileSystemEventArgs e)
{
string hostName = e.Name!.TrimStart("Cealing-Host-".ToCharArray()).TrimEnd(".json".ToCharArray());