From 3b0def815969c24b94de1ce52b4b6d986bfc46a0 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 3 Jun 2025 23:06:24 +0800
Subject: [PATCH 1/5] Add new api OpenWebUrl
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 13 +++++++++++++
Flow.Launcher/PublicAPIInstance.cs | 14 ++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index cb60251ed95..e89839131da 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -305,6 +305,19 @@ public interface IPublicAPI
/// Extra FileName Info
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null);
+ ///
+ /// 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.
+ ///
+ public void OpenWebUrl(Uri url, bool? inPrivate = null, bool forceBrower = false);
+
+ ///
+ /// 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.
+ ///
+ public void OpenWebUrl(string url, bool? inPrivate = null, bool forceBrower = false);
+
///
/// 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.
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index c06c5603991..b238a899ddb 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -391,9 +391,9 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null
}
- 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 @@ private void OpenUri(Uri uri, bool? inPrivate = null)
}
}
+ 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);
From 54c2cd13f64b3ef42d60554e79f5365da2d243dd Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 3 Jun 2025 23:06:38 +0800
Subject: [PATCH 2/5] Force web url for WebSearch plugin
---
Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
index 76aeb3250b1..0040cffa7da 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
@@ -71,7 +71,7 @@ public async Task> QueryAsync(Query query, CancellationToken token)
Score = score,
Action = c =>
{
- _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)));
+ _context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)));
return true;
},
@@ -135,7 +135,7 @@ private async Task> SuggestionsAsync(string keyword, string
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
Action = c =>
{
- _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
+ _context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
return true;
},
From c001041ba8d2743617c4931a0ad72038e0fd0fb1 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 3 Jun 2025 23:08:51 +0800
Subject: [PATCH 3/5] Fix build issue
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 4 ++--
Flow.Launcher/PublicAPIInstance.cs | 9 ++++-----
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index e89839131da..b87cc52d0ab 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -309,14 +309,14 @@ public interface IPublicAPI
/// 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.
///
- public void OpenWebUrl(Uri url, bool? inPrivate = null, bool forceBrower = false);
+ public void OpenWebUrl(Uri url, bool? inPrivate = null);
///
/// 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.
///
- public void OpenWebUrl(string url, bool? inPrivate = null, bool forceBrower = false);
+ public void OpenWebUrl(string url, bool? inPrivate = null);
///
/// Opens the URL with the given Uri object.
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index b238a899ddb..bc82c2e8ffb 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -390,7 +390,6 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null
}
}
-
private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrower = false)
{
if (forceBrower || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
@@ -420,14 +419,14 @@ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrower = false)
}
}
- public void OpenUrl(string url, bool? inPrivate = null, bool forceBrower = false)
+ public void OpenWebUrl(string url, bool? inPrivate = null)
{
- OpenUri(new Uri(url), inPrivate, forceBrower);
+ OpenUri(new Uri(url), inPrivate, true);
}
- public void OpenUrl(Uri url, bool? inPrivate = null, bool forceBrower = false)
+ public void OpenWebUrl(Uri url, bool? inPrivate = null)
{
- OpenUri(url, inPrivate, forceBrower);
+ OpenUri(url, inPrivate, true);
}
public void OpenUrl(string url, bool? inPrivate = null)
From f4d6ef371a7738924b3c6a3ee857ce76544e1482 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Wed, 4 Jun 2025 18:57:20 +0800
Subject: [PATCH 4/5] Fix typos
---
Flow.Launcher/PublicAPIInstance.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index bc82c2e8ffb..b4a6b47b7f4 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -390,9 +390,9 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null
}
}
- private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrower = false)
+ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false)
{
- if (forceBrower || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
+ if (forceBrowser || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
var browserInfo = _settings.CustomBrowser;
From eb7a89292b2d61126ede55baf1affb3340bb28fa Mon Sep 17 00:00:00 2001
From: Jeremy
Date: Fri, 13 Jun 2025 22:02:34 +1000
Subject: [PATCH 5/5] update OpenUrl method summary
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index b87cc52d0ab..09c402bcfff 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -319,13 +319,15 @@ public interface IPublicAPI
public void OpenWebUrl(string url, bool? inPrivate = null);
///
- /// Opens the URL with the given Uri object.
+ /// Opens the URL with the given Uri object in browser if scheme is Http or Https.
+ /// If the URL is a local file, it will instead be opened with the default application for that file type.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
///
public void OpenUrl(Uri url, bool? inPrivate = null);
///
- /// Opens the URL with the given string.
+ /// Opens the URL with the given string in browser if scheme is Http or Https.
+ /// If the URL is a local file, it will instead be opened with the default application for that file type.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
/// Non-C# plugins should use this method.
///