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) { }