From bd2893affa131eaaea51f4bdcf3620a730eccd7e Mon Sep 17 00:00:00 2001 From: Space Time Date: Sun, 2 Mar 2025 12:12:35 +0800 Subject: [PATCH] =?UTF-8?q?1.1.4=20->=200.0.1=20=E7=AC=AC9=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 --- App.axaml.cs | 1 + Wins/AboutWin.axaml.cs | 30 +++++++++++++++++++----------- Wins/MainWin.axaml.cs | 19 +++++++++++++------ 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/App.axaml.cs b/App.axaml.cs index dd97a25..0a82e90 100644 --- a/App.axaml.cs +++ b/App.axaml.cs @@ -14,6 +14,7 @@ internal partial class App : Application public override void OnFrameworkInitializationCompleted() { + // Todo: Check x11-utils & xdg-utils environment for Linux. if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { #region Upgrade Settings diff --git a/Wins/AboutWin.axaml.cs b/Wins/AboutWin.axaml.cs index ed175a6..2d30d9e 100644 --- a/Wins/AboutWin.axaml.cs +++ b/Wins/AboutWin.axaml.cs @@ -49,21 +49,29 @@ public partial class AboutWin : Window }); } - private void AboutButton_Click(object sender, RoutedEventArgs e) + private async Task AboutButton_ClickAsync(object sender, RoutedEventArgs e) { - //Button senderButton = (Button)sender; + Button senderButton = (Button)sender; - //if (senderButton == VersionButton) - // await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{AboutConst._ReleasePagePasswordLabel} 3wnj").ShowWindowDialogAsync(this); + if (senderButton == VersionButton) + await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{AboutConst._ReleasePagePasswordLabel} 3wnj").ShowWindowDialogAsync(this); - //ProcessStartInfo processStartInfo = new(senderButton == EmailButton ? "mailto:" : string.Empty + ToolTip.GetTip(senderButton)) { UseShellExecute = true }; + string processStartUrl = senderButton == EmailButton ? "mailto:" : string.Empty + ToolTip.GetTip(senderButton); - //try { Process.Start(processStartInfo); } - //catch (UnauthorizedAccessException) - //{ - // processStartInfo.Verb = "RunAs"; - // Process.Start(processStartInfo); - //} + try + { + if (OperatingSystem.IsWindows()) + Process.Start(new ProcessStartInfo(processStartUrl) { UseShellExecute = true }); + else + Process.Start("xdg-open", processStartUrl); + } + catch (UnauthorizedAccessException) + { + if (OperatingSystem.IsWindows()) + Process.Start(new ProcessStartInfo(processStartUrl) { UseShellExecute = true, Verb = "RunAs" }); + else + Process.Start("sudo", $"xdg-open {processStartUrl}"); + } } private void AboutWin_KeyDown(object sender, KeyEventArgs e) diff --git a/Wins/MainWin.axaml.cs b/Wins/MainWin.axaml.cs index a3b775d..02978a5 100644 --- a/Wins/MainWin.axaml.cs +++ b/Wins/MainWin.axaml.cs @@ -331,7 +331,10 @@ public partial class MainWin : Window continue; if (await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxErrorPrompt, ButtonEnum.YesNo).ShowWindowDialogAsync(this) == ButtonResult.Yes) - Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true }); + if (OperatingSystem.IsWindows()) + Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true }); + else + Process.Start("xdg-open", MainConst.NginxErrorLogsPath); break; } @@ -532,8 +535,8 @@ public partial class MainWin : Window try { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true }); } catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true, Verb = "RunAs" }); } else - try { Process.Start("vi", cealHostPath); } - catch (UnauthorizedAccessException) { Process.Start("sudo", $"vi {cealHostPath}"); } + try { Process.Start("xdg-open", cealHostPath); } + catch (UnauthorizedAccessException) { Process.Start("sudo", $"xdg-open {cealHostPath}"); } } private async void EditConfButton_Click(object sender, RoutedEventArgs e) { @@ -557,7 +560,7 @@ public partial class MainWin : Window if (OperatingSystem.IsWindows()) Process.Start(new ProcessStartInfo(confPath) { UseShellExecute = true }); else - Process.Start("vi", confPath); + Process.Start("xdg-open", confPath); } private async void UpdateUpstreamHostButton_Click(object? sender, RoutedEventArgs e) { @@ -595,8 +598,12 @@ public partial class MainWin : Window await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpdateUpstreamHostSuccessMsg).ShowWindowDialogAsync(this); } else if (overrideOptionResult == ButtonResult.No) - try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); } - catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); } + if (OperatingSystem.IsWindows()) + try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); } + catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); } + else + try { Process.Start("xdg-open", upstreamUpstreamHostUrl); } + catch (UnauthorizedAccessException) { Process.Start("sudo", $"xdg-open {upstreamUpstreamHostUrl}"); } } } catch when (sender == null) { }