mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-14 13:22:07 +08:00
1.1.3 -> 1.1.4 第71次更新
This commit is contained in:
parent
bdf34249c6
commit
419ddd8fdb
@ -53,7 +53,7 @@ public partial class App : Application
|
|||||||
new SettingsPres().AccentForegroundColor = newAccentForegroundColor;
|
new SettingsPres().AccentForegroundColor = newAccentForegroundColor;
|
||||||
#endregion Foreground Color
|
#endregion Foreground Color
|
||||||
|
|
||||||
new MainWin(e.Args).Show();
|
new MainWin().Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
|
@ -11,9 +11,13 @@ namespace Sheas_Cealer.Preses;
|
|||||||
|
|
||||||
internal partial class MainPres : GlobalPres
|
internal partial class MainPres : GlobalPres
|
||||||
{
|
{
|
||||||
internal MainPres(string[] args)
|
internal MainPres()
|
||||||
{
|
{
|
||||||
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
int browserPathIndex = Array.FindIndex(args, arg => arg.Equals("-b", StringComparison.OrdinalIgnoreCase)) + 1;
|
int browserPathIndex = Array.FindIndex(args, arg => arg.Equals("-b", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||||
|
int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||||
|
int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||||
|
|
||||||
BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
|
BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
|
||||||
!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
|
!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
|
||||||
@ -22,14 +26,10 @@ internal partial class MainPres : GlobalPres
|
|||||||
Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||||
string.Empty).ToString()!;
|
string.Empty).ToString()!;
|
||||||
|
|
||||||
int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
|
|
||||||
|
|
||||||
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
|
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
|
||||||
!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :
|
!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :
|
||||||
args[upstreamUrlIndex];
|
args[upstreamUrlIndex];
|
||||||
|
|
||||||
int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;
|
|
||||||
|
|
||||||
ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
|
ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
|
||||||
!string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty :
|
!string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty :
|
||||||
args[extraArgsIndex];
|
args[extraArgsIndex];
|
||||||
|
@ -55,11 +55,13 @@ public partial class MainWin : Window
|
|||||||
private int GameClickTime = 0;
|
private int GameClickTime = 0;
|
||||||
private int GameFlashInterval = 1000;
|
private int GameFlashInterval = 1000;
|
||||||
|
|
||||||
internal MainWin(string[] args)
|
private bool IsSilent = false;
|
||||||
|
|
||||||
|
internal MainWin()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
DataContext = MainPres = new(args);
|
DataContext = MainPres = new();
|
||||||
}
|
}
|
||||||
private void MainWin_SourceInitialized(object sender, EventArgs e)
|
private void MainWin_SourceInitialized(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -85,6 +87,19 @@ public partial class MainWin : Window
|
|||||||
if (!MainPres.IsNginxRunning)
|
if (!MainPres.IsNginxRunning)
|
||||||
NginxCleaner.Clean();
|
NginxCleaner.Clean();
|
||||||
|
|
||||||
|
IsSilent = true;
|
||||||
|
|
||||||
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
|
if (MainConst.IsAdmin && MainPres.IsMihomoExist && Array.Exists(args, arg => arg.Equals("-m", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
MihomoButton_Click(null!, null!);
|
||||||
|
if (MainConst.IsAdmin && MainPres.IsNginxExist && Array.Exists(args, arg => arg.Equals("-n", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
NginxButton_Click(null!, null!);
|
||||||
|
if (Array.Exists(args, arg => arg.Equals("-s", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
StartButton_Click(null!, null!);
|
||||||
|
|
||||||
|
IsSilent = false;
|
||||||
|
|
||||||
UpdateUpstreamHostButton_Click(null!, null!);
|
UpdateUpstreamHostButton_Click(null!, null!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -161,7 +176,7 @@ public partial class MainWin : Window
|
|||||||
HoldButtonTimer?.Stop();
|
HoldButtonTimer?.Stop();
|
||||||
|
|
||||||
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
(!IsSilent && MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath)))
|
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath)))
|
||||||
@ -195,7 +210,7 @@ public partial class MainWin : Window
|
|||||||
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(NginxHttpsPort != 443 && MessageBox.Show(string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(NginxHttpsPort != 443 && MessageBox.Show(string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(NginxHttpPort != 80 && MessageBox.Show(string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(NginxHttpPort != 80 && MessageBox.Show(string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(!IsSilent && MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(MainPres.IsFlashing && MessageBox.Show(MainConst._LaunchNginxFlashingPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
(MainPres.IsFlashing && MessageBox.Show(MainConst._LaunchNginxFlashingPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -326,7 +341,7 @@ public partial class MainWin : Window
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(MihomoConfs))
|
if (string.IsNullOrWhiteSpace(MihomoConfs))
|
||||||
throw new Exception(MainConst._MihomoConfErrorMsg);
|
throw new Exception(MainConst._MihomoConfErrorMsg);
|
||||||
if (MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
if (!IsSilent && MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!File.Exists(MainConst.MihomoConfPath))
|
if (!File.Exists(MainConst.MihomoConfPath))
|
||||||
|
Loading…
Reference in New Issue
Block a user