mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-05 13:07:26 +00:00
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace ZonyLrcTools.Desktop.Helpers;
|
|
|
|
public static class UrlHelper
|
|
{
|
|
public static void OpenLink(string url)
|
|
{
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
{
|
|
using var process = Process.Start(new ProcessStartInfo
|
|
{
|
|
FileName = "/bin/sh",
|
|
Arguments = $"-c \"xdg-open {url.Replace("\"", "\\\"")}\"",
|
|
RedirectStandardOutput = true,
|
|
UseShellExecute = false,
|
|
CreateNoWindow = true,
|
|
WindowStyle = ProcessWindowStyle.Hidden
|
|
});
|
|
}
|
|
else
|
|
{
|
|
using var process = Process.Start(new ProcessStartInfo
|
|
{
|
|
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
|
|
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? url : "",
|
|
CreateNoWindow = true,
|
|
UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
|
});
|
|
}
|
|
}
|
|
}
|