1.1.4 -> 0.0.1 第3次更新

This commit is contained in:
Space Time 2025-03-01 20:36:55 +08:00
parent 2149a24ca8
commit d33a08ea14
6 changed files with 43 additions and 42 deletions

View File

@ -70,7 +70,7 @@ public partial class App : Application
base.OnFrameworkInitializationCompleted(); base.OnFrameworkInitializationCompleted();
} }
private void DisableAvaloniaDataAnnotationValidation() private static void DisableAvaloniaDataAnnotationValidation()
{ {
// Get an array of plugins to remove // Get an array of plugins to remove
var dataValidationPluginsToRemove = BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray(); var dataValidationPluginsToRemove = BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();

View File

@ -10,7 +10,7 @@ internal class MainAdminControlVisibilityConv : IValueConverter
{ {
bool isAdmin = (bool)value; bool isAdmin = (bool)value;
return isAdmin ? true : false; return isAdmin;
} }
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();

View File

@ -13,26 +13,27 @@ internal partial class MainPres : GlobalPres
{ {
internal MainPres() internal MainPres()
{ {
//string[] args = Environment.GetCommandLineArgs(); 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 upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
//int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", 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 :
// (Registry.LocalMachine.OpenSubKey(MainConst.EdgeBrowserRegistryPath)?.GetValue(string.Empty, null) ?? OperatingSystem.IsWindows() ?
// Registry.LocalMachine.OpenSubKey(MainConst.ChromeBrowserRegistryPath)?.GetValue(string.Empty, null) ?? (Registry.LocalMachine.OpenSubKey(MainConst.EdgeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
// Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ?? Registry.LocalMachine.OpenSubKey(MainConst.ChromeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
// string.Empty).ToString()!; Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
string.Empty).ToString()! : string.Empty;
//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];
//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];
} }
[ObservableProperty] [ObservableProperty]

View File

@ -54,7 +54,7 @@ public partial class AboutWin : Window
Button senderButton = (Button)sender; Button senderButton = (Button)sender;
if (senderButton == VersionButton) if (senderButton == VersionButton)
await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{AboutConst._ReleasePagePasswordLabel} 3wnj").ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{AboutConst._ReleasePagePasswordLabel} 3wnj").ShowWindowDialogAsync(this);
ProcessStartInfo processStartInfo = new(senderButton == EmailButton ? "mailto:" : string.Empty + ToolTip.GetTip(senderButton)) { UseShellExecute = true }; ProcessStartInfo processStartInfo = new(senderButton == EmailButton ? "mailto:" : string.Empty + ToolTip.GetTip(senderButton)) { UseShellExecute = true };

View File

@ -148,7 +148,7 @@ public partial class MainWin : Window
IReadOnlyList<IStorageFile> browserFiles = await TopLevel.GetTopLevel(this)!.StorageProvider.OpenFilePickerAsync(new() { Title = MainConst._BrowserPathDialogFilterFileType, AllowMultiple = false }); //Todo: Filter IReadOnlyList<IStorageFile> browserFiles = await TopLevel.GetTopLevel(this)!.StorageProvider.OpenFilePickerAsync(new() { Title = MainConst._BrowserPathDialogFilterFileType, AllowMultiple = false }); //Todo: Filter
if (browserFiles.Count > 0) if (browserFiles.Count > 0)
MainPres.BrowserPath = browserFiles[0].Path.LocalPath; //Todo: Test Absolute Path MainPres.BrowserPath = browserFiles[0].Path.LocalPath;
return; return;
case MainConst.SettingsMode.UpstreamUrlMode: case MainConst.SettingsMode.UpstreamUrlMode:
@ -186,8 +186,8 @@ public partial class MainWin : Window
{ {
HoldButtonTimer?.Stop(); HoldButtonTimer?.Stop();
if ((CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) || if ((CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes) ||
(sender is not true && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._KillBrowserProcessPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes)) (sender is not true && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._KillBrowserProcessPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes))
return; return;
foreach (Process browserProcess in Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainPres.BrowserPath) : Path.GetFileName(MainPres.BrowserPath))) foreach (Process browserProcess in Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainPres.BrowserPath) : Path.GetFileName(MainPres.BrowserPath)))
@ -213,12 +213,12 @@ public partial class MainWin : Window
try try
{ {
if ((!MainPres.IsConginxExist && !MainPres.IsNginxExist) || if ((!MainPres.IsConginxExist && !MainPres.IsNginxExist) ||
(CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) || (CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes) ||
(NginxHttpsPort != 443 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) || (NginxHttpsPort != 443 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes) ||
(NginxHttpPort != 80 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) || (NginxHttpPort != 80 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes) ||
(sender != null && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchHostsNginxPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) || (sender != null && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchHostsNginxPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes) ||
(await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) || (await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes) ||
(MainPres.IsFlashing && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxFlashingPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes)) (MainPres.IsFlashing && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxFlashingPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes))
return; return;
if (!File.Exists(MainConst.NginxConfPath)) if (!File.Exists(MainConst.NginxConfPath))
@ -327,7 +327,7 @@ public partial class MainWin : Window
if (sender == null ? MainPres.IsConginxRunning : MainPres.IsNginxRunning) if (sender == null ? MainPres.IsConginxRunning : MainPres.IsNginxRunning)
continue; continue;
if (await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxErrorPrompt, ButtonEnum.YesNo).ShowAsync() == ButtonResult.Yes) if (await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxErrorPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) == ButtonResult.Yes)
Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true }); Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true });
break; break;
@ -391,7 +391,7 @@ public partial class MainWin : Window
return; return;
if (string.IsNullOrWhiteSpace(MihomoConfs)) if (string.IsNullOrWhiteSpace(MihomoConfs))
throw new(MainConst._MihomoConfErrorMsg); throw new(MainConst._MihomoConfErrorMsg);
if (!MainPres.IsConginxRunning && !MainPres.IsCoproxyStopping && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) if (!MainPres.IsConginxRunning && !MainPres.IsCoproxyStopping && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) != ButtonResult.Yes)
return; return;
if (!File.Exists(MainConst.MihomoConfPath)) if (!File.Exists(MainConst.MihomoConfPath))
@ -453,7 +453,7 @@ public partial class MainWin : Window
if (MainPres.IsComihomoExist ? MainPres.IsComihomoRunning : MainPres.IsMihomoRunning) if (MainPres.IsComihomoExist ? MainPres.IsComihomoRunning : MainPres.IsMihomoRunning)
continue; continue;
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchMihomoErrorMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchMihomoErrorMsg).ShowWindowDialogAsync(this);
break; break;
} }
@ -577,11 +577,11 @@ public partial class MainWin : Window
{ {
MainPres.IsUpstreamHostUtd = true; MainPres.IsUpstreamHostUtd = true;
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpstreamHostUtdMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpstreamHostUtdMsg).ShowWindowDialogAsync(this);
} }
else else
{ {
ButtonResult overrideOptionResult = await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._OverrideUpstreamHostPrompt, ButtonEnum.YesNoCancel).ShowAsync(); ButtonResult overrideOptionResult = await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._OverrideUpstreamHostPrompt, ButtonEnum.YesNoCancel).ShowWindowDialogAsync(this);
if (overrideOptionResult == ButtonResult.Yes) if (overrideOptionResult == ButtonResult.Yes)
{ {
@ -589,7 +589,7 @@ public partial class MainWin : Window
MainPres.IsUpstreamHostUtd = true; MainPres.IsUpstreamHostUtd = true;
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpdateUpstreamHostSuccessMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpdateUpstreamHostSuccessMsg).ShowWindowDialogAsync(this);
} }
else if (overrideOptionResult == ButtonResult.No) else if (overrideOptionResult == ButtonResult.No)
try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); } try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); }
@ -604,7 +604,7 @@ public partial class MainWin : Window
{ {
if (GameFlashInterval <= 10) if (GameFlashInterval <= 10)
{ {
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameReviewEndingMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameReviewEndingMsg).ShowWindowDialogAsync(this);
return; return;
} }
@ -612,19 +612,19 @@ public partial class MainWin : Window
switch (++GameClickTime) switch (++GameClickTime)
{ {
case 1: case 1:
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickOnceMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickOnceMsg).ShowWindowDialogAsync(this);
return; return;
case 2: case 2:
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickTwiceMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickTwiceMsg).ShowWindowDialogAsync(this);
return; return;
case 3: case 3:
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickThreeMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickThreeMsg).ShowWindowDialogAsync(this);
return; return;
} }
if (!MainPres.IsFlashing) if (!MainPres.IsFlashing)
{ {
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameStartMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameStartMsg).ShowWindowDialogAsync(this);
MainPres.IsFlashing = true; MainPres.IsFlashing = true;
NginxConfWatcher_Changed(null!, null!); NginxConfWatcher_Changed(null!, null!);
@ -662,7 +662,7 @@ public partial class MainWin : Window
MainPres.IsFlashing = false; MainPres.IsFlashing = false;
NginxConfWatcher_Changed(null!, null!); NginxConfWatcher_Changed(null!, null!);
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameEndingMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameEndingMsg).ShowWindowDialogAsync(this);
} }
else else
{ {
@ -680,7 +680,7 @@ public partial class MainWin : Window
} }
if (GameFlashInterval > 10) if (GameFlashInterval > 10)
await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{MainConst._GameGradeMsg} {GameFlashInterval}").ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{MainConst._GameGradeMsg} {GameFlashInterval}").ShowWindowDialogAsync(this);
} }
} }
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog(this); private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog(this);

View File

@ -28,7 +28,7 @@ public partial class SettingsWin : Window
{ {
SettingsPres.IsEnglishLang = SettingsPres.IsEnglishLang.HasValue ? SettingsPres.IsEnglishLang.Value ? null : true : false; SettingsPres.IsEnglishLang = SettingsPres.IsEnglishLang.HasValue ? SettingsPres.IsEnglishLang.Value ? null : true : false;
await MessageBoxManager.GetMessageBoxStandard(string.Empty, SettingsConst._ChangeLangSuccessMsg).ShowAsync(); await MessageBoxManager.GetMessageBoxStandard(string.Empty, SettingsConst._ChangeLangSuccessMsg).ShowWindowDialogAsync(this);
} }
private void ColorsButton_Click(object sender, RoutedEventArgs e) private void ColorsButton_Click(object sender, RoutedEventArgs e)
{ {