Fixed the browser not opening on Linux and macOS.

Fixed the browser not opening on Linux and macOS.
This commit is contained in:
Anon 2022-08-20 18:00:38 +00:00 committed by GitHub
commit e150bd569b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace MinecraftClient.Protocol
{
@ -91,7 +92,28 @@ namespace MinecraftClient.Protocol
{
try
{
Process.Start(link);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var ps = new ProcessStartInfo(link)
{
UseShellExecute = true,
Verb = "open"
};
Process.Start(ps);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", link);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", link);
}
else
{
ConsoleIO.WriteLine("Platform not supported, open up the link manually: " + link);
}
}
catch (Exception e)
{