Add new api OpenWebUrl

This commit is contained in:
Jack251970 2025-06-03 23:06:24 +08:00
parent 367bf2c3e7
commit 3b0def8159
2 changed files with 25 additions and 2 deletions

View file

@ -305,6 +305,19 @@ namespace Flow.Launcher.Plugin
/// <param name="FileNameOrFilePath">Extra FileName Info</param>
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null);
/// <summary>
/// Opens the URL using the browser with the given Uri object, even if the URL is a local file.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
/// </summary>
public void OpenWebUrl(Uri url, bool? inPrivate = null, bool forceBrower = false);
/// <summary>
/// Opens the URL using the browser with the given string, even if the URL is a local file.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
/// Non-C# plugins should use this method.
/// </summary>
public void OpenWebUrl(string url, bool? inPrivate = null, bool forceBrower = false);
/// <summary>
/// Opens the URL with the given Uri object.
/// The browser and mode used is based on what's configured in Flow's default browser settings.

View file

@ -391,9 +391,9 @@ namespace Flow.Launcher
}
private void OpenUri(Uri uri, bool? inPrivate = null)
private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrower = false)
{
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
if (forceBrower || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
var browserInfo = _settings.CustomBrowser;
@ -420,6 +420,16 @@ namespace Flow.Launcher
}
}
public void OpenUrl(string url, bool? inPrivate = null, bool forceBrower = false)
{
OpenUri(new Uri(url), inPrivate, forceBrower);
}
public void OpenUrl(Uri url, bool? inPrivate = null, bool forceBrower = false)
{
OpenUri(url, inPrivate, forceBrower);
}
public void OpenUrl(string url, bool? inPrivate = null)
{
OpenUri(new Uri(url), inPrivate);